/* ***********************IMPORTANT *********************************************
 *  Copyright (C) 2004-2007 Thierry Lagarde <tlagarde@users.sourceforge.net>
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License.
 *
 *
 *                      ********************
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *
 *                      ********************
 *
 *
 * You are highly encouraged to send your changes to <tlagarde@users.sourceforge.net>
 * for possible incorporation into the main distribution.
 * By sending these changes to <tlagarde@users.sourceforge.net>,
 * it is assumed that you are offering <tlagarde@users.sourceforge.net>
 * the unlimited, non-exclusive right to reuse, modify, and relicense the code.
 *
 *
 *                      ********************
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **************************************************************************************/
#include "Equipement_Signature.h"
#include "Equipement_Port.h"
#include "Settings.h"
#include "Debug.h"
#include "Objet.h"


gboolean Compare_Entete_Equipement (gchar * Entete_Signature, gchar * Entete_Equipement)
{
	gint      i, Taille_Entete_Equipement, Taille_Entete_Signature, index_Entete_Signature;
	gboolean  Saut;

	ERROR_if (Entete_Signature == NULL);
	ERROR_if (Entete_Equipement == NULL);

	Taille_Entete_Equipement = strlen (Entete_Equipement);
	Taille_Entete_Signature = strlen (Entete_Signature);
	Saut = FALSE;
	index_Entete_Signature = 0;
	for (i = 0; i < Taille_Entete_Equipement; i++) {
		if ((Saut) && (i < (Taille_Entete_Equipement - 5)) && (index_Entete_Signature < (Taille_Entete_Signature - 5))
			&& (Entete_Signature[index_Entete_Signature] == Entete_Equipement[i])
			&& (Entete_Signature[index_Entete_Signature + 1] == Entete_Equipement[i + 1])
			&& (Entete_Signature[index_Entete_Signature + 2] == Entete_Equipement[i + 2])
			&& (Entete_Signature[index_Entete_Signature + 3] == Entete_Equipement[i + 3])
			&& (Entete_Signature[index_Entete_Signature + 4] == Entete_Equipement[i + 4])
			&& (Entete_Signature[index_Entete_Signature + 5] == Entete_Equipement[i + 5])){
			Saut = FALSE;
		}
		
		if ((index_Entete_Signature < (Taille_Entete_Signature - 1)) && (Entete_Signature[index_Entete_Signature] == '%') && (Entete_Signature[index_Entete_Signature + 1] == '%')) {
			Saut = TRUE;
			index_Entete_Signature = index_Entete_Signature + 2;
		}
		if (!Saut) {
			if (Entete_Signature[index_Entete_Signature] != Entete_Equipement[i]) {
				return FALSE;
			}
			index_Entete_Signature++;
		}
		else {
		
		}
	}
	if (index_Entete_Signature!=Taille_Entete_Signature)
		return FALSE;

	return TRUE;
}


struct Struct_Signature *Retour_Pointeur_Signature_Correspondant (struct Struct_Equipement *Equipement)
{
	struct Struct_Signature *Signature= NULL, *Signature_Equivalent= NULL;
	guint     Nb_Objet_Liste, i;
	gint      Nb_Port_Pouvant_Etre_Ouvert;
	gint      Nb_Port_Pouvant_Etre_Ouvert_Fermer,Note_Signature,Note_Signature_Sur;
	gboolean  Resultat;
	
	ERROR_if (Equipement == NULL);
	Signature_Equivalent = NULL;
	Nb_Objet_Liste = g_list_length (Settings->GList_Signature);


