diff options
author | Guy Harris <guy@alum.mit.edu> | 2008-08-08 19:27:58 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2008-08-08 19:27:58 +0000 |
commit | 3cba46070ca162b8095160e87c9bdfb9ba4bc5c6 (patch) | |
tree | e884f5e4551bded93e3675c7a31992792f536a33 | |
parent | 652343e2d1501be5fc596c036817d9b5ddfe4892 (diff) |
Add Winsock AF_ values to epan/aftypes.h; the DirectPlay and ActiveSync
Desktop Pass-Through protocols use them.
Use those values in the dissectors for those protocols.
In the Desktop Pass-Through dissector, define the Winsock SOCK_ values
ourselves, and get the IP protocol values from <epan/ipproto.h>. Don't
include now-unnecessary system headers in that dissector.
svn path=/trunk/; revision=25959
-rw-r--r-- | epan/aftypes.h | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-dplay.c | 20 | ||||
-rw-r--r-- | epan/dissectors/packet-dtpt.c | 51 |
3 files changed, 37 insertions, 42 deletions
diff --git a/epan/aftypes.h b/epan/aftypes.h index 607355800d..ba99a45631 100644 --- a/epan/aftypes.h +++ b/epan/aftypes.h @@ -1,5 +1,6 @@ /* aftypes.h - * AF_ values on various flavors of BSD + * AF_ values on various OSes; they're used in some network protocols, as + * well as in BSD DLT_NULL headers. * * $Id$ * @@ -40,6 +41,11 @@ extern "C" { #define BSD_AF_INET6_FREEBSD 28 #define BSD_AF_INET6_DARWIN 30 +/* Winsock AF_ values. */ +#define WINSOCK_AF_INET 2 +#define WINSOCK_AF_IPX 6 +#define WINSOCK_AF_INET6 23 + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/epan/dissectors/packet-dplay.c b/epan/dissectors/packet-dplay.c index d3f63da740..9b5b6daf27 100644 --- a/epan/dissectors/packet-dplay.c +++ b/epan/dissectors/packet-dplay.c @@ -32,6 +32,7 @@ #include <epan/packet.h> #include <epan/prefs.h> #include <epan/emem.h> +#include <epan/aftypes.h> #include <string.h> /* function declarations */ @@ -43,21 +44,10 @@ static gint dissect_type1a_message(proto_tree *tree, tvbuff_t *tvb, gint offset) static int proto_dplay = -1; static dissector_handle_t dplay_handle; -/* - * Address family definitions used in the protocol; we don't use the AF_ - * values for the OS for which we're building, as there's no guarantee - * that the definitions for that OS match the ones used in the protocol. - * - * XXX - check that these match what's used in the protocol; what's - * used in the protocol is probably what's defined in Winsock. - */ -#define DPLAY_AF_INET 2 -#define DPLAY_AF_IPX 6 /* XXX - sys/socket.h: AF_IPX is 4 ? */ - /* Common data fields */ static int hf_dplay_size = -1; /* Size of the whole data */ static int hf_dplay_token = -1; -static int hf_dplay_saddr_af = -1; /* DPLAY_AF_INET, as this dissector does not handle IPX yet */ +static int hf_dplay_saddr_af = -1; /* WINSOCK_AF_INET, as this dissector does not handle IPX yet */ static int hf_dplay_saddr_port = -1; /* port to use for the reply to this packet */ static int hf_dplay_saddr_ip = -1; /* IP to use for the reply to this packet, or 0.0.0.0, then use the same IP as this packet used. */ @@ -366,8 +356,8 @@ static const value_string dplay_command_val[] = { }; static const value_string dplay_af_val[] = { - { DPLAY_AF_INET, "AF_INET" }, - { DPLAY_AF_IPX, "AF_IPX" }, + { WINSOCK_AF_INET, "AF_INET" }, + { WINSOCK_AF_IPX, "AF_IPX" }, { 0 , NULL}, }; @@ -1209,7 +1199,7 @@ static gboolean heur_dissect_dplay(tvbuff_t *tvb, packet_info *pinfo, proto_tree token = (token & 0xfff00000) >> 20; if (token == 0xfab || token == 0xbab || token == 0xcab) { /* Check the s_addr_in structure */ - if (tvb_get_letohs(tvb, 4) == DPLAY_AF_INET) { + if (tvb_get_letohs(tvb, 4) == WINSOCK_AF_INET) { int offset; for (offset = 12; offset <= 20; offset++) if (tvb_get_guint8(tvb, offset) != 0) diff --git a/epan/dissectors/packet-dtpt.c b/epan/dissectors/packet-dtpt.c index f808ffa6ec..cfef3cb89a 100644 --- a/epan/dissectors/packet-dtpt.c +++ b/epan/dissectors/packet-dtpt.c @@ -1,8 +1,9 @@ /* packet-dtpt.c - * Routines for DTPT packet dissection + * Routines for Microsoft ActiveSync Desktop Pass-Through (DTPT) packet + * dissection * * Uwe Girlich <uwe@planetquake.com> - * http://www.synce.org/index.php/DTPT + * http://www.synce.org/moin/ProtocolDocumentation/DesktopPassThrough * * $Id$ * @@ -33,25 +34,12 @@ #include <string.h> -#include <sys/types.h> -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -# include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif - -#ifdef HAVE_WINSOCK2_H -#include <winsock2.h> /* needed to define AF_ values on Windows */ -#endif - #include <glib.h> #include <epan/packet.h> #include <epan/conversation.h> #include <epan/prefs.h> +#include <epan/aftypes.h> +#include <epan/ipproto.h> static int proto_dtpt = -1; @@ -184,21 +172,32 @@ static const value_string names_error[] = { }; static const value_string names_family[] = { - { AF_INET, "AF_INET" }, + { WINSOCK_AF_INET, "AF_INET" }, { 0, NULL } }; +/* + * Winsock's SOCK_ values. These are probably the same as they are on + * other OSes, as they probably all come from 4.2BSD, but it's still + * best to define them ourselves (to avoid problems if other OSes + * define them differently, and to avoid having to include system + * header files that might require a bunch of other includes). + */ +#define WINSOCK_SOCK_STREAM 1 +#define WINSOCK_SOCK_DGRAM 2 +#define WINSOCK_SOCK_RAW 3 + static const value_string names_socket_type[] = { - { SOCK_STREAM, "SOCK_STREAM" }, - { SOCK_DGRAM, "SOCK_DGRAM" }, - { SOCK_RAW, "SOCK_RAW" }, + { WINSOCK_SOCK_STREAM, "SOCK_STREAM" }, + { WINSOCK_SOCK_DGRAM, "SOCK_DGRAM" }, + { WINSOCK_SOCK_RAW, "SOCK_RAW" }, { 0, NULL } }; static const value_string names_protocol[] = { - { IPPROTO_IP, "IPPROTO_IP" }, - { IPPROTO_TCP, "IPPROTO_TCP" }, - { IPPROTO_UDP, "IPPROTP_UDP" }, + { IP_PROTO_IP, "IPPROTO_IP" }, + { IP_PROTO_TCP, "IPPROTO_TCP" }, + { IP_PROTO_UDP, "IPPROTP_UDP" }, { 0, NULL } }; @@ -359,7 +358,7 @@ dissect_dtpt_sockaddr(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_family, tvb, offset, 2, family); switch (family) { - case AF_INET: { + case WINSOCK_AF_INET: { guint16 port; guint32 addr; @@ -383,7 +382,7 @@ dissect_dtpt_sockaddr(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_family, tvb, offset+0, 4, family); switch (family) { - case AF_INET: { + case WINSOCK_AF_INET: { guint16 port; guint32 addr; |