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 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MS Proxy");
207 if (check_col(pinfo->cinfo, COL_INFO))
208 col_set_str(pinfo->cinfo, COL_INFO,
209 (( redirect_info->proto == PT_TCP) ? "TCP stream" :
213 ti = proto_tree_add_item( tree, proto_msproxy, tvb, 0, 0,
216 msp_tree = proto_item_add_subtree(ti, ett_msproxy);
218 proto_tree_add_uint( msp_tree, hf_msproxy_dstport, tvb, 0, 0,
219 redirect_info->remote_port);
221 proto_tree_add_ipv4( msp_tree, hf_msproxy_dstaddr, tvb, 0, 0,
222 redirect_info->remote_addr);
226 /* set pinfo->{src/dst port} and call the UDP sub-dissector lookup */
228 if ( pinfo->srcport == redirect_info->clnt_port)
229 ptr = &pinfo->destport;
231 ptr = &pinfo->srcport;
233 *ptr = redirect_info->remote_port;
235 if ( redirect_info->proto == PT_TCP)
236 decode_tcp_ports( tvb, 0, pinfo, tree, pinfo->srcport,
237 pinfo->destport, NULL);
239 decode_udp_ports( tvb, 0, pinfo, tree, pinfo->srcport,
240 pinfo->destport, -1);
242 *ptr = redirect_info->server_int_port;
247 static void add_msproxy_conversation( packet_info *pinfo,
248 hash_entry_t *hash_info){
250 /* check to see if a conversation already exists, if it does assume */
251 /* it's our conversation and quit. Otherwise create a new conversation. */
252 /* Load the conversation dissector to our dissector and load the */
253 /* conversation data structure with the info needed to call the TCP or */
254 /* UDP port decoder. */
256 /* NOTE: Currently this assume that the conversation will be created */
257 /* during a packet from the server. If that changes, pinfo->src */
258 /* and pinfo->dst will not be correct and this routine will have */
261 conversation_t *conversation;
262 redirect_entry_t *new_conv_info;
264 if (pinfo->fd->flags.visited) {
266 * We've already processed this frame once, so we
267 * should already have done this.
272 conversation = find_conversation( pinfo->fd->num, &pinfo->src,
273 &pinfo->dst, hash_info->proto, hash_info->server_int_port,
274 hash_info->clnt_port, 0);
276 if ( !conversation) {
277 conversation = conversation_new( pinfo->fd->num, &pinfo->src, &pinfo->dst,
278 hash_info->proto, hash_info->server_int_port,
279 hash_info->clnt_port, 0);
281 conversation_set_dissector(conversation, msproxy_sub_handle);
283 new_conv_info = se_alloc(sizeof(redirect_entry_t));
285 new_conv_info->remote_addr = hash_info->dst_addr;
286 new_conv_info->clnt_port = hash_info->clnt_port;
287 new_conv_info->remote_port = hash_info->dst_port;
288 new_conv_info->server_int_port = hash_info->server_int_port;
289 new_conv_info->proto = hash_info->proto;
291 conversation_add_proto_data(conversation, proto_msproxy,
297 static int display_application_name(tvbuff_t *tvb, int offset,
300 /* display the application name in the proto tree. */
302 /* NOTE: this routine assumes that the tree pointer is valid (not NULL) */
306 length = tvb_strnlen( tvb, offset, 255);
307 proto_tree_add_text( tree, tvb, offset, length, "Application: %.*s",
308 length, tvb_get_ptr( tvb, offset, length));
314 static const char *get_msproxy_cmd_name( int cmd, int direction) {
316 /* return the command name string for cmd */
319 case MSPROXY_HELLO_2:
320 case MSPROXY_HELLO: return "Hello";
322 /* MSPROXY_HELLO_ACK & MSPROXY_USERINFO have the same value (0x1000). */
323 /* So use the direction flag to determine which to use. */
325 case MSPROXY_USERINFO:
326 if ( direction == FROM_SERVER)
327 return "Hello Acknowledge";
330 case MSPROXY_USERINFO_ACK: return "User Info Acknowledge";
331 case MSPROXY_AUTH: return "Authentication";
332 case MSPROXY_AUTH_1_ACK: return "Authentication Acknowledge";
333 case MSPROXY_AUTH_2: return "Authentication 2";
334 case MSPROXY_AUTH_2_ACK: return "Authentication 2 Acknowledge";
335 case MSPROXY_RESOLVE: return "Resolve";
336 case MSPROXY_RESOLVE_ACK: return "Resolve Acknowledge";
337 case MSPROXY_BIND: return "Bind";
338 case MSPROXY_TCP_BIND: return "TCP Bind";
339 case MSPROXY_TCP_BIND_ACK: return "TCP Bind Acknowledge";
340 case MSPROXY_LISTEN: return "Listen";
341 case MSPROXY_BINDINFO: return "Bind Info";
342 case MSPROXY_BINDINFO_ACK: return "Bind Info Acknowledge";
343 case MSPROXY_CONNECT: return "Connect";
344 case MSPROXY_CONNECT_ACK: return "Connect Acknowledge";
345 case MSPROXY_UDPASSOCIATE: return "UDP Associate";
346 case MSPROXY_UDP_BIND_REQ: return "UDP Bind";
347 case MSPROXY_UDPASSOCIATE_ACK: return "Bind or Associate Acknowledge";
348 case MSPROXY_CONNECTED: return "Connected";
349 case MSPROXY_SESSIONEND: return "Session End";
351 default: return "Unknown";
357 static void dissect_user_info_2(tvbuff_t *tvb, int offset,
360 /* decode the user, application, computer name */
366 length = tvb_strnlen( tvb, offset, 255);
369 proto_tree_add_text( tree, tvb, offset, length + 1,
370 "User name: %.*s", length,
371 tvb_get_ptr( tvb, offset, length));
372 offset += length + 2;
374 length = tvb_strnlen( tvb, offset, 255);
377 proto_tree_add_text( tree, tvb, offset, length + 1,
378 "Application name: %.*s", length,
379 tvb_get_ptr( tvb, offset, length));
380 offset += length + 1;
382 length = tvb_strnlen( tvb, offset, 255);
385 proto_tree_add_text( tree, tvb, offset, length + 1,
386 "Client computer name: %.*s", length,
387 tvb_get_ptr( tvb, offset, length));
393 static void dissect_msproxy_request_1(tvbuff_t *tvb, int offset,
396 /* decode the request _1 structure */
401 dissect_user_info_2( tvb, offset, tree);
407 static void dissect_bind(tvbuff_t *tvb, int offset,
408 proto_tree *tree, hash_entry_t *conv_info) {
410 /* decode the bind request */
415 proto_tree_add_item( tree, hf_msproxy_bindaddr, tvb, offset, 4,
420 proto_tree_add_item( tree, hf_msproxy_bindport, tvb, offset, 2,
425 proto_tree_add_item( tree, hf_msproxy_clntport, tvb, offset, 2,
429 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
433 proto_tree_add_item( tree, hf_msproxy_boundport, tvb, offset, 2,
437 display_application_name( tvb, offset, tree);
443 static void dissect_auth(tvbuff_t *tvb, int offset,
446 /* decode the authorization request */
451 proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
452 tvb_get_ptr( tvb, offset, 7));
459 static void dissect_tcp_bind(tvbuff_t *tvb, int offset,
460 proto_tree *tree, hash_entry_t *conv_info) {
462 /* decode the bind packet. Set the protocol type in the conversation */
463 /* information so the bind_info can use it to create the payload */
467 conv_info->proto = PT_TCP;
472 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
476 proto_tree_add_item( tree, hf_msproxy_boundport, tvb, offset, 2,
480 display_application_name( tvb, offset, tree);
485 static void dissect_request_connect(tvbuff_t *tvb, int offset,
486 proto_tree *tree, hash_entry_t *conv_info) {
488 /* decode the connect request, display */
490 conv_info->proto = PT_TCP;
495 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
498 conv_info->dst_port = tvb_get_ntohs( tvb, offset);
502 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
505 conv_info->dst_addr = tvb_get_ipv4( tvb, offset);
509 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
512 proto_tree_add_uint( tree, hf_msproxy_clntport, tvb, offset, 2,
513 conv_info->clnt_port);
517 display_application_name( tvb, offset, tree);
522 static void dissect_bind_info_ack(tvbuff_t *tvb, int offset, proto_tree *tree) {
524 /* decode the client bind info ack */
530 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
534 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
538 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
542 proto_tree_add_item( tree, hf_msproxy_server_int_port, tvb,
546 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
550 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
554 display_application_name( tvb, offset, tree);
559 static void dissect_request_resolve(tvbuff_t *tvb, int offset,
562 /* dissect the request resolve structure */
563 /* display a string with a length, characters encoding */
564 /* they are displayed under a tree with the name in Label variable */
565 /* return the length of the string and the length byte */
567 proto_tree *name_tree;
570 int length = tvb_get_guint8( tvb, offset);
573 ti = proto_tree_add_text(tree, tvb, offset, length + 1,
574 "Host Name: %.*s", length,
575 tvb_get_ptr( tvb, offset + 18, length));
577 name_tree = proto_item_add_subtree(ti, ett_msproxy_name);
579 proto_tree_add_text( name_tree, tvb, offset, 1, "Length: %d",
585 proto_tree_add_text( name_tree, tvb, offset, length, "String: %s",
586 tvb_get_ptr( tvb, offset, length));
592 static void dissect_udp_bind(tvbuff_t *tvb, int offset,
593 proto_tree *tree, hash_entry_t *conv_info) {
595 /* Dissect the udp bind request. Load the protocol id (PT_UDP) and the */
596 /* remote address so bind_info can use it to create conversation */
599 conv_info->proto = PT_UDP;
605 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
611 proto_tree_add_item( tree, hf_msproxy_dstport, tvb, offset, 2,
616 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
622 display_application_name( tvb, offset, tree);
626 static void dissect_udp_assoc(tvbuff_t *tvb, int offset,
627 proto_tree *tree, hash_entry_t *conv_info) {
629 /* dissect the udp associate request. And load client port into */
630 /* conversation data structure for later. */
636 proto_tree_add_item( tree, hf_msproxy_clntport, tvb, offset, 2,
639 conv_info->clnt_port = tvb_get_ntohs( tvb, offset);
644 display_application_name( tvb, offset, tree);
648 static void dissect_msproxy_request(tvbuff_t *tvb,
649 proto_tree *tree, hash_entry_t *conv_info) {
655 proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
656 tvb_get_letohl( tvb, offset));
659 proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
660 tvb_get_letohl( tvb, offset));
663 proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%0x",
664 tvb_get_letohl( tvb, offset));
667 proto_tree_add_text( tree, tvb, offset, 1, "Server ack: %u",
668 tvb_get_guint8( tvb, offset));
671 proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: %u",
672 tvb_get_guint8( tvb, offset));
675 proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
676 tvb_get_ptr( tvb, offset, 4));
682 cmd = tvb_get_ntohs( tvb, offset);
685 proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
686 cmd, "Command: 0x%02x (%s)", cmd,
687 get_msproxy_cmd_name( cmd, FROM_CLIENT));
693 dissect_auth( tvb, offset, tree);
697 dissect_bind( tvb, offset, tree, conv_info);
700 case MSPROXY_UDP_BIND_REQ:
701 dissect_udp_bind( tvb, offset, tree, conv_info);
704 case MSPROXY_AUTH_2: /*$$ this is probably wrong place for this */
705 case MSPROXY_TCP_BIND:
706 dissect_tcp_bind( tvb, offset, tree, conv_info);
709 case MSPROXY_RESOLVE:
710 dissect_request_resolve( tvb, offset, tree);
713 case MSPROXY_CONNECT:
715 dissect_request_connect( tvb, offset, tree,
719 case MSPROXY_BINDINFO_ACK:
720 dissect_bind_info_ack( tvb, offset, tree);
724 case MSPROXY_HELLO_2:
725 dissect_msproxy_request_1( tvb, offset, tree);
728 case MSPROXY_UDPASSOCIATE:
729 dissect_udp_assoc( tvb, offset, tree, conv_info);
733 proto_tree_add_text( tree, tvb, offset, 0,
734 "Unhandled request command (report this, please)");
740 static void dissect_hello_ack(tvbuff_t *tvb, int offset, proto_tree *tree) {
742 /* decode the hello acknowledge packet */
747 proto_tree_add_item( tree, hf_msproxy_serverport, tvb, offset, 2,
751 proto_tree_add_item( tree, hf_msproxy_serveraddr, tvb, offset, 4,
759 /* XXX - implement me */
760 static void dissect_user_info_ack(tvbuff_t *tvb _U_, int offset,
761 proto_tree *tree _U_) {
763 /* decode the response _2 structure */
773 static void dissect_udpassociate_ack(tvbuff_t *tvb, int offset,
779 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
783 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
787 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
791 display_application_name( tvb, offset, tree);
797 static void dissect_auth_1_ack(tvbuff_t *tvb, int offset,
802 proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
803 tvb_get_ptr( tvb, offset, 7));
806 /* XXX - always 255? */
807 proto_tree_add_text( tree, tvb, offset, 255, "NT domain: %.255s",
808 tvb_get_ptr( tvb, offset, 255));
814 /* XXX - implement me */
815 static void dissect_msproxy_response_4( tvbuff_t *tvb _U_, int offset,
816 proto_tree *tree _U_) {
818 /* decode the response _4 structure */
825 static void dissect_connect_ack( tvbuff_t *tvb, int offset, packet_info *pinfo,
826 proto_tree *tree, hash_entry_t *conv_info) {
828 /* decode the connect ack packet */
832 proto_tree_add_item( tree, hf_msproxy_server_int_port, tvb,
836 conv_info->proto = PT_TCP;
837 conv_info->server_int_port = tvb_get_ntohs( tvb, offset);
841 proto_tree_add_item( tree, hf_msproxy_server_int_addr, tvb,
845 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
849 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
853 display_application_name( tvb, offset, tree);
856 add_msproxy_conversation( pinfo, conv_info);
861 static void dissect_tcp_bind_ack( tvbuff_t *tvb, int offset, proto_tree *tree) {
863 /* decode the tcp bind */
868 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
872 proto_tree_add_uint( tree, hf_msproxy_server_int_port, tvb,
876 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
880 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
885 display_application_name( tvb, offset, tree);
891 static void dissect_bind_info( tvbuff_t *tvb, int offset, packet_info *pinfo,
892 proto_tree *tree, hash_entry_t *conv_info) {
894 /* decode the Bind info response from server */
899 proto_tree_add_item( tree, hf_msproxy_bind_id, tvb, offset, 4,
904 conv_info->dst_port = tvb_get_ntohs( tvb, offset);
906 proto_tree_add_uint( tree, hf_msproxy_dstport, tvb, offset, 2,
907 conv_info->dst_port);
910 conv_info->dst_addr = tvb_get_ipv4( tvb, offset);
912 proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4,
916 conv_info->server_int_port = tvb_get_ntohs( tvb, offset);
918 proto_tree_add_uint( tree, hf_msproxy_server_int_port, tvb,
919 offset, 2, conv_info->server_int_port);
923 proto_tree_add_item( tree, hf_msproxy_server_ext_port, tvb,
927 proto_tree_add_item( tree, hf_msproxy_server_ext_addr, tvb,
931 display_application_name( tvb, offset, tree);
935 add_msproxy_conversation( pinfo, conv_info);
940 static void dissect_resolve(tvbuff_t *tvb, int offset, proto_tree *tree) {
942 /* dissect the response resolve structure */
943 /* display a string with a length, characters encoding */
944 /* they are displayed under a tree with the name in Label variable */
945 /* return the length of the string and the length byte */
950 addr_offset = tvb_get_guint8( tvb, offset);
952 proto_tree_add_text( tree, tvb, offset, 1, "Address offset: %d",
959 offset += addr_offset;
961 proto_tree_add_item( tree, hf_msproxy_resolvaddr, tvb, offset, 4,
968 static void dissect_msproxy_response(tvbuff_t *tvb, packet_info *pinfo,
969 proto_tree *tree, hash_entry_t *conv_info) {
975 proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
976 tvb_get_letohl( tvb, offset));
979 proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
980 tvb_get_letohl( tvb, offset));
983 proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%04x",
984 tvb_get_letohl( tvb, offset));
987 proto_tree_add_text( tree, tvb, offset, 1, "Client ack: 0x%02x",
988 tvb_get_guint8( tvb, offset));
991 proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: 0x%02x",
992 tvb_get_guint8( tvb, offset));
996 proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
997 tvb_get_ptr( tvb, offset, 4));
1004 cmd = tvb_get_ntohs( tvb, offset);
1007 proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
1008 cmd, "Command: 0x%02x (%s)", cmd,
1009 get_msproxy_cmd_name( cmd, FROM_SERVER));
1013 case MSPROXY_HELLO_ACK:
1014 dissect_hello_ack( tvb, offset, tree);
1017 case MSPROXY_USERINFO_ACK:
1018 dissect_user_info_ack( tvb, offset, tree);
1021 case MSPROXY_AUTH_1_ACK:
1022 dissect_auth_1_ack( tvb, offset, tree);
1025 /* this also handle the MSPROXY_BIND_ACK ??? check this */
1027 case MSPROXY_UDPASSOCIATE_ACK:
1028 dissect_udpassociate_ack( tvb, offset, tree);
1031 case MSPROXY_AUTH_2_ACK:
1032 case MSPROXY_AUTH_2_ACK2:
1033 dissect_msproxy_response_4( tvb, offset, tree);
1036 case MSPROXY_TCP_BIND_ACK:
1037 dissect_tcp_bind_ack( tvb, offset, tree);
1040 case MSPROXY_CONNECT_ACK:
1041 dissect_connect_ack( tvb, offset, pinfo, tree,
1045 case MSPROXY_BINDINFO:
1046 dissect_bind_info( tvb, offset, pinfo, tree, conv_info);
1049 case MSPROXY_RESOLVE_ACK:
1050 dissect_resolve( tvb, offset, tree);
1053 case MSPROXY_CONNECT_AUTHFAILED:
1054 case MSPROXY_BIND_AUTHFAILED:
1055 proto_tree_add_text( tree, tvb, offset, 0, "No know information (help wanted)");
1061 (((cmd >> 8) == MSPROXY_CONNREFUSED) ||
1062 ((cmd >> 12) == MSPROXY_CONNREFUSED)))
1063 proto_tree_add_text( tree, tvb, offset, 0,
1064 "No know information (help wanted)");
1067 proto_tree_add_text( tree, tvb, offset, 0,
1068 "Unhandled response command (report this, please)");
1076 static void dissect_msproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1079 proto_tree *msproxy_tree = NULL;
1084 hash_entry_t *hash_info;
1085 conversation_t *conversation;
1087 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSproxy");
1088 col_clear(pinfo->cinfo, COL_INFO);
1090 conversation = find_conversation( pinfo->fd->num, &pinfo->src, &pinfo->dst,
1091 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
1093 if ( !conversation) {
1094 conversation = conversation_new( pinfo->fd->num, &pinfo->src, &pinfo->dst,
1095 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
1097 hash_info = conversation_get_proto_data(conversation, proto_msproxy);
1099 hash_info = se_alloc(sizeof(hash_entry_t));
1100 conversation_add_proto_data(conversation, proto_msproxy,
1104 if (check_col(pinfo->cinfo, COL_INFO)){
1106 cmd = tvb_get_ntohs( tvb, 36);
1108 if ( pinfo->srcport == UDP_PORT_MSPROXY)
1109 col_add_fstr( pinfo->cinfo, COL_INFO, "Server message: %s",
1110 get_msproxy_cmd_name( cmd, FROM_SERVER));
1112 col_add_fstr(pinfo->cinfo, COL_INFO, "Client message: %s",
1113 get_msproxy_cmd_name( cmd, FROM_CLIENT));
1117 if (tree) { /* if proto tree, decode data */
1118 ti = proto_tree_add_item( tree, proto_msproxy, tvb, 0, -1,
1121 msproxy_tree = proto_item_add_subtree(ti, ett_msproxy);
1124 if ( pinfo->srcport == UDP_PORT_MSPROXY)
1125 dissect_msproxy_response( tvb, pinfo, msproxy_tree, hash_info);
1127 dissect_msproxy_request( tvb, msproxy_tree, hash_info);
1132 static void msproxy_reinit( void){
1134 /* Do the cleanup work when a new pass through the packet list is */
1135 /* performed. Reset the highest row seen counter */
1143 proto_register_msproxy( void){
1145 /* Prep the msproxy protocol, for now, just register it */
1147 static gint *ett[] = {
1151 static hf_register_info hf[] = {
1154 { "Command", "msproxy.command", FT_UINT16, BASE_DEC,
1155 NULL, 0x0, NULL, HFILL
1159 { &hf_msproxy_dstaddr,
1160 { "Destination Address", "msproxy.dstaddr", FT_IPv4, BASE_NONE, NULL,
1165 { &hf_msproxy_srcport,
1166 { "Source Port", "msproxy.srcport", FT_UINT16,
1167 BASE_DEC, NULL, 0x0, NULL, HFILL
1170 { &hf_msproxy_dstport,
1171 { "Destination Port", "msproxy.dstport", FT_UINT16,
1172 BASE_DEC, NULL, 0x0, NULL, HFILL
1175 { &hf_msproxy_clntport,
1176 { "Client Port", "msproxy.clntport", FT_UINT16,
1177 BASE_DEC, NULL, 0x0, NULL, HFILL
1180 { &hf_msproxy_server_ext_addr,
1181 { "Server External Address", "msproxy.server_ext_addr", FT_IPv4, BASE_NONE, NULL,
1186 { &hf_msproxy_server_ext_port,
1187 { "Server External Port", "msproxy.server_ext_port", FT_UINT16,
1188 BASE_DEC, NULL, 0x0, NULL, HFILL
1192 { &hf_msproxy_server_int_addr,
1193 { "Server Internal Address", "msproxy.server_int_addr", FT_IPv4, BASE_NONE, NULL,
1198 { &hf_msproxy_server_int_port,
1199 { "Server Internal Port", "msproxy.server_int_port", FT_UINT16,
1200 BASE_DEC, NULL, 0x0, NULL, HFILL
1203 { &hf_msproxy_serverport,
1204 { "Server Port", "msproxy.serverport", FT_UINT16,
1205 BASE_DEC, NULL, 0x0, NULL, HFILL
1208 { &hf_msproxy_bindport,
1209 { "Bind Port", "msproxy.bindport", FT_UINT16,
1210 BASE_DEC, NULL, 0x0, NULL, HFILL
1213 { &hf_msproxy_boundport,
1214 { "Bound Port", "msproxy.boundport", FT_UINT16,
1215 BASE_DEC, NULL, 0x0, NULL, HFILL
1218 { &hf_msproxy_serveraddr,
1219 { "Server Address", "msproxy.serveraddr", FT_IPv4, BASE_NONE, NULL,
1223 { &hf_msproxy_bindaddr,
1224 { "Destination", "msproxy.bindaddr", FT_IPv4, BASE_NONE, NULL,
1228 { &hf_msproxy_bind_id,
1229 { "Bound Port Id", "msproxy.bindid", FT_UINT32,
1230 BASE_HEX, NULL, 0x0, NULL, HFILL
1233 { &hf_msproxy_resolvaddr,
1234 { "Address", "msproxy.resolvaddr", FT_IPv4, BASE_NONE, NULL,
1241 proto_msproxy = proto_register_protocol( "MS Proxy Protocol",
1242 "MS Proxy", "msproxy");
1244 proto_register_field_array(proto_msproxy, hf, array_length(hf));
1245 proto_register_subtree_array(ett, array_length(ett));
1247 register_init_routine( &msproxy_reinit); /* register re-init routine */
1249 msproxy_sub_handle = create_dissector_handle(msproxy_sub_dissector,
1255 proto_reg_handoff_msproxy(void) {
1257 /* dissector install routine */
1259 dissector_handle_t msproxy_handle;
1261 msproxy_handle = create_dissector_handle(dissect_msproxy,
1263 dissector_add("udp.port", UDP_PORT_MSPROXY, msproxy_handle);