2 * Routines for Microsoft Proxy packet dissection
3 * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * This was derived from the dante socks implementation source code.
26 * Most of the information came from common.h and msproxy_clientprotocol.c
28 * See http://www.inet.no/dante for more information
31 /************************************************************************
33 * Notes: These are possible command values. User input is welcome *
35 * Command = 0x040a - Remote host closed connection (maybe ?? ) *
36 * Command = 0x0411 - Remote host closed connection *
37 * Command = 0x0413 - Local host closed connection or SYN worked *
39 ************************************************************************/
52 #include <epan/packet.h>
53 #include <epan/addr_resolv.h>
54 #include <epan/conversation.h>
55 #include <epan/emem.h>
57 #include "packet-tcp.h"
58 #include "packet-udp.h"
60 extern void udp_hash_add(guint16 proto,
61 void (*dissect)(const guchar *, int, frame_data *, proto_tree *));
64 static int proto_msproxy = -1;
66 static int ett_msproxy = -1;
67 static int ett_msproxy_name = -1;
69 static int hf_msproxy_cmd = -1;
70 static int hf_msproxy_clntport = -1;
72 static int hf_msproxy_dstaddr = -1;
74 static int hf_msproxy_srcport = -1;
75 static int hf_msproxy_dstport = -1;
76 static int hf_msproxy_serverport = -1;
77 static int hf_msproxy_serveraddr = -1;
78 static int hf_msproxy_bindport = -1;
79 static int hf_msproxy_bindaddr = -1;
80 static int hf_msproxy_boundport = -1;
81 static int hf_msproxy_bind_id = -1;
82 static int hf_msproxy_resolvaddr = -1;
84 static int hf_msproxy_server_int_addr = -1;
85 static int hf_msproxy_server_int_port = -1;
86 static int hf_msproxy_server_ext_addr = -1;
87 static int hf_msproxy_server_ext_port = -1;
89 static dissector_handle_t msproxy_sub_handle;
92 #define UDP_PORT_MSPROXY 1745
94 #define N_MSPROXY_HELLO 0x05 /* packet 1 from client */
95 #define N_MSPROXY_ACK 0x10 /* packet 1 from server */
96 #define N_MSPROXY_USERINFO_ACK 0x04 /* packet 2 from server */
97 #define N_MSPROXY_AUTH 0x47 /* packet 3 from client */
98 #define N_MSPROXY_RESOLVE 0x07 /* Resolve request */
101 /*$$$ 0x0500 was dante value, I see 0x05ff and 0x0500 */
103 #define MSPROXY_HELLO 0x0500
104 #define MSPROXY_HELLO_2 0x05ff
106 #define MSPROXY_HELLO_ACK 0x1000
108 #define MSPROXY_USERINFO 0x1000
109 #define MSPROXY_USERINFO_ACK 0x0400
111 #define MSPROXY_AUTH 0x4700
112 #define MSPROXY_AUTH_1_ACK 0x4714
113 #define MSPROXY_AUTH_2 0x4701
114 #define MSPROXY_AUTH_2_ACK 0x4715
115 #define MSPROXY_AUTH_2_ACK2 0x4716
117 #define MSPROXY_RESOLVE 0x070d
118 #define MSPROXY_RESOLVE_ACK 0x070f
120 #define MSPROXY_BIND 0x0704
121 #define MSPROXY_BIND_ACK 0x0706
123 #define MSPROXY_TCP_BIND 0x0707
124 #define MSPROXY_TCP_BIND_ACK 0x0708
126 #define MSPROXY_LISTEN 0x0406
128 #define MSPROXY_BINDINFO 0x0709
130 #define MSPROXY_BINDINFO_ACK 0x070a
132 #define MSPROXY_CONNECT 0x071e
133 #define MSPROXY_CONNECT_ACK 0x0703
135 #define MSPROXY_UDPASSOCIATE 0x0705
136 #define MSPROXY_UDPASSOCIATE_ACK 0x0706
138 #define MSPROXY_UDP_BIND_REQ 0x070b
140 #define MSPROXY_CONNECTED 0x042c
141 #define MSPROXY_SESSIONEND 0x251e
143 #define MSPROXY_BIND_AUTHFAILED 0x0804
144 #define MSPROXY_CONNECT_AUTHFAILED 0x081e
145 #define MSPROXY_CONNREFUSED 0x4 /* low 12 bits seem to vary. */
147 #define FROM_SERVER 1 /* direction of packet data for get_msproxy_cmd_name */
148 #define FROM_CLIENT 0
153 /*$$$ should this be the same as redirect_entry_t ?? */
154 /* then the add_conversation could just copy the structure */
155 /* using the same allocation (instance for you object guys) */
156 /* wouldn't work because there may be multiple child conversations */
157 /* from the same MSProxy conversation */
163 guint32 server_int_port;
168 /************** conversation hash stuff ***************/
173 guint32 server_int_port;
179 /************** negotiated conversation hash stuff ***************/
182 static guint32 last_row= 0; /* used to see if packet is new */
184 static void msproxy_sub_dissector( tvbuff_t *tvb, packet_info *pinfo,
187 /* Conversation dissector called from TCP or UDP dissector. Decode and */
188 /* display the msproxy header, the pass the rest of the data to the tcp */
189 /* or udp port decode routine to handle the payload. */
192 redirect_entry_t *redirect_info;
193 conversation_t *conversation;
194 proto_tree *msp_tree;
197 conversation = find_conversation( pinfo->fd->num, &pinfo->src, &pinfo->dst,
198 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
200 DISSECTOR_ASSERT( conversation); /* should always find a conversation */
202 redirect_info = conversation_get_proto_data(conversation,
205 if (check_col(pinfo->cinfo, COL_PROTOCOL))
206 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MS Proxy");
208 if (check_col(pinfo->cinfo, COL_INFO))
209 col_set_str(pinfo->cinfo, COL_INFO,
210 (( redirect_info->proto == PT_TCP) ? "TCP stream" :
214 ti = proto_tree_add_item( tree, proto_msproxy, tvb, 0, 0,
217 msp_tree = proto_item_add_subtree(ti, ett_msproxy);
219 proto_tree_add_uint( msp_tree, hf_msproxy_dstport, tvb, 0, 0,
220 redirect_info->remote_port);
222 proto_tree_add_ipv4( msp_tree, hf_msproxy_dstaddr, tvb, 0, 0,
223 redirect_info->remote_addr);
227 /* set pinfo->{src/dst port} and call the UDP sub-dissector lookup */
229 if ( pinfo->srcport == redirect_info->clnt_port)
230 ptr = &pinfo->destport;
232 ptr = &pinfo->srcport;
234 *ptr = redirect_info->remote_port;
236 if ( redirect_info->proto == PT_TCP)
237 decode_tcp_ports( tvb, 0, pinfo, tree, pinfo->srcport,
238 pinfo->destport, NULL);
240 decode_udp_ports( tvb, 0, pinfo, tree, pinfo->srcport,
241 pinfo->destport, -1);
243 *ptr = redirect_info->server_int_port;
248 static void add_msproxy_conversation( packet_info *pinfo,
249 hash_entry_t *hash_info){
251 /* check to see if a conversation already exists, if it does assume */
252 /* it's our conversation and quit. Otherwise create a new conversation. */
253 /* Load the conversation dissector to our dissector and load the */
254 /* conversation data structure with the info needed to call the TCP or */
255 /* UDP port decoder. */
257 /* NOTE: Currently this assume that the conversation will be created */
258 /* during a packet from the server. If that changes, pinfo->src */
259 /* and pinfo->dst will not be correct and this routine will have */
262 conversation_t *conversation;
263 redirect_entry_t *new_conv_info;
265 if (pinfo->fd->flags.visited) {
267 * We've already processed this frame once, so we
268 * should already have done this.
273 conversation = find_conversation( pinfo->fd->num, &pinfo->src,
274 &pinfo->dst, hash_info->proto, hash_info->server_int_port,
275 hash_info->clnt_port, 0);
277 if ( !conversation) {
278 conversation = conversation_new( pinfo->fd->num, &pinfo->src, &pinfo->dst,
279 hash_info->proto, hash_info->server_int_port,
280 hash_info->clnt_port, 0);
282 conversation_set_dissector(conversation, msproxy_sub_handle);
284 new_conv_info = se_alloc(sizeof(redirect_entry_t));
286 new_conv_info->remote_addr = hash_info->dst_addr;
287 new_conv_info->clnt_port = hash_info->clnt_port;
288 new_conv_info->remote_port = hash_info->dst_port;
289 new_conv_info->server_int_port = hash_info->server_int_port;
290 new_conv_info->proto = hash_info->proto;
292 conversation_add_proto_data(conversation, proto_msproxy,
298 static int display_application_name(tvbuff_t *tvb, int offset,
301 /* display the application name in the proto tree. */
303 /* NOTE: this routine assumes that the tree pointer is valid (not NULL) */
307 length = tvb_strnlen( tvb, offset, 255);
308 proto_tree_add_text( tree, tvb, offset, length, "Application: %.*s",
309 length, tvb_get_ptr( tvb, offset, length));
315 static const char *get_msproxy_cmd_name( int cmd, int direction) {
317 /* return the command name string for cmd */
320 case MSPROXY_HELLO_2:
321 case MSPROXY_HELLO: return "Hello";
323 /* MSPROXY_HELLO_ACK & MSPROXY_USERINFO have the same value (0x1000). */
324 /* So use the direction flag to determine which to use. */
326 case MSPROXY_USERINFO:
327 if ( direction == FROM_SERVER)
328 return "Hello Acknowledge";
331 case MSPROXY_USERINFO_ACK: return "User Info Acknowledge";
332 case MSPROXY_AUTH: return "Authentication";
333 case MSPROXY_AUTH_1_ACK: return "Authentication Acknowledge";
334 case MSPROXY_AUTH_2: return "Authentication 2";
335 case MSPROXY_AUTH_2_ACK: return "Authentication 2 Acknowledge";
336 case MSPROXY_RESOLVE: return "Resolve";
337 case MSPROXY_RESOLVE_ACK: return "Resolve Acknowledge";
338 case MSPROXY_BIND: return "Bind";
339 case MSPROXY_TCP_BIND: return "TCP Bind";
340 case MSPROXY_TCP_BIND_ACK: return "TCP Bind Acknowledge";
341 case MSPROXY_LISTEN: return "Listen";
342 case MSPROXY_BINDINFO: return "Bind Info";
343 case MSPROXY_BINDINFO_ACK: return "Bind Info Acknowledge";
344 case MSPROXY_CONNECT: return "Connect";
345 case MSPROXY_CONNECT_ACK: return "Connect Acknowledge";
346 case MSPROXY_UDPASSOCIATE: return "UDP Associate";
347 case MSPROXY_UDP_BIND_REQ: return "UDP Bind";
348 case MSPROXY_UDPASSOCIATE_ACK: return "Bind or Associate Acknowledge";
349 case MSPROXY_CONNECTED: return "Connected";
350 case MSPROXY_SESSIONEND: return "Session End";
352 default: return "Unknown";
358 static void dissect_user_info_2(tvbuff_t *tvb, int offset,
361 /* decode the user, application, computer name */
367 length = tvb_strnlen( tvb, offset, 255);
370 proto_tree_add_text( tree, tvb, offset, length + 1,
371 "User name: %.*s", length,
372 tvb_get_ptr( tvb, offset, length));
373 offset += length + 2;
375 length = tvb_strnlen( tvb, offset, 255);
378 proto_tree_add_text( tree, tvb, offset, length + 1,
379 "Application name: %.*s", length,
380 tvb_get_ptr( tvb, offset, length));
381 offset += length + 1;
383 length = tvb_strnlen( tvb, offset, 255);
386 proto_tree_add_text( tree, tvb, offset, length + 1,
387 "Client computer name: %.*s", length,
388 tvb_get_ptr( tvb, offset, length));
394 static void dissect_msproxy_request_1(tvbuff_t *tvb, int offset,
397 /* decode the request _1 structure */
402 dissect_user_info_2( tvb, offset, tree);
408 static void dissect_bind(tvbuff_t *tvb, int offset,
409 proto_tree *tree, hash_entry_t *conv_info) {
411 /* decode the bind request */
416 proto_tree_add_item( tree, hf_msproxy_bindaddr, tvb, offset, 4,
421 proto_tree_add_item( tree, hf_msproxy_bindport, tvb, offset, 2,
426 proto_tree_add_item( tree, hf_msproxy_clntport, tvb, offset, 2,
430 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
434 proto_tree_add_item( tree, hf_msproxy_boundport, tvb, offset, 2,
438 display_application_name( tvb, offset, tree);
444 static void dissect_auth(tvbuff_t *tvb, int offset,
447 /* decode the authorization request */
452 proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
453 tvb_get_ptr( tvb, offset, 7));
460 static void dissect_tcp_bind(tvbuff_t *tvb, int offset,
461 proto_tree *tree, hash_entry_t *conv_info) {
463 /* decode the bind packet. Set the protocol type in the conversation */
464 /* information so the bind_info can use it to create the payload */
468 conv_info->proto = PT_TCP;
473 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
477 proto_tree_add_item( tree, hf_msproxy_boundport, tvb, offset, 2,
481 display_application_name( tvb, offset, tree);
486 static void dissect_request_connect(tvbuff_t *tvb, int offset,
487 proto_tree *tree, hash_entry_t *conv_info) {
489 /* decode the connect request, display */
491 conv_info->proto = PT_TCP;
496 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
499 conv_info->dst_port = tvb_get_ntohs( tvb, offset);
503 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
506 conv_info->dst_addr = tvb_get_ipv4( tvb, offset);
510 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
513 proto_tree_add_uint( tree, hf_msproxy_clntport, tvb, offset, 2,
514 conv_info->clnt_port);
518 display_application_name( tvb, offset, tree);
523 static void dissect_bind_info_ack(tvbuff_t *tvb, int offset, proto_tree *tree) {
525 /* decode the client bind info ack */
531 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
535 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
539 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
543 proto_tree_add_item( tree, hf_msproxy_server_int_port, tvb,
547 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
551 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
555 display_application_name( tvb, offset, tree);
560 static void dissect_request_resolve(tvbuff_t *tvb, int offset,
563 /* dissect the request resolve structure */
564 /* display a string with a length, characters encoding */
565 /* they are displayed under a tree with the name in Label variable */
566 /* return the length of the string and the length byte */
568 proto_tree *name_tree;
571 int length = tvb_get_guint8( tvb, offset);
574 ti = proto_tree_add_text(tree, tvb, offset, length + 1,
575 "Host Name: %.*s", length,
576 tvb_get_ptr( tvb, offset + 18, length));
578 name_tree = proto_item_add_subtree(ti, ett_msproxy_name);
580 proto_tree_add_text( name_tree, tvb, offset, 1, "Length: %d",
586 proto_tree_add_text( name_tree, tvb, offset, length, "String: %s",
587 tvb_get_ptr( tvb, offset, length));
593 static void dissect_udp_bind(tvbuff_t *tvb, int offset,
594 proto_tree *tree, hash_entry_t *conv_info) {
596 /* Dissect the udp bind request. Load the protocol id (PT_UDP) and the */
597 /* remote address so bind_info can use it to create conversation */
600 conv_info->proto = PT_UDP;
606 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
612 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
617 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
623 display_application_name( tvb, offset, tree);
627 static void dissect_udp_assoc(tvbuff_t *tvb, int offset,
628 proto_tree *tree, hash_entry_t *conv_info) {
630 /* dissect the udp associate request. And load client port into */
631 /* conversation data structure for later. */
637 proto_tree_add_item( tree, hf_msproxy_clntport, tvb, offset, 2,
640 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
645 display_application_name( tvb, offset, tree);
649 static void dissect_msproxy_request(tvbuff_t *tvb,
650 proto_tree *tree, hash_entry_t *conv_info) {
656 proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
657 tvb_get_letohl( tvb, offset));
660 proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
661 tvb_get_letohl( tvb, offset));
664 proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%0x",
665 tvb_get_letohl( tvb, offset));
668 proto_tree_add_text( tree, tvb, offset, 1, "Server ack: %u",
669 tvb_get_guint8( tvb, offset));
672 proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: %u",
673 tvb_get_guint8( tvb, offset));
676 proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
677 tvb_get_ptr( tvb, offset, 4));
683 cmd = tvb_get_ntohs( tvb, offset);
686 proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
687 cmd, "Command: 0x%02x (%s)", cmd,
688 get_msproxy_cmd_name( cmd, FROM_CLIENT));
694 dissect_auth( tvb, offset, tree);
698 dissect_bind( tvb, offset, tree, conv_info);
701 case MSPROXY_UDP_BIND_REQ:
702 dissect_udp_bind( tvb, offset, tree, conv_info);
705 case MSPROXY_AUTH_2: /*$$ this is probably wrong place for this */
706 case MSPROXY_TCP_BIND:
707 dissect_tcp_bind( tvb, offset, tree, conv_info);
710 case MSPROXY_RESOLVE:
711 dissect_request_resolve( tvb, offset, tree);
714 case MSPROXY_CONNECT:
716 dissect_request_connect( tvb, offset, tree,
720 case MSPROXY_BINDINFO_ACK:
721 dissect_bind_info_ack( tvb, offset, tree);
725 case MSPROXY_HELLO_2:
726 dissect_msproxy_request_1( tvb, offset, tree);
729 case MSPROXY_UDPASSOCIATE:
730 dissect_udp_assoc( tvb, offset, tree, conv_info);
734 proto_tree_add_text( tree, tvb, offset, 0,
735 "Unhandled request command (report this, please)");
741 static void dissect_hello_ack(tvbuff_t *tvb, int offset, proto_tree *tree) {
743 /* decode the hello acknowledge packet */
748 proto_tree_add_item( tree, hf_msproxy_serverport, tvb, offset, 2,
752 proto_tree_add_item( tree, hf_msproxy_serveraddr, tvb, offset, 4,
760 /* XXX - implement me */
761 static void dissect_user_info_ack(tvbuff_t *tvb _U_, int offset,
762 proto_tree *tree _U_) {
764 /* decode the response _2 structure */
774 static void dissect_udpassociate_ack(tvbuff_t *tvb, int offset,
780 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
784 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
788 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
792 display_application_name( tvb, offset, tree);
798 static void dissect_auth_1_ack(tvbuff_t *tvb, int offset,
803 proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
804 tvb_get_ptr( tvb, offset, 7));
807 /* XXX - always 255? */
808 proto_tree_add_text( tree, tvb, offset, 255, "NT domain: %.255s",
809 tvb_get_ptr( tvb, offset, 255));
815 /* XXX - implement me */
816 static void dissect_msproxy_response_4( tvbuff_t *tvb _U_, int offset,
817 proto_tree *tree _U_) {
819 /* decode the response _4 structure */
826 static void dissect_connect_ack( tvbuff_t *tvb, int offset, packet_info *pinfo,
827 proto_tree *tree, hash_entry_t *conv_info) {
829 /* decode the connect ack packet */
833 proto_tree_add_item( tree, hf_msproxy_server_int_port, tvb,
837 conv_info->proto = PT_TCP;
838 conv_info->server_int_port = tvb_get_ntohs( tvb, offset);
842 proto_tree_add_item( tree, hf_msproxy_server_int_addr, tvb,
846 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
850 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
854 display_application_name( tvb, offset, tree);
857 add_msproxy_conversation( pinfo, conv_info);
862 static void dissect_tcp_bind_ack( tvbuff_t *tvb, int offset, proto_tree *tree) {
864 /* decode the tcp bind */
869 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
873 proto_tree_add_uint( tree, hf_msproxy_server_int_port, tvb,
877 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
881 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
886 display_application_name( tvb, offset, tree);
892 static void dissect_bind_info( tvbuff_t *tvb, int offset, packet_info *pinfo,
893 proto_tree *tree, hash_entry_t *conv_info) {
895 /* decode the Bind info response from server */
900 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
905 conv_info->dst_port = tvb_get_ntohs( tvb, offset);
907 proto_tree_add_uint( tree, hf_msproxy_dstport, tvb, offset, 2,
908 conv_info->dst_port);
911 conv_info->dst_addr = tvb_get_ipv4( tvb, offset);
913 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
917 conv_info->server_int_port = tvb_get_ntohs( tvb, offset);
919 proto_tree_add_uint( tree, hf_msproxy_server_int_port, tvb,
920 offset, 2, conv_info->server_int_port);
924 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
928 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
932 display_application_name( tvb, offset, tree);
936 add_msproxy_conversation( pinfo, conv_info);
941 static void dissect_resolve(tvbuff_t *tvb, int offset, proto_tree *tree) {
943 /* dissect the response resolve structure */
944 /* display a string with a length, characters encoding */
945 /* they are displayed under a tree with the name in Label variable */
946 /* return the length of the string and the length byte */
951 addr_offset = tvb_get_guint8( tvb, offset);
953 proto_tree_add_text( tree, tvb, offset, 1, "Address offset: %d",
960 offset += addr_offset;
962 proto_tree_add_item( tree, hf_msproxy_resolvaddr, tvb, offset, 4,
969 static void dissect_msproxy_response(tvbuff_t *tvb, packet_info *pinfo,
970 proto_tree *tree, hash_entry_t *conv_info) {
976 proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
977 tvb_get_letohl( tvb, offset));
980 proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
981 tvb_get_letohl( tvb, offset));
984 proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%04x",
985 tvb_get_letohl( tvb, offset));
988 proto_tree_add_text( tree, tvb, offset, 1, "Client ack: 0x%02x",
989 tvb_get_guint8( tvb, offset));
992 proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: 0x%02x",
993 tvb_get_guint8( tvb, offset));
997 proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
998 tvb_get_ptr( tvb, offset, 4));
1005 cmd = tvb_get_ntohs( tvb, offset);
1008 proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
1009 cmd, "Command: 0x%02x (%s)", cmd,
1010 get_msproxy_cmd_name( cmd, FROM_SERVER));
1014 case MSPROXY_HELLO_ACK:
1015 dissect_hello_ack( tvb, offset, tree);
1018 case MSPROXY_USERINFO_ACK:
1019 dissect_user_info_ack( tvb, offset, tree);
1022 case MSPROXY_AUTH_1_ACK:
1023 dissect_auth_1_ack( tvb, offset, tree);
1026 /* this also handle the MSPROXY_BIND_ACK ??? check this */
1028 case MSPROXY_UDPASSOCIATE_ACK:
1029 dissect_udpassociate_ack( tvb, offset, tree);
1032 case MSPROXY_AUTH_2_ACK:
1033 case MSPROXY_AUTH_2_ACK2:
1034 dissect_msproxy_response_4( tvb, offset, tree);
1037 case MSPROXY_TCP_BIND_ACK:
1038 dissect_tcp_bind_ack( tvb, offset, tree);
1041 case MSPROXY_CONNECT_ACK:
1042 dissect_connect_ack( tvb, offset, pinfo, tree,
1046 case MSPROXY_BINDINFO:
1047 dissect_bind_info( tvb, offset, pinfo, tree, conv_info);
1050 case MSPROXY_RESOLVE_ACK:
1051 dissect_resolve( tvb, offset, tree);
1054 case MSPROXY_CONNECT_AUTHFAILED:
1055 case MSPROXY_BIND_AUTHFAILED:
1056 proto_tree_add_text( tree, tvb, offset, 0, "No know information (help wanted)");
1062 (((cmd >> 8) == MSPROXY_CONNREFUSED) ||
1063 ((cmd >> 12) == MSPROXY_CONNREFUSED)))
1064 proto_tree_add_text( tree, tvb, offset, 0,
1065 "No know information (help wanted)");
1068 proto_tree_add_text( tree, tvb, offset, 0,
1069 "Unhandled response command (report this, please)");
1077 static void dissect_msproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1080 proto_tree *msproxy_tree = NULL;
1085 hash_entry_t *hash_info;
1086 conversation_t *conversation;
1088 if (check_col(pinfo->cinfo, COL_PROTOCOL))
1089 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSproxy");
1090 if (check_col(pinfo->cinfo, COL_INFO))
1091 col_clear(pinfo->cinfo, COL_INFO);
1093 conversation = find_conversation( pinfo->fd->num, &pinfo->src, &pinfo->dst,
1094 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
1096 if ( !conversation) {
1097 conversation = conversation_new( pinfo->fd->num, &pinfo->src, &pinfo->dst,
1098 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
1100 hash_info = conversation_get_proto_data(conversation, proto_msproxy);
1102 hash_info = se_alloc(sizeof(hash_entry_t));
1103 conversation_add_proto_data(conversation, proto_msproxy,
1107 if (check_col(pinfo->cinfo, COL_INFO)){
1109 cmd = tvb_get_ntohs( tvb, 36);
1111 if ( pinfo->srcport == UDP_PORT_MSPROXY)
1112 col_add_fstr( pinfo->cinfo, COL_INFO, "Server message: %s",
1113 get_msproxy_cmd_name( cmd, FROM_SERVER));
1115 col_add_fstr(pinfo->cinfo, COL_INFO, "Client message: %s",
1116 get_msproxy_cmd_name( cmd, FROM_CLIENT));
1120 if (tree) { /* if proto tree, decode data */
1121 ti = proto_tree_add_item( tree, proto_msproxy, tvb, 0, -1,
1124 msproxy_tree = proto_item_add_subtree(ti, ett_msproxy);
1127 if ( pinfo->srcport == UDP_PORT_MSPROXY)
1128 dissect_msproxy_response( tvb, pinfo, msproxy_tree, hash_info);
1130 dissect_msproxy_request( tvb, msproxy_tree, hash_info);
1135 static void msproxy_reinit( void){
1137 /* Do the cleanup work when a new pass through the packet list is */
1138 /* performed. Reset the highest row seen counter */
1146 proto_register_msproxy( void){
1148 /* Prep the msproxy protocol, for now, just register it */
1150 static gint *ett[] = {
1154 static hf_register_info hf[] = {
1157 { "Command", "msproxy.command", FT_UINT16, BASE_DEC,
1158 NULL, 0x0, "", HFILL
1162 { &hf_msproxy_dstaddr,
1163 { "Destination Address", "msproxy.dstaddr", FT_IPv4, BASE_NONE, NULL,
1168 { &hf_msproxy_srcport,
1169 { "Source Port", "msproxy.srcport", FT_UINT16,
1170 BASE_DEC, NULL, 0x0, "", HFILL
1173 { &hf_msproxy_dstport,
1174 { "Destination Port", "msproxy.dstport", FT_UINT16,
1175 BASE_DEC, NULL, 0x0, "", HFILL
1178 { &hf_msproxy_clntport,
1179 { "Client Port", "msproxy.clntport", FT_UINT16,
1180 BASE_DEC, NULL, 0x0, "", HFILL
1183 { &hf_msproxy_server_ext_addr,
1184 { "Server External Address", "msproxy.server_ext_addr", FT_IPv4, BASE_NONE, NULL,
1189 { &hf_msproxy_server_ext_port,
1190 { "Server External Port", "msproxy.server_ext_port", FT_UINT16,
1191 BASE_DEC, NULL, 0x0, "", HFILL
1195 { &hf_msproxy_server_int_addr,
1196 { "Server Internal Address", "msproxy.server_int_addr", FT_IPv4, BASE_NONE, NULL,
1201 { &hf_msproxy_server_int_port,
1202 { "Server Internal Port", "msproxy.server_int_port", FT_UINT16,
1203 BASE_DEC, NULL, 0x0, "", HFILL
1206 { &hf_msproxy_serverport,
1207 { "Server Port", "msproxy.serverport", FT_UINT16,
1208 BASE_DEC, NULL, 0x0, "", HFILL
1211 { &hf_msproxy_bindport,
1212 { "Bind Port", "msproxy.bindport", FT_UINT16,
1213 BASE_DEC, NULL, 0x0, "", HFILL
1216 { &hf_msproxy_boundport,
1217 { "Bound Port", "msproxy.boundport", FT_UINT16,
1218 BASE_DEC, NULL, 0x0, "", HFILL
1221 { &hf_msproxy_serveraddr,
1222 { "Server Address", "msproxy.serveraddr", FT_IPv4, BASE_NONE, NULL,
1226 { &hf_msproxy_bindaddr,
1227 { "Destination", "msproxy.bindaddr", FT_IPv4, BASE_NONE, NULL,
1231 { &hf_msproxy_bind_id,
1232 { "Bound Port Id", "msproxy.bindid", FT_UINT32,
1233 BASE_HEX, NULL, 0x0, "", HFILL
1236 { &hf_msproxy_resolvaddr,
1237 { "Address", "msproxy.resolvaddr", FT_IPv4, BASE_NONE, NULL,
1244 proto_msproxy = proto_register_protocol( "MS Proxy Protocol",
1245 "MS Proxy", "msproxy");
1247 proto_register_field_array(proto_msproxy, hf, array_length(hf));
1248 proto_register_subtree_array(ett, array_length(ett));
1250 register_init_routine( &msproxy_reinit); /* register re-init routine */
1252 msproxy_sub_handle = create_dissector_handle(msproxy_sub_dissector,
1258 proto_reg_handoff_msproxy(void) {
1260 /* dissector install routine */
1262 dissector_handle_t msproxy_handle;
1264 msproxy_handle = create_dissector_handle(dissect_msproxy,
1266 dissector_add("udp.port", UDP_PORT_MSPROXY, msproxy_handle);