From: <ja...@us...> - 2003-12-15 09:32:24
|
Update of /cvsroot/iptables-p2p/iptables-p2p/kernel In directory sc8-pr-cvs1:/tmp/cvs-serv16460/kernel Modified Files: match_http.c Log Message: formatting Index: match_http.c =================================================================== RCS file: /cvsroot/iptables-p2p/iptables-p2p/kernel/match_http.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- match_http.c 15 Dec 2003 07:23:32 -0000 1.3 +++ match_http.c 15 Dec 2003 09:32:20 -0000 1.4 @@ -67,8 +67,11 @@ next_line(const unsigned char *data, const unsigned char *end) { - while(data <= end) - if(*data++ == '\n') return data; + while (data <= end) + { + if (*data++ == '\n') + return data; + } return NULL; } @@ -78,66 +81,74 @@ const unsigned char **strings) { int i = 0; - while (strings[i]) { - if(memcmp(data, strings[i], strlen(strings[i]) - 1) == 0) + + while (strings[i]) + { + if (memcmp(data, strings[i], strlen(strings[i]) - 1) == 0) return i; + i++; } + return -1; } +#define MM(x) (method_matched == x) +#define HM(x) headers_matched[x] int -match_http( const unsigned char *data, - const unsigned char *end) +match_http(const unsigned char *data, + const unsigned char *end) { - unsigned int method_matched; /* Methods matched */ - unsigned char headers_matched[ HEADERS_COUNT ]; /* headers matched*/ - - if (end - data < SIZE_MIN || end - data > SIZE_MAX) return 0; + unsigned int method_matched; /* Methods matched */ + unsigned int headers_matched[HEADERS_COUNT]; /* Headers matched */ + if (end - data < SIZE_MIN || end - data > SIZE_MAX) + return 0; method_matched = string_match(data, methods_list); - if(method_matched == -1) + if (method_matched == -1) return 0; memset(headers_matched, 0, sizeof(headers_matched)); - while ( (data = next_line(data, end)) ) { + while ((data = next_line(data, end))) + { int header; -/* FIXME: Should check for buffer overrun here - * string_match should receive end - data as an argument - */ + /* + * FIXME: Should check for buffer overrun here. + * + * string_match should receive end - data as an argument + */ header = string_match(data, headers_list); - if( header != -1) - headers_matched[ header ] = 1; - } -#define MM(x) (method_matched == x) -#define HM(x) headers_matched[x] + if (header != -1) + headers_matched[header] = 1; + } /* Kazaa */ - if( ( MM(NM_GET_HASH) || MM(MM_HTTP11) ) && HM(HM_X_KAZZA) ) + if ((MM(NM_GET_HASH) || MM(MM_HTTP11)) && HM(HM_X_KAZZA)) return 1; /* Gnutella */ - if ( (MM(MM_GET_GET) || MM(MM_GET_URIRES) || MM(MM_HTTP11)) && HM(HM_X_GNUTELLA) ) + if ((MM(MM_GET_GET) || MM(MM_GET_URIRES) || MM(MM_HTTP11)) && + (HM(HM_X_GNUTELLA))) return 1; /* OpenFT */ - if( (MM(MM_GET) || MM(MM_HTTP11)) && HM(HM_X_OPENFTALIAS) ) + if ((MM(MM_GET) || MM(MM_HTTP11)) && (HM(HM_X_OPENFTALIAS))) return 1; - if( MM(MM_GET_POISONED) ) + if (MM(MM_GET_POISONED)) return 1; /* Shareazza */ - if( (MM(MM_GET_URIRES) && (HM(HM_CONTENT_URN) || HM(HM_X_QUEUE)) )) + if ((MM(MM_GET_URIRES) && (HM(HM_CONTENT_URN) || HM(HM_X_QUEUE)))) return 1; - if( MM(MM_HTTP11) && HM(HM_X_TIGER_THREE) ) + if (MM(MM_HTTP11) && HM(HM_X_TIGER_THREE)) return 1; return 0; |