xref: /dflybsd-src/contrib/tcpdump/print-msnlb.c (revision 59c07fbdf8168fa08c76c515186d561b5a92690c)
1411677aeSAaron LI /*
2411677aeSAaron LI  * Copyright (c) 2013 Romain Francoise <romain@orebokech.com>
3411677aeSAaron LI  *
4411677aeSAaron LI  * Redistribution and use in source and binary forms, with or without
5411677aeSAaron LI  * modification, are permitted provided that the following conditions
6411677aeSAaron LI  * are met:
7411677aeSAaron LI  * 1. Redistributions of source code must retain the above copyright
8411677aeSAaron LI  *    notice, this list of conditions and the following disclaimer.
9411677aeSAaron LI  * 2. Redistributions in binary form must reproduce the above copyright
10411677aeSAaron LI  *    notice, this list of conditions and the following disclaimer in the
11411677aeSAaron LI  *    documentation and/or other materials provided with the distribution.
12411677aeSAaron LI  * 3. Neither the name of the project nor the names of its contributors
13411677aeSAaron LI  *    may be used to endorse or promote products derived from this software
14411677aeSAaron LI  *    without specific prior written permission.
15411677aeSAaron LI  *
16411677aeSAaron LI  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17411677aeSAaron LI  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18411677aeSAaron LI  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19411677aeSAaron LI  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20411677aeSAaron LI  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21411677aeSAaron LI  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22411677aeSAaron LI  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23411677aeSAaron LI  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24411677aeSAaron LI  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25411677aeSAaron LI  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26411677aeSAaron LI  * SUCH DAMAGE.
27411677aeSAaron LI  */
28411677aeSAaron LI 
29411677aeSAaron LI /* \summary: MS Network Load Balancing's (NLB) heartbeat printer */
30411677aeSAaron LI 
31411677aeSAaron LI #ifdef HAVE_CONFIG_H
32*ed775ee7SAntonio Huete Jimenez #include <config.h>
33411677aeSAaron LI #endif
34411677aeSAaron LI 
35*ed775ee7SAntonio Huete Jimenez #include "netdissect-stdinc.h"
36411677aeSAaron LI 
37411677aeSAaron LI #include "netdissect.h"
38411677aeSAaron LI #include "addrtoname.h"
39411677aeSAaron LI #include "extract.h"
40411677aeSAaron LI 
41411677aeSAaron LI struct msnlb_heartbeat_pkt {
42*ed775ee7SAntonio Huete Jimenez 	nd_byte     unknown1[4];
43*ed775ee7SAntonio Huete Jimenez 	nd_byte     unknown2[4];
44*ed775ee7SAntonio Huete Jimenez 	nd_uint32_t host_prio;	/* little-endian */
45*ed775ee7SAntonio Huete Jimenez 	nd_ipv4     virtual_ip;
46*ed775ee7SAntonio Huete Jimenez 	nd_ipv4     host_ip;
47411677aeSAaron LI 	/* the protocol is undocumented so we ignore the rest */
48411677aeSAaron LI };
49411677aeSAaron LI 
50411677aeSAaron LI void
msnlb_print(netdissect_options * ndo,const u_char * bp)51411677aeSAaron LI msnlb_print(netdissect_options *ndo, const u_char *bp)
52411677aeSAaron LI {
53411677aeSAaron LI 	const struct msnlb_heartbeat_pkt *hb;
54411677aeSAaron LI 
55*ed775ee7SAntonio Huete Jimenez 	ndo->ndo_protocol = "msnlb";
56411677aeSAaron LI 	hb = (const struct msnlb_heartbeat_pkt *)bp;
57411677aeSAaron LI 
58*ed775ee7SAntonio Huete Jimenez 	ND_PRINT("MS NLB heartbeat");
59*ed775ee7SAntonio Huete Jimenez 	ND_PRINT(", host priority: %u", GET_LE_U_4((hb->host_prio)));
60*ed775ee7SAntonio Huete Jimenez 	ND_PRINT(", cluster IP: %s", GET_IPADDR_STRING(hb->virtual_ip));
61*ed775ee7SAntonio Huete Jimenez 	ND_PRINT(", host IP: %s", GET_IPADDR_STRING(hb->host_ip));
62411677aeSAaron LI }
63