	if (Nb_Objet_Liste != 0) {
		for (i = 0; i < Nb_Objet_Liste; i++) {
			Signature = g_list_nth_data (Settings->GList_Signature, i);
			if ((Signature->Nb_Fils == 0) && (strcmp (Signature->Md5_Signature, Equipement->Md5_Signature_W) == 0)) {
			
				
				Note_Signature = 0;     
				Note_Signature_Sur = 0; 
				
			
			
			
				
			
			
			
			
			
				if (Signature->Open_Port != -1)
					if (Signature->Open_Port != Equipement->Nb_Port_Ouvert)
						continue;
			
			
				if (Signature->Close_Port != -1)
					if (Signature->Close_Port != Equipement->Nb_Port_Fermer)
						continue;	
			
			
				if ((Signature->Firewall) && (Equipement->Nb_Port_Ouvert+Equipement->Nb_Port_Fermer > Equipement->Nb_Port_Firewaller))
						continue;
				
			
			
			
			
			
			
				if (Signature->Snmp != AUTRE_INDIFFERENT){
					switch (Signature->Snmp){
						case AUTRE_YES :
							if (!Equipement->Snmp_Ouvert)
								continue;
							break;
						case AUTRE_NO :
							if (Equipement->Snmp_Ouvert)
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu Snmp");
					}
				}			
				
			
				if (Signature->GateWay != AUTRE_INDIFFERENT){
					switch (Signature->GateWay){
						case AUTRE_YES :
							if (!Equipement->GateWay)
								continue;
							break;
						case AUTRE_NO :
							if (Equipement->GateWay)
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu GateWay");
					}
				}
				
			
				if (Signature->Routage != AUTRE_INDIFFERENT){
					switch (Signature->Routage){
						case AUTRE_YES :
							if (!Equipement->Routage)
								continue;
							break;
						case AUTRE_NO :
							if (Equipement->Routage)
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu Routage");
					}
					
				}
/*
				printf("GateWay : %d-%d\n",Signature->GateWay,Equipement->GateWay);
				if ((Signature->GateWay) && (Signature->GateWay != Equipement->GateWay))
						continue;
				printf("Routage : %d-%d\n",Signature->Routage,Equipement->Routage);
				if ((Signature->Routage) && (Signature->Routage != Equipement->Routage))
						continue;
			*/
				
			
			
			
				if (Signature->Smb != AUTRE_INDIFFERENT){
					switch (Signature->Smb){
						case AUTRE_YES :
							if (!Cherche_Si_Port_Ouvert (Equipement, PORT_SAMBA))
								continue;
							break;
						case AUTRE_NO :
							if (Cherche_Si_Port_Ouvert (Equipement, PORT_SAMBA))
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu Smb");
					}
				}
							
				
			
			
			
				if (Signature->Sip != AUTRE_INDIFFERENT){
					switch (Signature->Sip){
						case AUTRE_YES :
							if (!Cherche_Si_Port_Ouvert (Equipement, PORT_SIP))
								continue;
							break;
						case AUTRE_NO :
							if (Cherche_Si_Port_Ouvert (Equipement, PORT_SIP))
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu Sip");
					}
				}
				
			
			
			
				if (Signature->Printer != AUTRE_INDIFFERENT){
					switch (Signature->Printer){
						case AUTRE_YES :
							if (!Cherche_Si_Port_Ouvert (Equipement, PORT_SPOOLER))
								continue;
							break;
						case AUTRE_NO :
							if (Cherche_Si_Port_Ouvert (Equipement, PORT_SPOOLER))
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu Printer");
					}
				}
				
			
			
			
				if (Signature->JetDirect != AUTRE_INDIFFERENT){
					switch (Signature->JetDirect){
						case AUTRE_YES :
							if (!Cherche_Si_Port_Ouvert (Equipement, PORT_JETDIRECT))
								continue;
							break;
						case AUTRE_NO :
							if (Cherche_Si_Port_Ouvert (Equipement, PORT_JETDIRECT))
								continue;
							break;
						default:
							debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu JetDirect");
					}
				}

			
			
			
			
			
				if ((Signature->MAC != NULL) && (strlen (Signature->MAC) != 0))
					if (strcasestr(Equipement->Fournisseur,Signature->MAC) == NULL)
						continue;
								
			
			
				if ((Signature->UDP != NULL) && (strlen (Signature->UDP) != 0))
					if (strncmp (Signature->UDP, Equipement->PortUdpListe,strlen(Signature->UDP)) != 0)
						continue;
						

			
			
				if (Signature->Etat_Snmp_Name != SNMP_INDIFFERENT) {
					if (Signature->Etat_Snmp_Name != SNMP_NULL){
						Resultat = FALSE;
						if ((Signature->Snmp_Name != NULL) && (strlen (Signature->Snmp_Name) != 0))
							Resultat = (strcasestr (Equipement->Snmp.System_Name,Signature->Snmp_Name)  != NULL);
						switch (Signature->Etat_Snmp_Name){
							case SNMP_CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case SNMP_MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_FTP);
						}
					}
					else {
						if (Equipement->Snmp.System_Name != NULL)
							continue; 
					}
				}
				
			
			
				if (Signature->Etat_Snmp_Description != SNMP_INDIFFERENT) {
					if (Signature->Etat_Snmp_Description != SNMP_NULL){
						Resultat = FALSE;
						if ((Signature->Snmp_Description != NULL) && (strlen (Signature->Snmp_Description) != 0))
							Resultat = (strcasestr (Equipement->Snmp.Description,Signature->Snmp_Description)  != NULL);
						switch (Signature->Etat_Snmp_Description){
							case SNMP_CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case SNMP_MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_FTP);
						}
					}
					else {
						if (Equipement->Snmp.Description != NULL)
							continue; 
					}
				}
				
			
			
				if (Signature->Etat_Snmp_Device != SNMP_INDIFFERENT) {
					if (Signature->Etat_Snmp_Device != SNMP_NULL){
						Resultat = FALSE;
						if ((Signature->Snmp_Device != NULL) && (strlen (Signature->Snmp_Device) != 0) && (Equipement->Snmp_Info_Device != NULL))
							Resultat = (strcasestr (Equipement->Snmp_Info_Device,Signature->Snmp_Device)  != NULL);
						switch (Signature->Etat_Snmp_Device){
							case SNMP_CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case SNMP_MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_FTP);
						}
					}
					else {
						if (Equipement->Snmp_Info_Device != NULL)
							continue; 
					}
				}				
				
			
				if (Signature->Etat_FTP != INDIFFERENT) {
					if (Signature->Etat_FTP != CLOSED) {
						if (Signature->Header_FTP == NULL){
							debug_printf (INTERFACE, D_WARN, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_FTP==NULL): [%s]", Signature->System_Name);
							continue;
						}
						if (Equipement->Entete_FTP != NULL)
							Resultat = Compare_Entete_Equipement (Signature->Header_FTP, Equipement->Entete_FTP);
						else
							Resultat = FALSE;
						switch (Signature->Etat_FTP){
							case CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_FTP);
						}
					}
					else {
						if (Cherche_Si_Port_Ouvert (Equipement, PORT_FTP))
							continue;
					}
				}
					
			
			
				if (Signature->Etat_HTTP != INDIFFERENT) {
					if (Signature->Etat_HTTP != CLOSED) {
						if (Signature->Header_HTTP == NULL){
							debug_printf (INTERFACE, D_WARN, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_HTTP==NULL): [%s]", Signature->System_Name);
							continue;
						}	
						if (Equipement->Entete_HTTP != NULL)
							Resultat = Compare_Entete_Equipement (Signature->Header_HTTP, Equipement->Entete_HTTP);
						else
							Resultat = FALSE;
						switch (Signature->Etat_HTTP){
							case CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_HTTP);
						}
					}
					else {
						if (Cherche_Si_Port_Ouvert (Equipement, PORT_HTTP))
							continue;
					}
				}
				
				
			
			
				if (Signature->Etat_IMAP != INDIFFERENT) {
					if (Signature->Etat_IMAP != CLOSED) {
						if (Signature->Header_IMAP == NULL){
							debug_printf (INTERFACE, D_WARN, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_IMAP==NULL): [%s]", Signature->System_Name);
							continue;
						}	
						if (Equipement->Entete_IMAP != NULL)
							Resultat = Compare_Entete_Equipement (Signature->Header_IMAP, Equipement->Entete_IMAP);
						else
							Resultat = FALSE;
						switch (Signature->Etat_IMAP){
							case CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_IMAP);
						}
					}
					else {
						if (Cherche_Si_Port_Ouvert (Equipement, PORT_IMAP))
							continue;
					}
				}
				
				
				
			
			
				if (Signature->Etat_SMTP != INDIFFERENT) {
					if (Signature->Etat_SMTP != CLOSED) {
						if (Signature->Header_SMTP == NULL){
							debug_printf (INTERFACE, D_WARN, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_SMTP==NULL): [%s]", Signature->System_Name);
							continue;
						}	
						if (Equipement->Entete_SMTP != NULL)
							Resultat = Compare_Entete_Equipement (Signature->Header_SMTP, Equipement->Entete_SMTP);
						else
							Resultat = FALSE;
						switch (Signature->Etat_SMTP){
							case CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_IMAP);
						}
					}
					else {
						if (Cherche_Si_Port_Ouvert (Equipement, PORT_SMTP))
							continue;
					}
				}
				
				
			
			
				if (Signature->Etat_SSH != INDIFFERENT) {
					if (Signature->Etat_SSH != CLOSED) {
						if (Signature->Header_SSH == NULL){
							debug_printf (INTERFACE, D_WARN, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_SSH==NULL): [%s]", Signature->System_Name);
							continue;
						}	
						if (Equipement->Entete_SSH != NULL)
							Resultat = Compare_Entete_Equipement (Signature->Header_SSH, Equipement->Entete_SSH);
						else
							Resultat = FALSE;
						switch (Signature->Etat_SSH){
							case CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_IMAP);
						}
					}
					else {
						if (Cherche_Si_Port_Ouvert (Equipement, PORT_SSH))
							continue;
					}
				}
				
				
			
			
				if (Signature->Etat_TELNET != INDIFFERENT) {
					if (Signature->Etat_TELNET != CLOSED) {
						if (Signature->Header_TELNET == NULL){
							debug_printf (INTERFACE, D_WARN, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_TELNET==NULL): [%s]", Signature->System_Name);
							continue;
						}
						if (Equipement->Entete_TELNET != NULL)
							Resultat = Compare_Entete_Equipement (Signature->Header_TELNET, Equipement->Entete_TELNET);
						else
							Resultat = FALSE;
						switch (Signature->Etat_TELNET){
							case CAN_BE_OPENED :
								Note_Signature_Sur++;
								if (Resultat)
									Note_Signature++;
								break;
							case MUST_BE_OPENED :
								if (!Resultat)
									continue;
								break;
							default:
								debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Case inconnu [%s]", Signature->Etat_IMAP);
						}
					}
					else {
						if (Cherche_Si_Port_Ouvert (Equipement, PORT_TELNET))
							continue;
					}
				}
				
			
			
				if ((Note_Signature_Sur != 0)
					&& (Note_Signature == 0))
					continue;
				
			

				Signature_Equivalent = Signature;
			
				return Signature_Equivalent;
				
			}
		}
	}
	return Signature_Equivalent;
}



