Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | diff -Nur wireshark-1.2.7/epan/conversation.c wireshark-1.2.7-fD/epan/conversation.c |
| 2 | --- wireshark-1.2.7/epan/conversation.c 2010-04-01 01:44:39.000000000 +0900 |
| 3 | +++ wireshark-1.2.7-fD/epan/conversation.c 2011-02-23 14:26:35.000000000 +0900 |
| 4 | @@ -40,6 +40,11 @@ |
| 5 | static GHashTable *conversation_hashtable_exact = NULL; |
| 6 | |
| 7 | /* |
| 8 | + * Hash table for conversations without strid. |
| 9 | + */ |
| 10 | +static GHashTable *conversation_hashtable_no_strid = NULL; |
| 11 | + |
| 12 | +/* |
| 13 | * Hash table for conversations with one wildcard address. |
| 14 | */ |
| 15 | static GHashTable *conversation_hashtable_no_addr2 = NULL; |
| 16 | @@ -63,6 +68,7 @@ |
| 17 | port_type ptype; |
| 18 | guint32 port1; |
| 19 | guint32 port2; |
| 20 | + guint32 strid; |
| 21 | } conversation_key; |
| 22 | #endif |
| 23 | /* |
| 24 | @@ -193,6 +199,7 @@ |
| 25 | hash_val += key->port1; |
| 26 | ADD_ADDRESS_TO_HASH(hash_val, &key->addr2); |
| 27 | hash_val += key->port2; |
| 28 | + hash_val += key->strid; |
| 29 | |
| 30 | return hash_val; |
| 31 | } |
| 32 | @@ -217,6 +224,78 @@ |
| 33 | */ |
| 34 | if (v1->port1 == v2->port1 && |
| 35 | v1->port2 == v2->port2 && |
| 36 | + v1->strid == v2->strid && |
| 37 | + ADDRESSES_EQUAL(&v1->addr1, &v2->addr1) && |
| 38 | + ADDRESSES_EQUAL(&v1->addr2, &v2->addr2)) { |
| 39 | + /* |
| 40 | + * Yes. It's the same conversation, and the two |
| 41 | + * address/port pairs are going in the same direction. |
| 42 | + */ |
| 43 | + return 1; |
| 44 | + } |
| 45 | + |
| 46 | + /* |
| 47 | + * Is the first port 2 the same as the second port 1, the first |
| 48 | + * port 1 the same as the second port 2, the first address 2 |
| 49 | + * the same as the second address 1, and the first address 1 |
| 50 | + * the same as the second address 2? |
| 51 | + */ |
| 52 | + if (v1->port2 == v2->port1 && |
| 53 | + v1->port1 == v2->port2 && |
| 54 | + v1->strid == v2->strid && |
| 55 | + ADDRESSES_EQUAL(&v1->addr2, &v2->addr1) && |
| 56 | + ADDRESSES_EQUAL(&v1->addr1, &v2->addr2)) { |
| 57 | + /* |
| 58 | + * Yes. It's the same conversation, and the two |
| 59 | + * address/port pairs are going in opposite directions. |
| 60 | + */ |
| 61 | + return 1; |
| 62 | + } |
| 63 | + |
| 64 | + /* |
| 65 | + * The addresses or the ports don't match. |
| 66 | + */ |
| 67 | + return 0; |
| 68 | +} |
| 69 | + |
| 70 | +/* |
| 71 | + * Compute the hash value for two given address/port pairs if the match |
| 72 | + * has a wildcard stream id. |
| 73 | + */ |
| 74 | +static guint |
| 75 | +conversation_hash_no_strid(gconstpointer v) |
| 76 | +{ |
| 77 | + const conversation_key *key = (const conversation_key *)v; |
| 78 | + guint hash_val; |
| 79 | + |
| 80 | + hash_val = 0; |
| 81 | + ADD_ADDRESS_TO_HASH(hash_val, &key->addr1); |
| 82 | + hash_val += key->port1; |
| 83 | + hash_val += key->port2; |
| 84 | + |
| 85 | + return hash_val; |
| 86 | +} |
| 87 | + |
| 88 | +/* |
| 89 | + * Compare two conversation keys, except for the stream id value. |
| 90 | + */ |
| 91 | +static gint |
| 92 | +conversation_match_no_strid(gconstpointer v, gconstpointer w) |
| 93 | +{ |
| 94 | + const conversation_key *v1 = (const conversation_key *)v; |
| 95 | + const conversation_key *v2 = (const conversation_key *)w; |
| 96 | + |
| 97 | + if (v1->ptype != v2->ptype) |
| 98 | + return 0; /* different types of port */ |
| 99 | + |
| 100 | + /* |
| 101 | + * Are the first and second port 1 values the same, the first and |
| 102 | + * second port 2 values the same, the first and second address |
| 103 | + * 1 values the same, and the first and second address 2 values |
| 104 | + * the same? |
| 105 | + */ |
| 106 | + if (v1->port1 == v2->port1 && |
| 107 | + v1->port2 == v2->port2 && |
| 108 | ADDRESSES_EQUAL(&v1->addr1, &v2->addr1) && |
| 109 | ADDRESSES_EQUAL(&v1->addr2, &v2->addr2)) { |
| 110 | /* |
| 111 | @@ -263,6 +342,7 @@ |
| 112 | ADD_ADDRESS_TO_HASH(hash_val, &key->addr1); |
| 113 | hash_val += key->port1; |
| 114 | hash_val += key->port2; |
| 115 | + hash_val += key->strid; |
| 116 | |
| 117 | return hash_val; |
| 118 | } |
| 119 | @@ -289,6 +369,7 @@ |
| 120 | */ |
| 121 | if (v1->port1 == v2->port1 && |
| 122 | v1->port2 == v2->port2 && |
| 123 | + v1->strid == v2->strid && |
| 124 | ADDRESSES_EQUAL(&v1->addr1, &v2->addr1)) { |
| 125 | /* |
| 126 | * Yes. It's the same conversation, and the two |
| 127 | @@ -317,6 +398,7 @@ |
| 128 | ADD_ADDRESS_TO_HASH(hash_val, &key->addr1); |
| 129 | hash_val += key->port1; |
| 130 | ADD_ADDRESS_TO_HASH(hash_val, &key->addr2); |
| 131 | + hash_val += key->strid; |
| 132 | |
| 133 | return hash_val; |
| 134 | } |
| 135 | @@ -342,6 +424,7 @@ |
| 136 | * address 2 values the same? |
| 137 | */ |
| 138 | if (v1->port1 == v2->port1 && |
| 139 | + v1->strid == v2->strid && |
| 140 | ADDRESSES_EQUAL(&v1->addr1, &v2->addr1) && |
| 141 | ADDRESSES_EQUAL(&v1->addr2, &v2->addr2)) { |
| 142 | /* |
| 143 | @@ -370,6 +453,7 @@ |
| 144 | hash_val = 0; |
| 145 | ADD_ADDRESS_TO_HASH(hash_val, &key->addr1); |
| 146 | hash_val += key->port1; |
| 147 | + hash_val += key->strid; |
| 148 | |
| 149 | return hash_val; |
| 150 | } |
| 151 | @@ -394,6 +478,7 @@ |
| 152 | * and second address 1 values the same? |
| 153 | */ |
| 154 | if (v1->port1 == v2->port1 && |
| 155 | + v1->strid == v2->strid && |
| 156 | ADDRESSES_EQUAL(&v1->addr1, &v2->addr1)) { |
| 157 | /* |
| 158 | * Yes. It's the same conversation, and the two |
| 159 | @@ -420,6 +505,8 @@ |
| 160 | conversation_keys = NULL; |
| 161 | if (conversation_hashtable_exact != NULL) |
| 162 | g_hash_table_destroy(conversation_hashtable_exact); |
| 163 | + if (conversation_hashtable_no_strid != NULL) |
| 164 | + g_hash_table_destroy(conversation_hashtable_no_strid); |
| 165 | if (conversation_hashtable_no_addr2 != NULL) |
| 166 | g_hash_table_destroy(conversation_hashtable_no_addr2); |
| 167 | if (conversation_hashtable_no_port2 != NULL) |
| 168 | @@ -438,6 +525,9 @@ |
| 169 | conversation_hashtable_exact = |
| 170 | g_hash_table_new(conversation_hash_exact, |
| 171 | conversation_match_exact); |
| 172 | + conversation_hashtable_no_strid = |
| 173 | + g_hash_table_new(conversation_hash_no_strid, |
| 174 | + conversation_match_no_strid); |
| 175 | conversation_hashtable_no_addr2 = |
| 176 | g_hash_table_new(conversation_hash_no_addr2, |
| 177 | conversation_match_no_addr2); |
| 178 | @@ -466,6 +556,15 @@ |
| 179 | conversation_new(guint32 setup_frame, address *addr1, address *addr2, port_type ptype, |
| 180 | guint32 port1, guint32 port2, guint options) |
| 181 | { |
| 182 | + return conversation_new_ext(setup_frame, addr1, addr2, ptype, |
| 183 | + port1, port2, options & ~(DISTINCT_SCTP_STREAMID), 0); |
| 184 | + |
| 185 | +} |
| 186 | + |
| 187 | +conversation_t * |
| 188 | +conversation_new_ext(guint32 setup_frame, address *addr1, address *addr2, port_type ptype, |
| 189 | + guint32 port1, guint32 port2, guint options, guint16 strid) |
| 190 | +{ |
| 191 | /* |
| 192 | DISSECTOR_ASSERT(!(options | CONVERSATION_TEMPLATE) || ((options | (NO_ADDR2 | NO_PORT2 | NO_PORT2_FORCE))) && |
| 193 | "A conversation template may not be constructed without wildcard options"); |
| 194 | @@ -486,7 +585,11 @@ |
| 195 | if (options & (NO_PORT2|NO_PORT2_FORCE)) { |
| 196 | hashtable = conversation_hashtable_no_port2; |
| 197 | } else { |
| 198 | - hashtable = conversation_hashtable_exact; |
| 199 | + if (options & DISTINCT_SCTP_STREAMID) { |
| 200 | + hashtable = conversation_hashtable_exact; |
| 201 | + } else { |
| 202 | + hashtable = conversation_hashtable_no_strid; |
| 203 | + } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | @@ -495,6 +598,7 @@ |
| 208 | existing_key.ptype = ptype; |
| 209 | existing_key.port1 = port1; |
| 210 | existing_key.port2 = port2; |
| 211 | + existing_key.strid = strid; |
| 212 | |
| 213 | conversation = g_hash_table_lookup(hashtable, &existing_key); |
| 214 | tc = conversation; /* Remember if lookup was successful */ |
| 215 | @@ -507,6 +611,7 @@ |
| 216 | new_key->ptype = ptype; |
| 217 | new_key->port1 = port1; |
| 218 | new_key->port2 = port2; |
| 219 | + new_key->strid = strid; |
| 220 | |
| 221 | if (conversation) { |
| 222 | for (; conversation->next; conversation = conversation->next) |
| 223 | @@ -568,8 +673,13 @@ |
| 224 | g_hash_table_insert(conversation_hashtable_no_addr2, |
| 225 | conv->key_ptr, conv); |
| 226 | } else { |
| 227 | - g_hash_table_insert(conversation_hashtable_exact, |
| 228 | - conv->key_ptr, conv); |
| 229 | + if (conv->options & DISTINCT_SCTP_STREAMID) { |
| 230 | + g_hash_table_insert(conversation_hashtable_exact, |
| 231 | + conv->key_ptr, conv); |
| 232 | + } else { |
| 233 | + g_hash_table_insert(conversation_hashtable_no_strid, |
| 234 | + conv->key_ptr, conv); |
| 235 | + } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | @@ -602,18 +712,23 @@ |
| 240 | g_hash_table_insert(conversation_hashtable_no_port2, |
| 241 | conv->key_ptr, conv); |
| 242 | } else { |
| 243 | - g_hash_table_insert(conversation_hashtable_exact, |
| 244 | - conv->key_ptr, conv); |
| 245 | + if (conv->options & DISTINCT_SCTP_STREAMID) { |
| 246 | + g_hash_table_insert(conversation_hashtable_exact, |
| 247 | + conv->key_ptr, conv); |
| 248 | + } else { |
| 249 | + g_hash_table_insert(conversation_hashtable_no_strid, |
| 250 | + conv->key_ptr, conv); |
| 251 | + } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * Search a particular hash table for a conversation with the specified |
| 257 | - * {addr1, port1, addr2, port2} and set up before frame_num. |
| 258 | + * {addr1, port1, addr2, port2, strid} and set up before frame_num. |
| 259 | */ |
| 260 | static conversation_t * |
| 261 | conversation_lookup_hashtable(GHashTable *hashtable, guint32 frame_num, address *addr1, address *addr2, |
| 262 | - port_type ptype, guint32 port1, guint32 port2) |
| 263 | + port_type ptype, guint32 port1, guint32 port2, guint16 strid) |
| 264 | { |
| 265 | conversation_t* conversation; |
| 266 | conversation_t* match; |
| 267 | @@ -628,6 +743,7 @@ |
| 268 | key.ptype = ptype; |
| 269 | key.port1 = port1; |
| 270 | key.port2 = port2; |
| 271 | + key.strid = strid; |
| 272 | |
| 273 | match = g_hash_table_lookup(hashtable, &key); |
| 274 | |
| 275 | @@ -685,12 +801,19 @@ |
| 276 | find_conversation(guint32 frame_num, address *addr_a, address *addr_b, port_type ptype, |
| 277 | guint32 port_a, guint32 port_b, guint options) |
| 278 | { |
| 279 | + return find_conversation_ext(frame_num, addr_a, addr_b, ptype, |
| 280 | + port_a, port_b, options | IGNORE_SCTP_STREAMID, 0); |
| 281 | +} |
| 282 | +conversation_t * |
| 283 | +find_conversation_ext(guint32 frame_num, address *addr_a, address *addr_b, port_type ptype, |
| 284 | + guint32 port_a, guint32 port_b, guint options, guint16 strid) |
| 285 | +{ |
| 286 | conversation_t *conversation; |
| 287 | |
| 288 | /* |
| 289 | - * First try an exact match, if we have two addresses and ports. |
| 290 | + * First try an exact match, if we have two addresses and ports and strid. |
| 291 | */ |
| 292 | - if (!(options & (NO_ADDR_B|NO_PORT_B))) { |
| 293 | + if (!(options & (NO_ADDR_B|NO_PORT_B|IGNORE_SCTP_STREAMID))) { |
| 294 | /* |
| 295 | * Neither search address B nor search port B are wildcarded, |
| 296 | * start out with an exact match. |
| 297 | @@ -699,7 +822,7 @@ |
| 298 | conversation = |
| 299 | conversation_lookup_hashtable(conversation_hashtable_exact, |
| 300 | frame_num, addr_a, addr_b, ptype, |
| 301 | - port_a, port_b); |
| 302 | + port_a, port_b, strid); |
| 303 | if ((conversation == NULL) && (addr_a->type == AT_FC)) { |
| 304 | /* In Fibre channel, OXID & RXID are never swapped as |
| 305 | * TCP/UDP ports are in TCP/IP. |
| 306 | @@ -707,7 +830,33 @@ |
| 307 | conversation = |
| 308 | conversation_lookup_hashtable(conversation_hashtable_exact, |
| 309 | frame_num, addr_b, addr_a, ptype, |
| 310 | - port_a, port_b); |
| 311 | + port_a, port_b, strid); |
| 312 | + } |
| 313 | + if (conversation != NULL) |
| 314 | + return conversation; |
| 315 | + } |
| 316 | + |
| 317 | + /* |
| 318 | + * Then, ignoring strid try an exact match, if we have two addresses and ports. |
| 319 | + */ |
| 320 | + if (!(options & (NO_ADDR_B|NO_PORT_B|NO_IGNORE_SCTP_STREAMID))) { |
| 321 | + /* |
| 322 | + * Neither search address B nor search port B are wildcarded, |
| 323 | + * start out with an exact match. |
| 324 | + * Exact matches check both directions. |
| 325 | + */ |
| 326 | + conversation = |
| 327 | + conversation_lookup_hashtable(conversation_hashtable_no_strid, |
| 328 | + frame_num, addr_a, addr_b, ptype, |
| 329 | + port_a, port_b, strid); |
| 330 | + if ((conversation == NULL) && (addr_a->type == AT_FC)) { |
| 331 | + /* In Fibre channel, OXID & RXID are never swapped as |
| 332 | + * TCP/UDP ports are in TCP/IP. |
| 333 | + */ |
| 334 | + conversation = |
| 335 | + conversation_lookup_hashtable(conversation_hashtable_no_strid, |
| 336 | + frame_num, addr_b, addr_a, ptype, |
| 337 | + port_a, port_b, strid); |
| 338 | } |
| 339 | if (conversation != NULL) |
| 340 | return conversation; |
| 341 | @@ -729,7 +878,7 @@ |
| 342 | */ |
| 343 | conversation = |
| 344 | conversation_lookup_hashtable(conversation_hashtable_no_addr2, |
| 345 | - frame_num, addr_a, addr_b, ptype, port_a, port_b); |
| 346 | + frame_num, addr_a, addr_b, ptype, port_a, port_b, strid); |
| 347 | if ((conversation == NULL) && (addr_a->type == AT_FC)) { |
| 348 | /* In Fibre channel, OXID & RXID are never swapped as |
| 349 | * TCP/UDP ports are in TCP/IP. |
| 350 | @@ -737,7 +886,7 @@ |
| 351 | conversation = |
| 352 | conversation_lookup_hashtable(conversation_hashtable_no_addr2, |
| 353 | frame_num, addr_b, addr_a, ptype, |
| 354 | - port_a, port_b); |
| 355 | + port_a, port_b, strid); |
| 356 | } |
| 357 | if (conversation != NULL) { |
| 358 | /* |
| 359 | @@ -779,7 +928,7 @@ |
| 360 | if (!(options & NO_ADDR_B)) { |
| 361 | conversation = |
| 362 | conversation_lookup_hashtable(conversation_hashtable_no_addr2, |
| 363 | - frame_num, addr_b, addr_a, ptype, port_b, port_a); |
| 364 | + frame_num, addr_b, addr_a, ptype, port_b, port_a, strid); |
| 365 | if (conversation != NULL) { |
| 366 | /* |
| 367 | * If this is for a connection-oriented |
| 368 | @@ -821,14 +970,14 @@ |
| 369 | */ |
| 370 | conversation = |
| 371 | conversation_lookup_hashtable(conversation_hashtable_no_port2, |
| 372 | - frame_num, addr_a, addr_b, ptype, port_a, port_b); |
| 373 | + frame_num, addr_a, addr_b, ptype, port_a, port_b, strid); |
| 374 | if ((conversation == NULL) && (addr_a->type == AT_FC)) { |
| 375 | /* In Fibre channel, OXID & RXID are never swapped as |
| 376 | * TCP/UDP ports are in TCP/IP |
| 377 | */ |
| 378 | conversation = |
| 379 | conversation_lookup_hashtable(conversation_hashtable_no_port2, |
| 380 | - frame_num, addr_b, addr_a, ptype, port_a, port_b); |
| 381 | + frame_num, addr_b, addr_a, ptype, port_a, port_b, strid); |
| 382 | } |
| 383 | if (conversation != NULL) { |
| 384 | /* |
| 385 | @@ -870,7 +1019,7 @@ |
| 386 | if (!(options & NO_PORT_B)) { |
| 387 | conversation = |
| 388 | conversation_lookup_hashtable(conversation_hashtable_no_port2, |
| 389 | - frame_num, addr_b, addr_a, ptype, port_b, port_a); |
| 390 | + frame_num, addr_b, addr_a, ptype, port_b, port_a, strid); |
| 391 | if (conversation != NULL) { |
| 392 | /* |
| 393 | * If this is for a connection-oriented |
| 394 | @@ -907,7 +1056,7 @@ |
| 395 | */ |
| 396 | conversation = |
| 397 | conversation_lookup_hashtable(conversation_hashtable_no_addr2_or_port2, |
| 398 | - frame_num, addr_a, addr_b, ptype, port_a, port_b); |
| 399 | + frame_num, addr_a, addr_b, ptype, port_a, port_b, strid); |
| 400 | if (conversation != NULL) { |
| 401 | /* |
| 402 | * If this is for a connection-oriented protocol: |
| 403 | @@ -952,11 +1101,11 @@ |
| 404 | if (addr_a->type == AT_FC) |
| 405 | conversation = |
| 406 | conversation_lookup_hashtable(conversation_hashtable_no_addr2_or_port2, |
| 407 | - frame_num, addr_b, addr_a, ptype, port_a, port_b); |
| 408 | + frame_num, addr_b, addr_a, ptype, port_a, port_b, strid); |
| 409 | else |
| 410 | conversation = |
| 411 | conversation_lookup_hashtable(conversation_hashtable_no_addr2_or_port2, |
| 412 | - frame_num, addr_b, addr_a, ptype, port_b, port_a); |
| 413 | + frame_num, addr_b, addr_a, ptype, port_b, port_a, strid); |
| 414 | if (conversation != NULL) { |
| 415 | /* |
| 416 | * If this is for a connection-oriented protocol, set the |
| 417 | diff -Nur wireshark-1.2.7/epan/conversation.h wireshark-1.2.7-fD/epan/conversation.h |
| 418 | --- wireshark-1.2.7/epan/conversation.h 2010-04-01 01:44:39.000000000 +0900 |
| 419 | +++ wireshark-1.2.7-fD/epan/conversation.h 2011-02-23 14:25:44.000000000 +0900 |
| 420 | @@ -39,11 +39,13 @@ |
| 421 | * TEMPLATE flag will be altered once the first connections (connection |
| 422 | * oriented protocols only) to include the newly found information which |
| 423 | * matched the wildcard options. |
| 424 | + * DISTINCT_SCTP_STREAMID will also save the SCTP stream identifier, if any. |
| 425 | */ |
| 426 | #define NO_ADDR2 0x01 |
| 427 | #define NO_PORT2 0x02 |
| 428 | #define NO_PORT2_FORCE 0x04 |
| 429 | #define CONVERSATION_TEMPLATE 0x08 |
| 430 | +#define DISTINCT_SCTP_STREAMID 0x10 |
| 431 | |
| 432 | /* |
| 433 | * Flags to pass to "find_conversation()" to indicate that the address B |
| 434 | @@ -51,6 +53,8 @@ |
| 435 | */ |
| 436 | #define NO_ADDR_B 0x01 |
| 437 | #define NO_PORT_B 0x02 |
| 438 | +#define IGNORE_SCTP_STREAMID 0x04 |
| 439 | +#define NO_IGNORE_SCTP_STREAMID 0x08 |
| 440 | |
| 441 | #include "packet.h" /* for conversation dissector type */ |
| 442 | |
| 443 | @@ -64,6 +68,7 @@ |
| 444 | port_type ptype; |
| 445 | guint32 port1; |
| 446 | guint32 port2; |
| 447 | + guint16 strid; |
| 448 | } conversation_key; |
| 449 | |
| 450 | typedef struct conversation { |
| 451 | @@ -85,6 +90,13 @@ |
| 452 | extern conversation_t *find_conversation(guint32 frame_num, address *addr_a, address *addr_b, |
| 453 | port_type ptype, guint32 port_a, guint32 port_b, guint options); |
| 454 | |
| 455 | +/* for SCTP stream */ |
| 456 | +extern conversation_t *conversation_new_ext(guint32 setup_frame, address *addr1, address *addr2, |
| 457 | + port_type ptype, guint32 port1, guint32 port2, guint options, guint16 strid); |
| 458 | +extern conversation_t *find_conversation_ext(guint32 frame_num, address *addr_a, address *addr_b, |
| 459 | + port_type ptype, guint32 port_a, guint32 port_b, guint options, guint16 strid); |
| 460 | + |
| 461 | + |
| 462 | extern void conversation_add_proto_data(conversation_t *conv, int proto, |
| 463 | void *proto_data); |
| 464 | extern void *conversation_get_proto_data(conversation_t *conv, int proto); |
| 465 | diff -Nur wireshark-1.2.7/epan/dissectors/packet-diameter.c wireshark-1.2.7-fD/epan/dissectors/packet-diameter.c |
| 466 | --- wireshark-1.2.7/epan/dissectors/packet-diameter.c 2010-04-01 01:44:21.000000000 +0900 |
| 467 | +++ wireshark-1.2.7-fD/epan/dissectors/packet-diameter.c 2011-02-23 13:33:10.000000000 +0900 |
| 468 | @@ -63,8 +63,10 @@ |
| 469 | #include "packet-ntp.h" |
| 470 | #include "packet-diameter.h" |
| 471 | #include "diam_dict.h" |
| 472 | +#include "packet-ssl.h" |
| 473 | |
| 474 | #define SCTP_PORT_DIAMETER 3868 |
| 475 | +#define SCTP_TLS_PORT_DIAMETER 3869 |
| 476 | |
| 477 | /* Diameter Header Flags */ |
| 478 | /* RPETrrrrCCCCCCCCCCCCCCCCCCCCCCCC */ |
| 479 | @@ -271,10 +273,13 @@ |
| 480 | |
| 481 | |
| 482 | static guint gbl_diameterSctpPort=SCTP_PORT_DIAMETER; |
| 483 | +static guint gbl_diameterSctpTlsPort=SCTP_TLS_PORT_DIAMETER; |
| 484 | |
| 485 | static dissector_handle_t diameter_tcp_handle; |
| 486 | static range_t *global_diameter_tcp_port_range; |
| 487 | +static range_t *global_diameter_tcp_tls_port_range; |
| 488 | #define DEFAULT_DIAMETER_PORT_RANGE "3868" |
| 489 | +#define DEFAULT_DIAMETER_TLS_PORT_RANGE "3869" |
| 490 | |
| 491 | /* desegmentation of Diameter over TCP */ |
| 492 | static gboolean gbl_diameter_desegment = TRUE; |
| 493 | @@ -1358,13 +1363,27 @@ |
| 494 | dissector_add("tcp.port", port, diameter_tcp_handle); |
| 495 | } |
| 496 | |
| 497 | +static void |
| 498 | +range_delete_callback_sec(guint32 port) |
| 499 | +{ |
| 500 | + ssl_dissector_delete(port, "diameter", TRUE); |
| 501 | +} |
| 502 | + |
| 503 | +static void |
| 504 | +range_add_callback_sec(guint32 port) |
| 505 | +{ |
| 506 | + ssl_dissector_add(port, "diameter", TRUE); |
| 507 | +} |
| 508 | + |
| 509 | void |
| 510 | proto_reg_handoff_diameter(void) |
| 511 | { |
| 512 | static gboolean Initialized=FALSE; |
| 513 | static guint SctpPort; |
| 514 | + static guint SctpsPort; |
| 515 | static dissector_handle_t diameter_handle; |
| 516 | static range_t *diameter_tcp_port_range; |
| 517 | + static range_t *diameters_tcp_port_range; |
| 518 | |
| 519 | if (!Initialized) { |
| 520 | diameter_handle = find_dissector("diameter"); |
| 521 | @@ -1382,20 +1401,27 @@ |
| 522 | /* AVP Code: 463 EAP-Reissued-Payload */ |
| 523 | dissector_add("diameter.base", 463, |
| 524 | new_create_dissector_handle(dissect_diameter_eap_payload, proto_diameter)); |
| 525 | + |
| 526 | + /* set port for future deletes */ |
| 527 | + diameter_tcp_port_range = range_copy(global_diameter_tcp_port_range); |
| 528 | + range_foreach(diameter_tcp_port_range, range_add_callback); |
| 529 | + diameters_tcp_port_range = range_copy(global_diameter_tcp_tls_port_range); |
| 530 | + range_foreach(diameters_tcp_port_range, range_add_callback_sec); |
| 531 | + |
| 532 | + dissector_add("sctp.port", gbl_diameterSctpPort, diameter_handle); |
| 533 | + ssl_dissector_add(gbl_diameterSctpTlsPort, "diameter", TRUE); |
| 534 | |
| 535 | Initialized=TRUE; |
| 536 | } else { |
| 537 | range_foreach(diameter_tcp_port_range, range_delete_callback); |
| 538 | g_free(diameter_tcp_port_range); |
| 539 | + range_foreach(diameters_tcp_port_range, range_delete_callback_sec); |
| 540 | + g_free(diameters_tcp_port_range); |
| 541 | dissector_delete("sctp.port", SctpPort, diameter_handle); |
| 542 | } |
| 543 | |
| 544 | - /* set port for future deletes */ |
| 545 | - diameter_tcp_port_range = range_copy(global_diameter_tcp_port_range); |
| 546 | - range_foreach(diameter_tcp_port_range, range_add_callback); |
| 547 | |
| 548 | - SctpPort=gbl_diameterSctpPort; |
| 549 | - dissector_add("sctp.port", gbl_diameterSctpPort, diameter_handle); |
| 550 | + |
| 551 | } |
| 552 | |
| 553 | /* registration with the filtering engine */ |
| 554 | @@ -1543,8 +1569,9 @@ |
| 555 | diameter_dissector_table = register_dissector_table("diameter.base", "DIAMETER_3GPP_AVPS", FT_UINT32, BASE_DEC); |
| 556 | diameter_3gpp_avp_dissector_table = register_dissector_table("diameter.3gpp", "DIAMETER_3GPP_AVPS", FT_UINT32, BASE_DEC); |
| 557 | |
| 558 | - /* Set default TCP ports */ |
| 559 | + /* Set default TCP & TLS ports */ |
| 560 | range_convert_str(&global_diameter_tcp_port_range, DEFAULT_DIAMETER_PORT_RANGE, MAX_UDP_PORT); |
| 561 | + range_convert_str(&global_diameter_tcp_tls_port_range, DEFAULT_DIAMETER_TLS_PORT_RANGE, MAX_UDP_PORT); |
| 562 | |
| 563 | /* Register configuration options for ports */ |
| 564 | diameter_module = prefs_register_protocol(proto_diameter, |
| 565 | diff -Nur wireshark-1.2.7/epan/dissectors/packet-sctp.c wireshark-1.2.7-fD/epan/dissectors/packet-sctp.c |
| 566 | --- wireshark-1.2.7/epan/dissectors/packet-sctp.c 2010-04-01 01:44:28.000000000 +0900 |
| 567 | +++ wireshark-1.2.7-fD/epan/dissectors/packet-sctp.c 2011-02-23 13:54:13.000000000 +0900 |
| 568 | @@ -2693,6 +2693,7 @@ |
| 569 | b_bit = tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_DATA_CHUNK_B_BIT; |
| 570 | u_bit = tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_DATA_CHUNK_U_BIT; |
| 571 | stream_id = tvb_get_ntohs(chunk_tvb, DATA_CHUNK_STREAM_ID_OFFSET); |
| 572 | + pinfo->strid = stream_id; |
| 573 | stream_seq_num = tvb_get_ntohs(chunk_tvb, DATA_CHUNK_STREAM_SEQ_NUMBER_OFFSET); |
| 574 | tsn = tvb_get_ntohl(chunk_tvb, DATA_CHUNK_TSN_OFFSET); |
| 575 | |
| 576 | diff -Nur wireshark-1.2.7/epan/dissectors/packet-ssl.c wireshark-1.2.7-fD/epan/dissectors/packet-ssl.c |
| 577 | --- wireshark-1.2.7/epan/dissectors/packet-ssl.c 2010-04-01 01:44:34.000000000 +0900 |
| 578 | +++ wireshark-1.2.7-fD/epan/dissectors/packet-ssl.c 2011-02-23 14:56:36.000000000 +0900 |
| 579 | @@ -500,6 +500,7 @@ |
| 580 | guint* conv_version; |
| 581 | Ssl_private_key_t * private_key; |
| 582 | guint32 port; |
| 583 | + guint16 strid; |
| 584 | |
| 585 | ti = NULL; |
| 586 | ssl_tree = NULL; |
| 587 | @@ -507,9 +508,14 @@ |
| 588 | first_record_in_frame = TRUE; |
| 589 | ssl_session = NULL; |
| 590 | port = 0; |
| 591 | + strid = 0; |
| 592 | |
| 593 | |
| 594 | ssl_debug_printf("\ndissect_ssl enter frame #%u (%s)\n", pinfo->fd->num, (pinfo->fd->flags.visited)?"already visited":"first time"); |
| 595 | + |
| 596 | + if (pinfo->ptype == PT_SCTP) { |
| 597 | + ssl_debug_printf("\ndissect_ssl SCTP stream %hd\n", pinfo->strid); |
| 598 | + } |
| 599 | |
| 600 | /* Track the version using conversations to reduce the |
| 601 | * chance that a packet that simply *looks* like a v2 or |
| 602 | @@ -523,14 +529,14 @@ |
| 603 | * the conv_version, must set the copy in the conversation |
| 604 | * in addition to conv_version |
| 605 | */ |
| 606 | - conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, |
| 607 | - pinfo->srcport, pinfo->destport, 0); |
| 608 | + conversation = find_conversation_ext(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, |
| 609 | + pinfo->srcport, pinfo->destport, NO_IGNORE_SCTP_STREAMID, pinfo->strid); |
| 610 | |
| 611 | if (!conversation) |
| 612 | { |
| 613 | /* create a new conversation */ |
| 614 | - conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, |
| 615 | - pinfo->srcport, pinfo->destport, 0); |
| 616 | + conversation = conversation_new_ext(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, |
| 617 | + pinfo->srcport, pinfo->destport, (pinfo->ptype == PT_SCTP) ? DISTINCT_SCTP_STREAMID : 0, pinfo->strid); |
| 618 | ssl_debug_printf(" new conversation = %p created\n", (void *)conversation); |
| 619 | } |
| 620 | conv_data = conversation_get_proto_data(conversation, proto_ssl); |
| 621 | @@ -549,7 +555,7 @@ |
| 622 | conversation_add_proto_data(conversation, proto_ssl, ssl_session); |
| 623 | |
| 624 | /* we need to know which side of the conversation is speaking */ |
| 625 | - if (ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP)) { |
| 626 | + if (ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype != PT_UDP)) { |
| 627 | dummy.addr = pinfo->src; |
| 628 | dummy.port = port = pinfo->srcport; |
| 629 | } else { |
| 630 | @@ -762,7 +768,7 @@ |
| 631 | * add decrypted data to this packet info */ |
| 632 | ssl_debug_printf("decrypt_ssl3_record: app_data len %d ssl, state 0x%02X\n", |
| 633 | record_length, ssl->state); |
| 634 | - direction = ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP); |
| 635 | + direction = ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype != PT_UDP); |
| 636 | |
| 637 | /* retrieve decoder for this packet direction */ |
| 638 | if (direction != 0) { |
| 639 | @@ -1504,7 +1510,7 @@ |
| 640 | col_append_str(pinfo->cinfo, COL_INFO, "Change Cipher Spec"); |
| 641 | dissect_ssl3_change_cipher_spec(tvb, ssl_record_tree, |
| 642 | offset, conv_version, content_type); |
| 643 | - if (ssl) ssl_change_cipher(ssl, ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP)); |
| 644 | + if (ssl) ssl_change_cipher(ssl, ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype != PT_UDP)); |
| 645 | break; |
| 646 | case SSL_ID_ALERT: |
| 647 | { |
| 648 | @@ -1566,8 +1572,8 @@ |
| 649 | /* we need dissector information when the selected packet is shown. |
| 650 | * ssl session pointer is NULL at that time, so we can't access |
| 651 | * info cached there*/ |
| 652 | - association = ssl_association_find(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP); |
| 653 | - association = association ? association: ssl_association_find(ssl_associations, pinfo->destport, pinfo->ptype == PT_TCP); |
| 654 | + association = ssl_association_find(ssl_associations, pinfo->srcport, pinfo->ptype != PT_UDP); |
| 655 | + association = association ? association: ssl_association_find(ssl_associations, pinfo->destport, pinfo->ptype != PT_UDP); |
| 656 | |
| 657 | proto_item_set_text(ssl_record_tree, |
| 658 | "%s Record Layer: %s Protocol: %s", |
| 659 | diff -Nur wireshark-1.2.7/epan/dissectors/packet-ssl-utils.c wireshark-1.2.7-fD/epan/dissectors/packet-ssl-utils.c |
| 660 | --- wireshark-1.2.7/epan/dissectors/packet-ssl-utils.c 2010-04-01 01:44:27.000000000 +0900 |
| 661 | +++ wireshark-1.2.7-fD/epan/dissectors/packet-ssl-utils.c 2011-02-23 13:33:10.000000000 +0900 |
| 662 | @@ -2713,9 +2713,10 @@ |
| 663 | fprintf(stderr, "association_add() could not find handle for protocol:%s\n",protocol); |
| 664 | } else { |
| 665 | if(port) { |
| 666 | - if(tcp) |
| 667 | + if(tcp) { |
| 668 | dissector_add("tcp.port", port, handle); |
| 669 | - else |
| 670 | + dissector_add("sctp.port", port, handle); |
| 671 | + } else |
| 672 | dissector_add("udp.port", port, handle); |
| 673 | } |
| 674 | g_tree_insert(associations, assoc, assoc); |
| 675 | diff -Nur wireshark-1.2.7/epan/packet_info.h wireshark-1.2.7-fD/epan/packet_info.h |
| 676 | --- wireshark-1.2.7/epan/packet_info.h 2010-04-01 01:44:40.000000000 +0900 |
| 677 | +++ wireshark-1.2.7-fD/epan/packet_info.h 2011-02-23 13:54:52.000000000 +0900 |
| 678 | @@ -169,6 +169,7 @@ |
| 679 | tvbuff_t *gssapi_decrypted_tvb; |
| 680 | gboolean gssapi_data_encrypted; |
| 681 | |
| 682 | + guint16 strid; /* Stream Id of the last DATA chunk in the packet */ |
| 683 | guint32 ppid; /* SCTP PPI of current DATA chunk */ |
| 684 | guint32 ppids[MAX_NUMBER_OF_PPIDS]; /* The first NUMBER_OF_PPIDS PPIDS which are present |
| 685 | * in the SCTP packet |