The void initprotonames () function in Snort. C is used to obtain the protocol name in protocol_names [256].
Struct protoent {
Char * p_name; // name
Char * p_aliases; // alias
Short * p_proto; // No.
}
Getprotobyname (): obtains other information about the protocol based on the protocol name.
Format: struct protoent * getprotobyname (const char * Name );
Parameter: Name communication protocol name
Return Value: Success-pointer to struct protoent
Failure-null Description: The name of the communication agreement is used to learn the alias, number, and other information of the communication agreement.
Getprotobynumber (): obtains other information about the protocol according to the number of the Protocol.
Format: struct protoent * getprotobynumber (INT number );
Parameter: Number of the communication protocol in host arrangement
Return Value: Success-pointer to struct protoent
Failed-Null
Note: The name and alias of the communication agreement are known by the number of the communication agreement.
Also ,:-)
Toupper (char c) converts character C to uppercase letters.
D = strdup (char * s): copy the string s to D and return a pointer to the string to be copied. The space required is allocated by malloc () and can be released by free.