Protocols sending the OS's AF_INET6 value are OS-specific or broken.

Check for all the different AF_INET6 values that are on various OSes.
If Totem is, and will forever be, used *ONLY* on one particular OS, feel
free to remove the uses of other _AF_INET6 values (but do *not* change
back to using the OS's AF_INET6; this should dissect the protocol
correctly on *all* OSes).

Add a common AF_INET definition to epan/aftypes.h while we're at it, and
use that; as most OSes picked up 4.2BSD's AF_INET value, most if not all
of them use 2, but IPv6 came out after 4.2BSD, and various OSes all
picked their own values for AF_INET6.

Change-Id: Iae15dfdd15203ed3ecd078a6499821dc09139a98
Reviewed-on: https://code.wireshark.org/review/2458
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-06-19 14:22:54 -07:00
parent 9e81d5820a
commit b936dbd7ee
2 changed files with 32 additions and 16 deletions

View File

@ -32,6 +32,9 @@
extern "C" {
#endif /* __cplusplus */
/* Pretty much everybody uses the same value for AF_INET. */
#define COMMON_AF_INET 2
/* BSD AF_ values. */
#define BSD_AF_INET 2
#define BSD_AF_ISO 7

View File

@ -27,22 +27,25 @@
Y.AMIR, L.E.MOSER, P.M.MELLIAR-SMITH, D.A.AGARWAL, P.CIARFELLA.
"The Totem Single-Ring Ordering and Membership Protocol"*/
/*
* NOTE: the source code at www.corosync.org looks as if it will not
* work with multiple OSes in a cluster if it uses IPv6, as it appears
* to use the OS's AF_ values in packets, and the value of AF_INET6
* is ***NOT*** the same in all OSes.
*
* (It'll work with IPv4, because AF_INET came out of 4.2BSD and
* most if not all OSes just picked up BSD's value of 2.)
*
* So we just check for all the AF_INET6 values we know about.
*
* We get the AF_ values from epan/aftypes.h, *not* from the OS
* we happen to be built for.
*/
# include "config.h"
#include <epan/packet.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#include <epan/aftypes.h>
/*
* Utilities for subdissectors of corosync_totemsrp.
@ -179,8 +182,13 @@ static const value_string corosync_totemsrp_message_header_encapsulated[] = {
static const value_string corosync_totemsrp_ip_address_family[] = {
{ AF_INET, "AF_INET" },
{ AF_INET6, "AF_INET6" },
{ COMMON_AF_INET, "AF_INET" },
{ BSD_AF_INET6_BSD, "AF_INET6 (most BSD)" },
{ BSD_AF_INET6_FREEBSD, "AF_INET6 (FreeBSD)" },
{ BSD_AF_INET6_DARWIN, "AF_INET6 (OS X and iOS)" },
{ LINUX_AF_INET6, "AF_INET6 (Linux)" },
{ SOLARIS_AF_INET6, "AF_INET6 (Solaris)" },
{ WINSOCK_AF_INET6, "AF_INET6 (Windows)" },
{ 0, NULL }
};
@ -260,11 +268,16 @@ dissect_corosync_totemsrp_ip_address(tvbuff_t *tvb,
switch (family)
{
case AF_INET:
case COMMON_AF_INET:
len = 4;
proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr4, tvb, offset, len, ENC_BIG_ENDIAN);
break;
case AF_INET6:
case BSD_AF_INET6_BSD:
case BSD_AF_INET6_FREEBSD:
case BSD_AF_INET6_DARWIN:
case LINUX_AF_INET6:
case SOLARIS_AF_INET6:
case WINSOCK_AF_INET6:
len = sizeof(struct e_in6_addr);
proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr6, tvb, offset, len, ENC_NA);
break;