/*
Nb_Port_Pouvant_Etre_Ouvert = 0;
				Nb_Port_Pouvant_Etre_Ouvert_Fermer = 0;
			
				if (Signature->Etat_FTP != INDIFFERENT) {
					if (Signature->Header_FTP == NULL)
						debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_FTP==NULL): [%s]", Signature->System_Name);
	
					if (Signature->Etat_FTP != CAN_BE_OPENED) {
						if ((Cherche_Si_Port_Ouvert (Equipement, PORT_FTP) == (Signature->Etat_FTP == CLOSED)))
							continue;
					}
					else
						Nb_Port_Pouvant_Etre_Ouvert++;
				
					if ((Signature->Etat_FTP != CLOSED) && (!Compare_Entete_Equipement (Signature->Header_FTP, Equipement->Entete_FTP))) {
					
						if (Signature->Etat_FTP == CAN_BE_OPENED)
							Nb_Port_Pouvant_Etre_Ouvert_Fermer++;
						else
							continue;
					}
				}
				
			
				
			
				if (Signature->Etat_HTTP != INDIFFERENT) {
					if (Signature->Header_HTTP == NULL)
						debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_HTTP==NULL): [%s]", Signature->System_Name);
			
					if (Signature->Etat_HTTP != CAN_BE_OPENED) {
					
						if ((Cherche_Si_Port_Ouvert (Equipement, PORT_HTTP) == (Signature->Etat_HTTP == CLOSED)))
							continue;
					}
					else
						Nb_Port_Pouvant_Etre_Ouvert++;
				
					if ((Signature->Etat_HTTP != CLOSED) && (!Compare_Entete_Equipement (Signature->Header_HTTP, Equipement->Entete_HTTP))) {
					
						if (Signature->Etat_HTTP == CAN_BE_OPENED)
							Nb_Port_Pouvant_Etre_Ouvert_Fermer++;
						else
							continue;
					}
				}
			
				if (Signature->Etat_IMAP != INDIFFERENT) {
					if (Signature->Header_IMAP == NULL)
						debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_IMAP==NULL): [%s]", Signature->System_Name);
					
					if (Signature->Etat_IMAP != CAN_BE_OPENED) {
						if ((Cherche_Si_Port_Ouvert (Equipement, PORT_IMAP) == (Signature->Etat_IMAP == CLOSED)))
							continue;
					}
					else
						Nb_Port_Pouvant_Etre_Ouvert++;
				
					if ((Signature->Etat_IMAP != CLOSED) && (!Compare_Entete_Equipement (Signature->Header_IMAP, Equipement->Entete_IMAP))) {
					
						if (Signature->Etat_IMAP == CAN_BE_OPENED)
							Nb_Port_Pouvant_Etre_Ouvert_Fermer++;
						else
							continue;
					}
				}
				
				
							
				if (Signature->Etat_SMTP != INDIFFERENT) {
					if (Signature->Header_SMTP == NULL)
						debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_SMTP==NULL): [%s]", Signature->System_Name);

					if (Signature->Etat_SMTP != CAN_BE_OPENED) {
						if ((Cherche_Si_Port_Ouvert (Equipement, PORT_SMTP) == (Signature->Etat_SMTP == CLOSED)))
							continue;
					}
					else
						Nb_Port_Pouvant_Etre_Ouvert++;
				
					if ((Signature->Etat_SMTP != CLOSED) && (!Compare_Entete_Equipement (Signature->Header_SMTP , Equipement->Entete_SMTP))) {
					
						if (Signature->Etat_SMTP == CAN_BE_OPENED)
							Nb_Port_Pouvant_Etre_Ouvert_Fermer++;
						else
							continue;
					}
				}
				
							
				if (Signature->Etat_SSH != INDIFFERENT) {
					if (Signature->Header_SSH == NULL)
						debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_SSH==NULL): [%s]", Signature->System_Name);
				
					if (Signature->Etat_SSH != CAN_BE_OPENED) {
						if ((Cherche_Si_Port_Ouvert (Equipement, PORT_SSH) == (Signature->Etat_SSH == CLOSED)))
							continue;
					}
					else
						Nb_Port_Pouvant_Etre_Ouvert++;
				
					if ((Signature->Etat_SSH != CLOSED) && (!Compare_Entete_Equipement (Signature->Header_SSH , Equipement->Entete_SSH))) {
					
						if (Signature->Etat_SSH == CAN_BE_OPENED)
							Nb_Port_Pouvant_Etre_Ouvert_Fermer++;
						else
							continue;
					}
				}		
				
				
			
				if (Signature->Etat_TELNET != INDIFFERENT) {
					if (Signature->Header_TELNET == NULL)
						debug_printf (INTERFACE, D_ERRO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "FingerPrinting (Header_TELNET==NULL): [%s]", Signature->System_Name);

					if (Signature->Etat_TELNET != CAN_BE_OPENED) {
						if ((Cherche_Si_Port_Ouvert (Equipement, PORT_TELNET) == (Signature->Etat_TELNET == CLOSED)))
							continue;
					}
					else
						Nb_Port_Pouvant_Etre_Ouvert++;
				
					if ((Signature->Etat_TELNET != CLOSED) && (!Compare_Entete_Equipement (Signature->Header_TELNET, Equipement->Entete_TELNET))) {
					
						if (Signature->Etat_TELNET == CAN_BE_OPENED)
							Nb_Port_Pouvant_Etre_Ouvert_Fermer++;
						else
							continue;
					}
				}
				if ((Nb_Port_Pouvant_Etre_Ouvert != 0) && (Nb_Port_Pouvant_Etre_Ouvert_Fermer == Nb_Port_Pouvant_Etre_Ouvert))
					continue;
	

*/
