diff options
author | Jakub Zawadzki <darkjames@darkjames.pl> | 2014-06-10 23:17:01 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-06-23 14:42:20 +0000 |
commit | c9a5fbeb1da9b5566ac9ac36bfdcdee6172ef5c8 (patch) | |
tree | 3f9997b415f193de85aa19094b20ee2e33f9d1d1 /epan | |
parent | eaf6e551febc534fd399688a5703a3c8ccaf26ff (diff) |
Optimize sip_is_known_sip_header()
Profling SIP shows that gperf generated hashing code, is
3 times faster than using GHashTable & g_str_hash/_equal()
This result in about 1% improve of whole dissection (sip traffic with filter).
Change-Id: Id6bf64bacd872e2d1c30a1b6356db444b25ba326
Reviewed-on: https://code.wireshark.org/review/2116
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/CMakeLists.txt | 1 | ||||
-rw-r--r-- | epan/dissectors/Makefile.common | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-sip-hdrs.c | 459 | ||||
-rw-r--r-- | epan/dissectors/packet-sip-hdrs.gperf | 161 | ||||
-rw-r--r-- | epan/dissectors/packet-sip-hdrs.h | 163 | ||||
-rw-r--r-- | epan/dissectors/packet-sip.c | 296 |
6 files changed, 788 insertions, 294 deletions
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index 48b08b4246..b0468a0e59 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -1204,6 +1204,7 @@ set(DISSECTOR_SRC dissectors/packet-sigcomp.c dissectors/packet-simulcrypt.c dissectors/packet-sip.c + dissectors/packet-sip-hdrs.c dissectors/packet-sipfrag.c dissectors/packet-sita.c dissectors/packet-skinny.c diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 02a747840f..5d58a92eb5 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -1130,6 +1130,7 @@ DISSECTOR_SRC = \ packet-sigcomp.c \ packet-simulcrypt.c \ packet-sip.c \ + packet-sip-hdrs.c \ packet-sipfrag.c \ packet-sita.c \ packet-skinny.c \ @@ -1631,6 +1632,7 @@ DISSECTOR_INCLUDES = \ packet-sdp.h \ packet-ses.h \ packet-sip.h \ + packet-sip-hdrs.h \ packet-skinny.h \ packet-sll.h \ packet-smb.h \ diff --git a/epan/dissectors/packet-sip-hdrs.c b/epan/dissectors/packet-sip-hdrs.c new file mode 100644 index 0000000000..ae79dc467e --- /dev/null +++ b/epan/dissectors/packet-sip-hdrs.c @@ -0,0 +1,459 @@ +/* ANSI-C code produced by gperf version 3.0.4 */ +/* Command-line: gperf -m 500 -D packet-sip-hdrs.gperf */ +/* Computed positions: -k'1,3,7,$' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." +#endif + +#line 1 "packet-sip-hdrs.gperf" + +#include <string.h> + +#include "packet-sip-hdrs.h" +#line 16 "packet-sip-hdrs.gperf" +struct name_pos { const char *name; int pos; }; + +#define TOTAL_KEYWORDS 134 +#define MIN_WORD_LENGTH 1 +#define MAX_WORD_LENGTH 29 +#define MIN_HASH_VALUE 3 +#define MAX_HASH_VALUE 220 +/* maximum key range = 218, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +_sip_header_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 55, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 27, 11, 4, + 54, 2, 75, 32, 103, 21, 6, 35, 12, 86, + 3, 39, 6, 34, 9, 7, 1, 82, 58, 86, + 8, 59, 4, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221 + }; + register int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[6]]; + /*FALLTHROUGH*/ + case 6: + case 5: + case 4: + case 3: + hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ + case 2: + case 1: + hval += asso_values[(unsigned char)str[0]]; + break; + } + return hval + asso_values[(unsigned char)str[len - 1]]; +} + +#ifdef __GNUC__ +__inline +#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif +#endif +const struct name_pos * +_sip_header_find (register const char *str, register unsigned int len) +{ + static const unsigned char lengthtable[] = + { + 1, 1, 1, 1, 5, 1, 1, 7, 1, 1, 12, 1, 1, 16, + 7, 15, 7, 19, 6, 8, 13, 4, 19, 15, 13, 6, 15, 18, + 2, 1, 4, 6, 15, 16, 4, 14, 4, 7, 1, 16, 11, 18, + 12, 4, 18, 8, 9, 13, 19, 9, 17, 13, 1, 18, 16, 13, + 9, 29, 1, 8, 10, 12, 17, 14, 14, 15, 19, 14, 10, 12, + 8, 18, 20, 19, 8, 17, 6, 5, 10, 21, 14, 11, 15, 13, + 13, 13, 1, 13, 9, 11, 11, 4, 3, 10, 1, 1, 19, 12, + 12, 17, 14, 10, 18, 9, 5, 7, 8, 15, 20, 9, 12, 11, + 20, 17, 21, 12, 9, 19, 1, 7, 10, 11, 15, 1, 7, 24, + 1, 12, 12, 16, 11, 4, 11, 12 + }; + static const struct name_pos wordlist[] = + { +#line 151 "packet-sip-hdrs.gperf" + {"t", POS_TO}, +#line 137 "packet-sip-hdrs.gperf" + {"e", POS_CONTENT_ENCODING}, +#line 143 "packet-sip-hdrs.gperf" + {"n", POS_IDENTITY_INFO}, +#line 139 "packet-sip-hdrs.gperf" + {"c", POS_CONTENT_TYPE}, +#line 41 "packet-sip-hdrs.gperf" + {"event", POS_EVENT}, +#line 146 "packet-sip-hdrs.gperf" + {"j", POS_REJECT_CONTACT}, +#line 149 "packet-sip-hdrs.gperf" + {"s", POS_SUBJECT}, +#line 32 "packet-sip-hdrs.gperf" + {"contact", POS_CONTACT}, +#line 148 "packet-sip-hdrs.gperf" + {"x", POS_SESSION_EXPIRES}, +#line 144 "packet-sip-hdrs.gperf" + {"r", POS_REFER_TO}, +#line 37 "packet-sip-hdrs.gperf" + {"content-type", POS_CONTENT_TYPE}, +#line 145 "packet-sip-hdrs.gperf" + {"b", POS_REFERED_BY}, +#line 138 "packet-sip-hdrs.gperf" + {"l", POS_CONTENT_LENGTH}, +#line 35 "packet-sip-hdrs.gperf" + {"content-language", POS_CONTENT_LANGUAGE}, +#line 118 "packet-sip-hdrs.gperf" + {"subject", POS_SUBJECT}, +#line 110 "packet-sip-hdrs.gperf" + {"security-client", POS_SECURITY_CLIENT}, +#line 42 "packet-sip-hdrs.gperf" + {"expires", POS_EXPIRES}, +#line 33 "packet-sip-hdrs.gperf" + {"content-disposition", POS_CONTENT_DISPOSITION}, +#line 113 "packet-sip-hdrs.gperf" + {"server", POS_SERVER}, +#line 102 "packet-sip-hdrs.gperf" + {"replaces", POS_REPLACES}, +#line 114 "packet-sip-hdrs.gperf" + {"service-route", POS_SERVICE_ROUTE}, +#line 54 "packet-sip-hdrs.gperf" + {"join", POS_JOIN}, +#line 77 "packet-sip-hdrs.gperf" + {"p-preferred-service", POS_P_PREFERRED_SERV}, +#line 111 "packet-sip-hdrs.gperf" + {"security-server", POS_SECURITY_SERVER}, +#line 80 "packet-sip-hdrs.gperf" + {"p-served-user", POS_P_SERVED_USER}, +#line 19 "packet-sip-hdrs.gperf" + {"accept", POS_ACCEPT}, +#line 115 "packet-sip-hdrs.gperf" + {"session-expires", POS_SESSION_EXPIRES}, +#line 79 "packet-sip-hdrs.gperf" + {"p-refused-uri-list", POS_P_REFUSED_URI_LST}, +#line 124 "packet-sip-hdrs.gperf" + {"to", POS_TO}, +#line 135 "packet-sip-hdrs.gperf" + {"i", POS_CALL_ID}, +#line 38 "packet-sip-hdrs.gperf" + {"cseq", POS_CSEQ}, +#line 94 "packet-sip-hdrs.gperf" + {"reason", POS_REASON}, +#line 125 "packet-sip-hdrs.gperf" + {"trigger-consent", POS_TRIGGER_CONSENT}, +#line 88 "packet-sip-hdrs.gperf" + {"priv-answer-mode", POS_PRIV_ANSWER_MODE}, +#line 109 "packet-sip-hdrs.gperf" + {"rseq", POS_RSEQ}, +#line 62 "packet-sip-hdrs.gperf" + {"p-answer-state", POS_P_ANSWER_STATE}, +#line 93 "packet-sip-hdrs.gperf" + {"rack", POS_RACK}, +#line 105 "packet-sip-hdrs.gperf" + {"require", POS_REQUIRE}, +#line 133 "packet-sip-hdrs.gperf" + {"a", POS_ACCEPT_CONTACT}, +#line 34 "packet-sip-hdrs.gperf" + {"content-encoding", POS_CONTENT_ENCODING}, +#line 107 "packet-sip-hdrs.gperf" + {"retry-after", POS_RETRY_AFTER}, +#line 119 "packet-sip-hdrs.gperf" + {"subscription-state", POS_SUBSCRIPTION_STATE}, +#line 26 "packet-sip-hdrs.gperf" + {"allow-events", POS_ALLOW_EVENTS}, +#line 39 "packet-sip-hdrs.gperf" + {"date", POS_DATE}, +#line 64 "packet-sip-hdrs.gperf" + {"p-asserted-service", POS_P_ASSERTED_SERV}, +#line 103 "packet-sip-hdrs.gperf" + {"reply-to", POS_REPLY_TO}, +#line 97 "packet-sip-hdrs.gperf" + {"recv-info", POS_RECV_INFO}, +#line 29 "packet-sip-hdrs.gperf" + {"authorization", POS_AUTHORIZATION}, +#line 104 "packet-sip-hdrs.gperf" + {"request-disposition", POS_REQUEST_DISPOSITION}, +#line 31 "packet-sip-hdrs.gperf" + {"call-info", POS_CALL_INFO}, +#line 68 "packet-sip-hdrs.gperf" + {"p-charging-vector", POS_P_CHARGING_VECTOR}, +#line 92 "packet-sip-hdrs.gperf" + {"proxy-require", POS_PROXY_REQUIRE}, +#line 150 "packet-sip-hdrs.gperf" + {"k", POS_SUPPORTED}, +#line 84 "packet-sip-hdrs.gperf" + {"permission-missing", POS_PERMISSION_MISSING}, +#line 65 "packet-sip-hdrs.gperf" + {"p-associated-uri", POS_P_ASSOCIATED_URI}, +#line 51 "packet-sip-hdrs.gperf" + {"identity-info", POS_IDENTITY_INFO}, +#line 120 "packet-sip-hdrs.gperf" + {"supported", POS_SUPPORTED}, +#line 67 "packet-sip-hdrs.gperf" + {"p-charging-function-addresses", POS_P_CHARGING_FUNC_ADDRESSES}, +#line 140 "packet-sip-hdrs.gperf" + {"o", POS_EVENT}, +#line 116 "packet-sip-hdrs.gperf" + {"sip-etag", POS_SIP_ETAG}, +#line 40 "packet-sip-hdrs.gperf" + {"error-info", POS_ERROR_INFO}, +#line 96 "packet-sip-hdrs.gperf" + {"record-route", POS_RECORD_ROUTE}, +#line 66 "packet-sip-hdrs.gperf" + {"p-called-party-id", POS_P_CALLED_PARTY_ID}, +#line 73 "packet-sip-hdrs.gperf" + {"p-dcs-redirect", POS_P_DCS_REDIRECT}, +#line 101 "packet-sip-hdrs.gperf" + {"reject-contact", POS_REJECT_CONTACT}, +#line 112 "packet-sip-hdrs.gperf" + {"security-verify", POS_SECURITY_VERIFY}, +#line 28 "packet-sip-hdrs.gperf" + {"authentication-info", POS_AUTHENTICATION_INFO}, +#line 85 "packet-sip-hdrs.gperf" + {"policy-contact", POS_POLICY_CONTACT}, +#line 72 "packet-sip-hdrs.gperf" + {"p-dcs-laes", POS_P_DCS_LAES}, +#line 60 "packet-sip-hdrs.gperf" + {"organization", POS_ORGANIZATION}, +#line 50 "packet-sip-hdrs.gperf" + {"identity", POS_IDENTITY}, +#line 90 "packet-sip-hdrs.gperf" + {"proxy-authenticate", POS_PROXY_AUTHENTICATE}, +#line 76 "packet-sip-hdrs.gperf" + {"p-preferred-identity", POS_P_PREFERRED_IDENTITY}, +#line 91 "packet-sip-hdrs.gperf" + {"proxy-authorization", POS_PROXY_AUTHORIZATION}, +#line 87 "packet-sip-hdrs.gperf" + {"priority", POS_PRIORITY}, +#line 106 "packet-sip-hdrs.gperf" + {"resource-priority", POS_RESOURCE_PRIORITY}, +#line 59 "packet-sip-hdrs.gperf" + {"min-se", POS_MIN_SE}, +#line 108 "packet-sip-hdrs.gperf" + {"route", POS_ROUTE}, +#line 24 "packet-sip-hdrs.gperf" + {"alert-info", POS_ALERT_INFO}, +#line 61 "packet-sip-hdrs.gperf" + {"p-access-network-info", POS_P_ACCESS_NETWORK_INFO}, +#line 20 "packet-sip-hdrs.gperf" + {"accept-contact", POS_ACCEPT_CONTACT}, +#line 27 "packet-sip-hdrs.gperf" + {"answer-mode", POS_ANSWER_MODE}, +#line 22 "packet-sip-hdrs.gperf" + {"accept-language", POS_ACCEPT_LANGUAGE}, +#line 78 "packet-sip-hdrs.gperf" + {"p-profile-key", POS_P_PROFILE_KEY}, +#line 95 "packet-sip-hdrs.gperf" + {"reason-phrase", POS_REASON_PHRASE}, +#line 74 "packet-sip-hdrs.gperf" + {"p-early-media", POS_P_EARLY_MEDIA}, +#line 147 "packet-sip-hdrs.gperf" + {"d", POS_REQUEST_DISPOSITION}, +#line 122 "packet-sip-hdrs.gperf" + {"target-dialog", POS_TARGET_DIALOG}, +#line 98 "packet-sip-hdrs.gperf" + {"refer-sub", POS_REFER_SUB}, +#line 46 "packet-sip-hdrs.gperf" + {"geolocation", POS_GEOLOCATION}, +#line 58 "packet-sip-hdrs.gperf" + {"min-expires", POS_MIN_EXPIRES}, +#line 83 "packet-sip-hdrs.gperf" + {"path", POS_PATH}, +#line 128 "packet-sip-hdrs.gperf" + {"via", POS_VIA}, +#line 70 "packet-sip-hdrs.gperf" + {"p-dcs-osps", POS_P_DCS_OSPS}, +#line 152 "packet-sip-hdrs.gperf" + {"v", POS_VIA}, +#line 142 "packet-sip-hdrs.gperf" + {"y", POS_IDENTITY}, +#line 63 "packet-sip-hdrs.gperf" + {"p-asserted-identity", POS_P_ASSERTED_IDENTITY}, +#line 56 "packet-sip-hdrs.gperf" + {"max-forwards", POS_MAX_FORWARDS}, +#line 43 "packet-sip-hdrs.gperf" + {"feature-caps", POS_FEATURE_CAPS}, +#line 47 "packet-sip-hdrs.gperf" + {"geolocation-error", POS_GEOLOCATION_ERROR}, +#line 36 "packet-sip-hdrs.gperf" + {"content-length", POS_CONTENT_LENGTH}, +#line 127 "packet-sip-hdrs.gperf" + {"user-agent", POS_USER_AGENT}, +#line 71 "packet-sip-hdrs.gperf" + {"p-dcs-billing-info", POS_P_DCS_BILLING_INFO}, +#line 123 "packet-sip-hdrs.gperf" + {"timestamp", POS_TIMESTAMP}, +#line 25 "packet-sip-hdrs.gperf" + {"allow", POS_ALLOW}, +#line 30 "packet-sip-hdrs.gperf" + {"call-id", POS_CALL_ID}, +#line 99 "packet-sip-hdrs.gperf" + {"refer-to", POS_REFER_TO}, +#line 21 "packet-sip-hdrs.gperf" + {"accept-encoding", POS_ACCEPT_ENCODING}, +#line 69 "packet-sip-hdrs.gperf" + {"p-dcs-trace-party-id", POS_P_DCS_TRACE_PARTY_ID}, +#line 86 "packet-sip-hdrs.gperf" + {"policy-id", POS_POLICY_ID}, +#line 52 "packet-sip-hdrs.gperf" + {"info-package", POS_INFO_PKG}, +#line 53 "packet-sip-hdrs.gperf" + {"in-reply-to", POS_IN_REPLY_TO}, +#line 82 "packet-sip-hdrs.gperf" + {"p-visited-network-id", POS_P_VISITED_NETWORK_ID}, +#line 121 "packet-sip-hdrs.gperf" + {"suppress-if-match", POS_SUPPRESS_IF_MATCH}, +#line 75 "packet-sip-hdrs.gperf" + {"p-media-authorization", POS_P_MEDIA_AUTHORIZATION}, +#line 132 "packet-sip-hdrs.gperf" + {"user-to-user", POS_USER_TO_USER}, +#line 131 "packet-sip-hdrs.gperf" + {"diversion", POS_DIVERSION}, +#line 48 "packet-sip-hdrs.gperf" + {"geolocation-routing", POS_GEOLOCATION_ROUTING}, +#line 141 "packet-sip-hdrs.gperf" + {"f", POS_FROM}, +#line 89 "packet-sip-hdrs.gperf" + {"privacy", POS_PRIVACY}, +#line 44 "packet-sip-hdrs.gperf" + {"flow-timer", POS_FLOW_TIMER}, +#line 100 "packet-sip-hdrs.gperf" + {"referred-by", POS_REFERED_BY}, +#line 81 "packet-sip-hdrs.gperf" + {"p-user-database", POS_P_USER_DATABASE}, +#line 134 "packet-sip-hdrs.gperf" + {"u", POS_ALLOW_EVENTS}, +#line 129 "packet-sip-hdrs.gperf" + {"warning", POS_WARNING}, +#line 23 "packet-sip-hdrs.gperf" + {"accept-resource-priority", POS_ACCEPT_RESOURCE_PRIORITY}, +#line 136 "packet-sip-hdrs.gperf" + {"m", POS_CONTACT}, +#line 117 "packet-sip-hdrs.gperf" + {"sip-if-match", POS_SIP_IF_MATCH}, +#line 57 "packet-sip-hdrs.gperf" + {"mime-version", POS_MIME_VERSION}, +#line 130 "packet-sip-hdrs.gperf" + {"www-authenticate", POS_WWW_AUTHENTICATE}, +#line 126 "packet-sip-hdrs.gperf" + {"unsupported", POS_UNSUPPORTED}, +#line 45 "packet-sip-hdrs.gperf" + {"from", POS_FROM}, +#line 55 "packet-sip-hdrs.gperf" + {"max-breadth", POS_MAX_BREADTH}, +#line 49 "packet-sip-hdrs.gperf" + {"history-info", POS_HISTORY_INFO} + }; + + static const short lookup[] = + { + -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, + 4, -1, -1, 5, -1, 6, 7, 8, -1, 9, + -1, -1, 10, 11, -1, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + -1, 27, 28, 29, 30, 31, -1, 32, 33, 34, + -1, 35, 36, -1, 37, 38, 39, 40, -1, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + -1, 52, 53, -1, 54, -1, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, -1, 83, 84, 85, -1, 86, + 87, 88, 89, 90, 91, 92, 93, 94, -1, 95, + 96, -1, 97, 98, 99, 100, -1, 101, 102, 103, + 104, 105, 106, 107, -1, 108, 109, 110, 111, 112, + 113, -1, -1, 114, 115, 116, -1, -1, -1, 117, + -1, 118, 119, -1, 120, -1, 121, -1, -1, -1, + 122, -1, -1, -1, -1, 123, 124, -1, -1, 125, + -1, -1, -1, 126, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 127, -1, -1, -1, -1, -1, 128, + -1, 129, -1, 130, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 131, -1, -1, -1, -1, -1, + 132, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 133 + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = _sip_header_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register int index = lookup[key]; + + if (index >= 0) + { + if (len == lengthtable[index]) + { + register const char *s = wordlist[index].name; + + if (*str == *s && !memcmp (str + 1, s + 1, len - 1)) + return &wordlist[index]; + } + } + } + } + return 0; +} +#line 153 "packet-sip-hdrs.gperf" + +int sip_is_known_sip_header(const char *header_name, unsigned int header_len) +{ + const struct name_pos *npos = _sip_header_find(header_name, header_len); + + if (!npos) + return -1; + return npos->pos; +} diff --git a/epan/dissectors/packet-sip-hdrs.gperf b/epan/dissectors/packet-sip-hdrs.gperf new file mode 100644 index 0000000000..5ca2fca734 --- /dev/null +++ b/epan/dissectors/packet-sip-hdrs.gperf @@ -0,0 +1,161 @@ +%{ +#include <string.h> + +#include "packet-sip-hdrs.h" +%} + +%compare-lengths +%readonly-tables +%struct-type +%null-strings +%language=ANSI-C + +%define lookup-function-name _sip_header_find +%define hash-function-name _sip_header_hash + +struct name_pos { const char *name; int pos; }; + +%% +accept, POS_ACCEPT +accept-contact, POS_ACCEPT_CONTACT +accept-encoding, POS_ACCEPT_ENCODING +accept-language, POS_ACCEPT_LANGUAGE +accept-resource-priority, POS_ACCEPT_RESOURCE_PRIORITY +alert-info, POS_ALERT_INFO +allow, POS_ALLOW +allow-events, POS_ALLOW_EVENTS +answer-mode, POS_ANSWER_MODE +authentication-info, POS_AUTHENTICATION_INFO +authorization, POS_AUTHORIZATION +call-id, POS_CALL_ID +call-info, POS_CALL_INFO +contact, POS_CONTACT +content-disposition, POS_CONTENT_DISPOSITION +content-encoding, POS_CONTENT_ENCODING +content-language, POS_CONTENT_LANGUAGE +content-length, POS_CONTENT_LENGTH +content-type, POS_CONTENT_TYPE +cseq, POS_CSEQ +date, POS_DATE +error-info, POS_ERROR_INFO +event, POS_EVENT +expires, POS_EXPIRES +feature-caps, POS_FEATURE_CAPS +flow-timer, POS_FLOW_TIMER +from, POS_FROM +geolocation, POS_GEOLOCATION +geolocation-error, POS_GEOLOCATION_ERROR +geolocation-routing, POS_GEOLOCATION_ROUTING +history-info, POS_HISTORY_INFO +identity, POS_IDENTITY +identity-info, POS_IDENTITY_INFO +info-package, POS_INFO_PKG +in-reply-to, POS_IN_REPLY_TO +join, POS_JOIN +max-breadth, POS_MAX_BREADTH +max-forwards, POS_MAX_FORWARDS +mime-version, POS_MIME_VERSION +min-expires, POS_MIN_EXPIRES +min-se, POS_MIN_SE +organization, POS_ORGANIZATION +p-access-network-info, POS_P_ACCESS_NETWORK_INFO +p-answer-state, POS_P_ANSWER_STATE +p-asserted-identity, POS_P_ASSERTED_IDENTITY +p-asserted-service, POS_P_ASSERTED_SERV +p-associated-uri, POS_P_ASSOCIATED_URI +p-called-party-id, POS_P_CALLED_PARTY_ID +p-charging-function-addresses, POS_P_CHARGING_FUNC_ADDRESSES +p-charging-vector, POS_P_CHARGING_VECTOR +p-dcs-trace-party-id, POS_P_DCS_TRACE_PARTY_ID +p-dcs-osps, POS_P_DCS_OSPS +p-dcs-billing-info, POS_P_DCS_BILLING_INFO +p-dcs-laes, POS_P_DCS_LAES +p-dcs-redirect, POS_P_DCS_REDIRECT +p-early-media, POS_P_EARLY_MEDIA +p-media-authorization, POS_P_MEDIA_AUTHORIZATION +p-preferred-identity, POS_P_PREFERRED_IDENTITY +p-preferred-service, POS_P_PREFERRED_SERV +p-profile-key, POS_P_PROFILE_KEY +p-refused-uri-list, POS_P_REFUSED_URI_LST +p-served-user, POS_P_SERVED_USER +p-user-database, POS_P_USER_DATABASE +p-visited-network-id, POS_P_VISITED_NETWORK_ID +path, POS_PATH +permission-missing, POS_PERMISSION_MISSING +policy-contact, POS_POLICY_CONTACT +policy-id, POS_POLICY_ID +priority, POS_PRIORITY +priv-answer-mode, POS_PRIV_ANSWER_MODE +privacy, POS_PRIVACY +proxy-authenticate, POS_PROXY_AUTHENTICATE +proxy-authorization, POS_PROXY_AUTHORIZATION +proxy-require, POS_PROXY_REQUIRE +rack, POS_RACK +reason, POS_REASON +reason-phrase, POS_REASON_PHRASE +record-route, POS_RECORD_ROUTE +recv-info, POS_RECV_INFO +refer-sub, POS_REFER_SUB +refer-to, POS_REFER_TO +referred-by, POS_REFERED_BY +reject-contact, POS_REJECT_CONTACT +replaces, POS_REPLACES +reply-to, POS_REPLY_TO +request-disposition, POS_REQUEST_DISPOSITION +require, POS_REQUIRE +resource-priority, POS_RESOURCE_PRIORITY +retry-after, POS_RETRY_AFTER +route, POS_ROUTE +rseq, POS_RSEQ +security-client, POS_SECURITY_CLIENT +security-server, POS_SECURITY_SERVER +security-verify, POS_SECURITY_VERIFY +server, POS_SERVER +service-route, POS_SERVICE_ROUTE +session-expires, POS_SESSION_EXPIRES +sip-etag, POS_SIP_ETAG +sip-if-match, POS_SIP_IF_MATCH +subject, POS_SUBJECT +subscription-state, POS_SUBSCRIPTION_STATE +supported, POS_SUPPORTED +suppress-if-match, POS_SUPPRESS_IF_MATCH +target-dialog, POS_TARGET_DIALOG +timestamp, POS_TIMESTAMP +to, POS_TO +trigger-consent, POS_TRIGGER_CONSENT +unsupported, POS_UNSUPPORTED +user-agent, POS_USER_AGENT +via, POS_VIA +warning, POS_WARNING +www-authenticate, POS_WWW_AUTHENTICATE +diversion, POS_DIVERSION +user-to-user, POS_USER_TO_USER +a, POS_ACCEPT_CONTACT +u, POS_ALLOW_EVENTS +i, POS_CALL_ID +m, POS_CONTACT +e, POS_CONTENT_ENCODING +l, POS_CONTENT_LENGTH +c, POS_CONTENT_TYPE +o, POS_EVENT +f, POS_FROM +y, POS_IDENTITY +n, POS_IDENTITY_INFO +r, POS_REFER_TO +b, POS_REFERED_BY +j, POS_REJECT_CONTACT +d, POS_REQUEST_DISPOSITION +x, POS_SESSION_EXPIRES +s, POS_SUBJECT +k, POS_SUPPORTED +t, POS_TO +v, POS_VIA +%% +int sip_is_known_sip_header(const char *header_name, unsigned int header_len) +{ + const struct name_pos *npos = _sip_header_find(header_name, header_len); + + if (!npos) + return -1; + return npos->pos; +} diff --git a/epan/dissectors/packet-sip-hdrs.h b/epan/dissectors/packet-sip-hdrs.h new file mode 100644 index 0000000000..279f0d48fb --- /dev/null +++ b/epan/dissectors/packet-sip-hdrs.h @@ -0,0 +1,163 @@ +/* packet-sip-hdrs.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * 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, or (at your option) any later version. + * + * 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 General Public License for more details. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __PACKET_SIP_HDRS_H__ +#define __PACKET_SIP_HDRS_H__ + +/* + * ########################### HOWTO ########################### + * In order to add new header for sip do: + * + * 1/ add your-header, POS_FOO_BAR to packet-sip-hdrs.gperf + * 2/ add below #define POS_FOO_BAR next_value + * 3/ update hf_header_array[] in packet-sip.c + * 4/ run gperf -m 500 -D packet-sip-hdrs.gperf > packet-sip-hdrs.c + * ############################################################# + */ + +/* from RFC 3261 + * Updated with info from http://www.iana.org/assignments/sip-parameters + * (last updated 2009-11-11) + * Updated with: http://www.ietf.org/internet-drafts/draft-ietf-sip-resource-priority-05.txt + */ + +#define POS_ACCEPT 1 +#define POS_ACCEPT_CONTACT 2 /* RFC3841 */ +#define POS_ACCEPT_ENCODING 3 +#define POS_ACCEPT_LANGUAGE 4 +#define POS_ACCEPT_RESOURCE_PRIORITY 5 /* RFC4412 */ +#define POS_ALERT_INFO 6 +#define POS_ALLOW 7 +#define POS_ALLOW_EVENTS 8 /* RFC3265 */ +#define POS_ANSWER_MODE 9 /* RFC5373 */ +#define POS_AUTHENTICATION_INFO 10 +#define POS_AUTHORIZATION 11 +#define POS_CALL_ID 12 +#define POS_CALL_INFO 13 +#define POS_CONTACT 14 +#define POS_CONTENT_DISPOSITION 15 +#define POS_CONTENT_ENCODING 16 +#define POS_CONTENT_LANGUAGE 17 +#define POS_CONTENT_LENGTH 18 +#define POS_CONTENT_TYPE 19 +#define POS_CSEQ 20 +#define POS_DATE 21 +#define POS_ERROR_INFO 22 +#define POS_EVENT 23 +#define POS_EXPIRES 24 +#define POS_FEATURE_CAPS 25 /* [RFC6809 */ +#define POS_FLOW_TIMER 26 /* RFC5626 */ +#define POS_FROM 27 +#define POS_GEOLOCATION 28 +#define POS_GEOLOCATION_ERROR 29 +#define POS_GEOLOCATION_ROUTING 30 +#define POS_HISTORY_INFO 31 /* RFC4244 */ +#define POS_IDENTITY 32 /* RFC4474 */ +#define POS_IDENTITY_INFO 33 /* RFC4474 */ +#define POS_INFO_PKG 34 /* RFC-ietf-sipcore-info-events-10.txt */ +#define POS_IN_REPLY_TO 35 /* RFC3261 */ +#define POS_JOIN 36 /* RFC3911 */ +#define POS_MAX_BREADTH 37 /* RFC5393*/ +#define POS_MAX_FORWARDS 38 +#define POS_MIME_VERSION 39 +#define POS_MIN_EXPIRES 40 +#define POS_MIN_SE 41 /* RFC4028 */ +#define POS_ORGANIZATION 42 /* RFC3261 */ +#define POS_P_ACCESS_NETWORK_INFO 43 /* RFC3455 */ +#define POS_P_ANSWER_STATE 44 /* RFC4964 */ +#define POS_P_ASSERTED_IDENTITY 45 /* RFC3325 */ +#define POS_P_ASSERTED_SERV 46 /* RFC6050 */ +#define POS_P_ASSOCIATED_URI 47 /* RFC3455 */ +#define POS_P_CALLED_PARTY_ID 48 /* RFC3455 */ +#define POS_P_CHARGING_FUNC_ADDRESSES 49 /* RFC3455 */ +#define POS_P_CHARGING_VECTOR 50 /* RFC3455 */ +#define POS_P_DCS_TRACE_PARTY_ID 51 /* RFC5503 */ +#define POS_P_DCS_OSPS 52 /* RFC5503 */ +#define POS_P_DCS_BILLING_INFO 53 /* RFC5503 */ +#define POS_P_DCS_LAES 54 /* RFC5503 */ +#define POS_P_DCS_REDIRECT 55 /* RFC5503 */ +#define POS_P_EARLY_MEDIA 56 /* RFC5009 */ +#define POS_P_MEDIA_AUTHORIZATION 57 /* RFC3313 */ +#define POS_P_PREFERRED_IDENTITY 58 /* RFC3325 */ +#define POS_P_PREFERRED_SERV 59 /* RFC6050 */ +#define POS_P_PROFILE_KEY 60 /* RFC5002 */ +#define POS_P_REFUSED_URI_LST 61 /* RFC5318 */ +#define POS_P_SERVED_USER 62 /* RFC5502 */ +#define POS_P_USER_DATABASE 63 /* RFC4457 */ +#define POS_P_VISITED_NETWORK_ID 64 /* RFC3455 */ +#define POS_PATH 65 /* RFC3327 */ +#define POS_PERMISSION_MISSING 66 /* RFC5360 */ +#define POS_POLICY_CONTACT 67 /* RFC3261 */ +#define POS_POLICY_ID 68 /* RFC3261 */ +#define POS_PRIORITY 69 /* RFC3261 */ +#define POS_PRIV_ANSWER_MODE 70 /* RFC5373 */ +#define POS_PRIVACY 71 /* RFC3323 */ +#define POS_PROXY_AUTHENTICATE 72 +#define POS_PROXY_AUTHORIZATION 73 +#define POS_PROXY_REQUIRE 74 +#define POS_RACK 75 /* RFC3262 */ +#define POS_REASON 76 /* RFC3326 */ +#define POS_REASON_PHRASE 77 /* RFC3326 */ +#define POS_RECORD_ROUTE 78 +#define POS_RECV_INFO 79 /* RFC-ietf-sipcore-info-events-10.txt*/ +#define POS_REFER_SUB 80 /* RFC4488 */ +#define POS_REFER_TO 81 /* RFC3515 */ +#define POS_REFERED_BY 82 /* RFC3892 */ +#define POS_REJECT_CONTACT 83 /* RFC3841 */ +#define POS_REPLACES 84 /* RFC3891 */ +#define POS_REPLY_TO 85 /* RFC3261 */ +#define POS_REQUEST_DISPOSITION 86 /* RFC3841 */ +#define POS_REQUIRE 87 /* RFC3261 */ +#define POS_RESOURCE_PRIORITY 88 /* RFC4412 */ +#define POS_RETRY_AFTER 89 /* RFC3261 */ +#define POS_ROUTE 90 /* RFC3261 */ +#define POS_RSEQ 91 /* RFC3262 */ +#define POS_SECURITY_CLIENT 92 /* RFC3329 */ +#define POS_SECURITY_SERVER 93 /* RFC3329 */ +#define POS_SECURITY_VERIFY 94 /* RFC3329 */ +#define POS_SERVER 95 /* RFC3261 */ +#define POS_SERVICE_ROUTE 96 /* RFC3608 */ +#define POS_SESSION_EXPIRES 97 /* RFC4028 */ +#define POS_SIP_ETAG 98 /* RFC3903 */ +#define POS_SIP_IF_MATCH 99 /* RFC3903 */ +#define POS_SUBJECT 100 /* RFC3261 */ +#define POS_SUBSCRIPTION_STATE 101 /* RFC3265 */ +#define POS_SUPPORTED 102 /* RFC3261 */ +#define POS_SUPPRESS_IF_MATCH 103 /* RFC5839 */ +#define POS_TARGET_DIALOG 104 /* RFC4538 */ +#define POS_TIMESTAMP 105 /* RFC3261 */ +#define POS_TO 106 /* RFC3261 */ +#define POS_TRIGGER_CONSENT 107 /* RFC5360 */ +#define POS_UNSUPPORTED 108 /* RFC3261 */ +#define POS_USER_AGENT 109 /* RFC3261 */ +#define POS_VIA 110 /* RFC3261 */ +#define POS_WARNING 111 /* RFC3261 */ +#define POS_WWW_AUTHENTICATE 112 /* RFC3261 */ +#define POS_DIVERSION 113 /* RFC5806 */ +#define POS_USER_TO_USER 114 /* draft-johnston-sipping-cc-uui-09 */ + +/* Encryption (Deprecated) [RFC3261] */ +/* Hide [RFC3261] (deprecated)*/ +/* Response-Key (Deprecated) [RFC3261] */ + +extern int sip_is_known_sip_header(const char *header_name, unsigned int header_len); + +#endif /* __PACKET_SIP_HDRS_H__ */ diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index 0797f5cc7e..22d96efeb7 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -54,6 +54,7 @@ #include "packet-isup.h" #include "packet-sip.h" +#include "packet-sip-hdrs.h" #include "packet-sdp.h" /* SDP needs a transport layer to determine request/response */ @@ -271,255 +272,6 @@ static const char *sip_methods[] = { "PUBLISH" }; -/* from RFC 3261 - * Updated with info from http://www.iana.org/assignments/sip-parameters - * (last updated 2009-11-11) - * Updated with: http://www.ietf.org/internet-drafts/draft-ietf-sip-resource-priority-05.txt - */ -typedef struct { - const char *name; - const char *compact_name; -} sip_header_t; -static const sip_header_t sip_headers[] = { - { "Unknown-header", NULL }, /* 0 Pad so that the real headers start at index 1 */ - { "Accept", NULL }, /* 1 */ -#define POS_ACCEPT 1 - { "Accept-Contact", "a" }, /* 2 RFC3841 */ -#define POS_ACCEPT_CONTACT 2 - { "Accept-Encoding", NULL }, /* 3 */ -#define POS_ACCEPT_ENCODING 3 - { "Accept-Language", NULL }, /* 4 */ -#define POS_ACCEPT_LANGUAGE 4 - { "Accept-Resource-Priority", NULL }, /* 5 RFC4412 */ -#define POS_ACCEPT_RESOURCE_PRIORITY 5 - { "Alert-Info", NULL }, -#define POS_ALERT_INFO 6 - { "Allow", NULL }, -#define POS_ALLOW 7 - { "Allow-Events", "u" }, /* 8 RFC3265 */ -#define POS_ALLOW_EVENTS 8 - { "Answer-Mode", NULL }, /* 9 RFC5373 */ -#define POS_ANSWER_MODE 9 - { "Authentication-Info", NULL }, -#define POS_AUTHENTICATION_INFO 10 - { "Authorization", NULL }, /* 11 */ -#define POS_AUTHORIZATION 11 - { "Call-ID", "i" }, -#define POS_CALL_ID 12 - { "Call-Info", NULL }, -#define POS_CALL_INFO 13 - { "Contact", "m" }, -#define POS_CONTACT 14 - { "Content-Disposition", NULL }, -#define POS_CONTENT_DISPOSITION 15 - { "Content-Encoding", "e" }, /* 16 */ -#define POS_CONTENT_ENCODING 16 - { "Content-Language", NULL }, -#define POS_CONTENT_LANGUAGE 17 - { "Content-Length", "l" }, -#define POS_CONTENT_LENGTH 18 - { "Content-Type", "c" }, -#define POS_CONTENT_TYPE 19 - { "CSeq", NULL }, -#define POS_CSEQ 20 - { "Date", NULL }, /* 21 */ -#define POS_DATE 21 -/* Encryption (Deprecated) [RFC3261] */ - { "Error-Info", NULL }, /* 22 */ -#define POS_ERROR_INFO 22 - { "Event", "o" }, /* 23 */ -#define POS_EVENT 23 - { "Expires", NULL }, /* 24 */ -#define POS_EXPIRES 24 - { "Feature-Caps", NULL }, /* 25 [RFC6809 */ -#define POS_FEATURE_CAPS 25 - { "Flow-Timer", NULL }, /* 26 RFC5626 */ -#define POS_FLOW_TIMER 26 - { "From", "f" }, /* 27 */ -#define POS_FROM 27 - - { "Geolocation", NULL }, /* 28 */ -#define POS_GEOLOCATION 28 - { "Geolocation-Error", NULL }, /* 29 */ -#define POS_GEOLOCATION_ERROR 29 - { "Geolocation-Routing", NULL }, /* 30 */ -#define POS_GEOLOCATION_ROUTING 30 - -/* Hide [RFC3261] (deprecated)*/ - { "History-Info", NULL }, /* 31 RFC4244 */ -#define POS_HISTORY_INFO 31 - { "Identity", "y" }, /* 32 RFC4474 */ -#define POS_IDENTITY 32 - { "Identity-Info", "n" }, /* 33 RFC4474 */ -#define POS_IDENTITY_INFO 33 - { "Info-Package", NULL }, /* 34 RFC-ietf-sipcore-info-events-10.txt */ -#define POS_INFO_PKG 34 - { "In-Reply-To", NULL }, /* 35 RFC3261 */ -#define POS_IN_REPLY_TO 35 - { "Join", NULL }, /* 36 RFC3911 */ -#define POS_JOIN 36 - { "Max-Breadth", NULL }, /* 37 RFC5393*/ -#define POS_MAX_BREADTH 37 - { "Max-Forwards", NULL }, /* 38 */ -#define POS_MAX_FORWARDS 38 - { "MIME-Version", NULL }, /* 39 */ -#define POS_MIME_VERSION 39 - { "Min-Expires", NULL }, /* 40 */ -#define POS_MIN_EXPIRES 40 - { "Min-SE", NULL }, /* 41 RFC4028 */ -#define POS_MIN_SE 41 - { "Organization", NULL }, /* 42 RFC3261 */ -#define POS_ORGANIZATION 42 - { "P-Access-Network-Info", NULL }, /* 43 RFC3455 */ -#define POS_P_ACCESS_NETWORK_INFO 43 - { "P-Answer-State", NULL }, /* 44 RFC4964 */ -#define POS_P_ANSWER_STATE 44 - { "P-Asserted-Identity", NULL }, /* 45 RFC3325 */ -#define POS_P_ASSERTED_IDENTITY 45 - { "P-Asserted-Service", NULL }, /* 46 RFC6050 */ -#define POS_P_ASSERTED_SERV 46 - { "P-Associated-URI", NULL }, /* 47 RFC3455 */ -#define POS_P_ASSOCIATED_URI 47 - { "P-Called-Party-ID", NULL }, /* 48 RFC3455 */ -#define POS_P_CALLED_PARTY_ID 48 - { "P-Charging-Function-Addresses", NULL }, /* 49 RFC3455 */ -#define POS_P_CHARGING_FUNC_ADDRESSES 49 - { "P-Charging-Vector", NULL }, /* 50 RFC3455 */ -#define POS_P_CHARGING_VECTOR 50 - { "P-DCS-Trace-Party-ID", NULL }, /* 51 RFC5503 */ -#define POS_P_DCS_TRACE_PARTY_ID 51 - { "P-DCS-OSPS", NULL }, /* 52 RFC5503 */ -#define POS_P_DCS_OSPS 52 - { "P-DCS-Billing-Info", NULL }, /* 53 RFC5503 */ -#define POS_P_DCS_BILLING_INFO 53 - { "P-DCS-LAES", NULL }, /* 54 RFC5503 */ -#define POS_P_DCS_LAES 54 - { "P-DCS-Redirect", NULL }, /* 55 RFC5503 */ -#define POS_P_DCS_REDIRECT 55 - { "P-Early-Media", NULL }, /* 56 RFC5009 */ -#define POS_P_EARLY_MEDIA 56 - { "P-Media-Authorization", NULL }, /* 57 RFC3313 */ -#define POS_P_MEDIA_AUTHORIZATION 57 - { "P-Preferred-Identity", NULL }, /* 58 RFC3325 */ -#define POS_P_PREFERRED_IDENTITY 58 - { "P-Preferred-Service", NULL }, /* 58 RFC6050 */ -#define POS_P_PREFERRED_SERV 59 - { "P-Profile-Key", NULL }, /* 60 RFC5002 */ -#define POS_P_PROFILE_KEY 60 - { "P-Refused-URI-List", NULL }, /* 61 RFC5318 */ -#define POS_P_REFUSED_URI_LST 61 - { "P-Served-User", NULL }, /* 62 RFC5502 */ -#define POS_P_SERVED_USER 62 - { "P-User-Database", NULL }, /* 63 RFC4457 */ -#define POS_P_USER_DATABASE 63 - { "P-Visited-Network-ID", NULL }, /* 64 RFC3455 */ -#define POS_P_VISITED_NETWORK_ID 64 - { "Path", NULL }, /* 65 RFC3327 */ -#define POS_PATH 65 - { "Permission-Missing", NULL }, /* 66 RFC5360 */ -#define POS_PERMISSION_MISSING 66 - { "Policy-Contact", NULL }, /* 67 RFC3261 */ -#define POS_POLICY_CONTACT 67 - { "Policy-ID", NULL }, /* 68 RFC3261 */ -#define POS_POLICY_ID 68 - { "Priority", NULL }, /* 69 RFC3261 */ -#define POS_PRIORITY 69 - { "Priv-Answer-Mode", NULL }, /* 70 RFC5373 */ -#define POS_PRIV_ANSWER_MODE 70 - { "Privacy", NULL }, /* 71 RFC3323 */ -#define POS_PRIVACY 71 - { "Proxy-Authenticate", NULL }, /* 72 */ -#define POS_PROXY_AUTHENTICATE 72 - { "Proxy-Authorization", NULL }, /* 73 */ -#define POS_PROXY_AUTHORIZATION 73 - { "Proxy-Require", NULL }, /* 74 */ -#define POS_PROXY_REQUIRE 74 - { "RAck", NULL }, /* 75 RFC3262 */ -#define POS_RACK 75 - { "Reason", NULL }, /* 76 RFC3326 */ -#define POS_REASON 76 - { "Reason-Phrase", NULL }, /* 77 RFC3326 */ -#define POS_REASON_PHRASE 77 - { "Record-Route", NULL }, /* 78 */ -#define POS_RECORD_ROUTE 78 - { "Recv-Info", NULL }, /* 79 RFC-ietf-sipcore-info-events-10.txt*/ -#define POS_RECV_INFO 79 - { "Refer-Sub", NULL }, /* 80 RFC4488 */ -#define POS_REFER_SUB 80 - { "Refer-To", "r" }, /* 81 RFC3515 */ -#define POS_REFER_TO 81 - { "Referred-By", "b" }, /* 82 RFC3892 */ -#define POS_REFERED_BY 82 - { "Reject-Contact", "j" }, /* 83 RFC3841 */ -#define POS_REJECT_CONTACT 83 - { "Replaces", NULL }, /* 84 RFC3891 */ -#define POS_REPLACES 84 - { "Reply-To", NULL }, /* 85 RFC3261 */ -#define POS_REPLY_TO 85 - { "Request-Disposition", "d" }, /* 86 RFC3841 */ -#define POS_REQUEST_DISPOSITION 86 - { "Require", NULL }, /* 87 RFC3261 */ -#define POS_REQUIRE 87 - { "Resource-Priority", NULL }, /* 88 RFC4412 */ -#define POS_RESOURCE_PRIORITY 88 - /*{ "Response-Key (Deprecated) [RFC3261]*/ - { "Retry-After", NULL }, /* 89 RFC3261 */ -#define POS_RETRY_AFTER 89 - { "Route", NULL }, /* 90 RFC3261 */ -#define POS_ROUTE 90 - { "RSeq", NULL }, /* 91 RFC3262 */ -#define POS_RSEQ 91 - { "Security-Client", NULL }, /* 92 RFC3329 */ -#define POS_SECURITY_CLIENT 92 - { "Security-Server", NULL }, /* 93 RFC3329 */ -#define POS_SECURITY_SERVER 93 - { "Security-Verify", NULL }, /* 94 RFC3329 */ -#define POS_SECURITY_VERIFY 94 - { "Server", NULL }, /* 95 RFC3261 */ -#define POS_SERVER 95 - { "Service-Route", NULL }, /* 96 RFC3608 */ -#define POS_SERVICE_ROUTE 96 - { "Session-Expires", "x" }, /* 97 RFC4028 */ -#define POS_SESSION_EXPIRES 97 - { "SIP-ETag", NULL }, /* 98 RFC3903 */ -#define POS_SIP_ETAG 98 - { "SIP-If-Match", NULL }, /* 99 RFC3903 */ -#define POS_SIP_IF_MATCH 99 - { "Subject", "s" }, /* 100 RFC3261 */ -#define POS_SUBJECT 100 - { "Subscription-State", NULL }, /* 101 RFC3265 */ -#define POS_SUBSCRIPTION_STATE 101 - { "Supported", "k" }, /* 102 RFC3261 */ -#define POS_SUPPORTED 102 - { "Suppress-If-Match", NULL }, /* 103 RFC5839 */ -#define POS_SUPPRESS_IF_MATCH 103 - { "Target-Dialog", NULL }, /* 104 RFC4538 */ -#define POS_TARGET_DIALOG 104 - { "Timestamp", NULL }, /* 105 RFC3261 */ -#define POS_TIMESTAMP 105 - { "To", "t" }, /* 106 RFC3261 */ -#define POS_TO 106 - { "Trigger-Consent", NULL }, /* 107 RFC5360 */ -#define POS_TRIGGER_CONSENT 107 - { "Unsupported", NULL }, /* 108 RFC3261 */ -#define POS_UNSUPPORTED 108 - { "User-Agent", NULL }, /* 109 RFC3261 */ -#define POS_USER_AGENT 109 - { "Via", "v" }, /* 110 RFC3261 */ -#define POS_VIA 110 - { "Warning", NULL }, /* 111 RFC3261 */ -#define POS_WARNING 111 - { "WWW-Authenticate", NULL }, /* 112 RFC3261 */ -#define POS_WWW_AUTHENTICATE 112 - { "Diversion", NULL }, /* 113 RFC5806 */ -#define POS_DIVERSION 113 - { "User-to-User", NULL }, /* 106 draft-johnston-sipping-cc-uui-09 */ -#define POS_USER_TO_USER 114 -}; - - - - static gint hf_header_array[] = { -1, /* 0"Unknown-header" - Pad so that the real headers start at index 1 */ -1, /* 1"Accept" */ @@ -833,7 +585,6 @@ static line_type_t sip_parse_line(tvbuff_t *tvb, int offset, gint linelen, guint *token_1_len); static gboolean sip_is_known_request(tvbuff_t *tvb, int meth_offset, guint meth_len, guint *meth_idx); -static gint sip_is_known_sip_header(gchar *header_name, guint header_len); static void dfilter_sip_request_line(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint offset, guint meth_len, gint linelen); static void dfilter_sip_status_line(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint line_end, gint offset); @@ -894,7 +645,6 @@ static sip_info_value_t *stat_info; ****************************************************************************/ static GHashTable *sip_hash = NULL; /* Hash table */ -static GHashTable *sip_headers_hash = NULL; /* Hash table */ /* Types for hash table keys and values */ #define MAX_CALL_ID_SIZE 128 @@ -967,28 +717,12 @@ static gint sip_equal(gconstpointer v, gconstpointer v2) static void sip_init_protocol(void) { - guint i; - gchar *value_copy; - /* Destroy any existing hashes. */ if (sip_hash) g_hash_table_destroy(sip_hash); /* Now create them again */ sip_hash = g_hash_table_new(g_str_hash , sip_equal); - /* Create a hashtable with the SIP headers; it will be used to find the related hf entry (POS_x). - * This is faster than the previously used for loop. - * There is no g_hash_table_destroy as the lifetime is the same as the lifetime of Wireshark. - */ - if(!sip_headers_hash){ - sip_headers_hash = g_hash_table_new(g_str_hash , g_str_equal); - for (i = 1; i < array_length(sip_headers); i++){ - value_copy = g_strdup (sip_headers[i].name); - /* Store (and compare) the string in lower case) */ - ascii_strdown_inplace(value_copy); - g_hash_table_insert(sip_headers_hash, (gpointer)value_copy, GINT_TO_POINTER(i)); - } - } } /* Call the export PDU tap with relevant data */ static void @@ -2990,8 +2724,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info proto_tree_add_string_format(hdr_tree, hf_header_array[hf_index], tvb, offset, next_offset - offset, - value+sub_value_offset, "%s String too big: %d bytes", - sip_headers[POS_CSEQ].name, + value+sub_value_offset, "CSeq String too big: %d bytes", strlen_to_copy); } THROW(ReportedBoundsError); @@ -3969,31 +3702,6 @@ static gboolean sip_is_known_request(tvbuff_t *tvb, int meth_offset, return FALSE; } -/* - * Returns index of method in sip_headers - * Header namne should be in lower case - */ -static gint sip_is_known_sip_header(gchar *header_name, guint header_len) -{ - guint pos; - - /* Compact name is one character long */ - if(header_len>1){ - pos = GPOINTER_TO_UINT(g_hash_table_lookup(sip_headers_hash, header_name)); - if (pos!=0) - return pos; - } - - /* Look for compact name match */ - for (pos = 1; pos < array_length(sip_headers); pos++) { - if (sip_headers[pos].compact_name != NULL && - header_len == strlen(sip_headers[pos].compact_name) && - g_ascii_strncasecmp(header_name, sip_headers[pos].compact_name, header_len) == 0) - return pos; - } - - return -1; -} /* * Display the entire message as raw text. |