xref: /freebsd/contrib/tcpdump/print-msnlb.c (revision 3c602fabf9b894ff79f08a80cbb7ad3b1eb84e62)
1d03c0883SXin LI /*
2d03c0883SXin LI  * Copyright (c) 2013 Romain Francoise <romain@orebokech.com>
3d03c0883SXin LI  *
4d03c0883SXin LI  * Redistribution and use in source and binary forms, with or without
5d03c0883SXin LI  * modification, are permitted provided that the following conditions
6d03c0883SXin LI  * are met:
7d03c0883SXin LI  * 1. Redistributions of source code must retain the above copyright
8d03c0883SXin LI  *    notice, this list of conditions and the following disclaimer.
9d03c0883SXin LI  * 2. Redistributions in binary form must reproduce the above copyright
10d03c0883SXin LI  *    notice, this list of conditions and the following disclaimer in the
11d03c0883SXin LI  *    documentation and/or other materials provided with the distribution.
12d03c0883SXin LI  * 3. Neither the name of the project nor the names of its contributors
13d03c0883SXin LI  *    may be used to endorse or promote products derived from this software
14d03c0883SXin LI  *    without specific prior written permission.
15d03c0883SXin LI  *
16d03c0883SXin LI  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17d03c0883SXin LI  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18d03c0883SXin LI  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19d03c0883SXin LI  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20d03c0883SXin LI  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21d03c0883SXin LI  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22d03c0883SXin LI  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23d03c0883SXin LI  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24d03c0883SXin LI  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25d03c0883SXin LI  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26d03c0883SXin LI  * SUCH DAMAGE.
27d03c0883SXin LI  */
28d03c0883SXin LI 
29*3c602fabSXin LI #define NETDISSECT_REWORKED
30d03c0883SXin LI #ifdef HAVE_CONFIG_H
31d03c0883SXin LI #include "config.h"
32d03c0883SXin LI #endif
33d03c0883SXin LI 
34d03c0883SXin LI #include <tcpdump-stdinc.h>
35d03c0883SXin LI 
36*3c602fabSXin LI #include "interface.h"
37d03c0883SXin LI #include "addrtoname.h"
38d03c0883SXin LI #include "extract.h"
39d03c0883SXin LI 
40d03c0883SXin LI struct msnlb_heartbeat_pkt {
41*3c602fabSXin LI 	uint32_t unknown1;
42*3c602fabSXin LI 	uint32_t unknown2;
43*3c602fabSXin LI 	uint32_t host_prio;	/* little-endian */
44*3c602fabSXin LI 	uint32_t virtual_ip;
45*3c602fabSXin LI 	uint32_t host_ip;
46d03c0883SXin LI 	/* the protocol is undocumented so we ignore the rest */
47d03c0883SXin LI };
48d03c0883SXin LI 
49d03c0883SXin LI void
50*3c602fabSXin LI msnlb_print(netdissect_options *ndo, const u_char *bp)
51d03c0883SXin LI {
52d03c0883SXin LI 	const struct msnlb_heartbeat_pkt *hb;
53d03c0883SXin LI 
54d03c0883SXin LI 	hb = (struct msnlb_heartbeat_pkt *)bp;
55d03c0883SXin LI 	ND_TCHECK(*hb);
56d03c0883SXin LI 
57d03c0883SXin LI 	ND_PRINT((ndo, "MS NLB heartbeat, host priority: %u,",
58d03c0883SXin LI 		EXTRACT_LE_32BITS(&(hb->host_prio))));
59*3c602fabSXin LI 	ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(ndo, &(hb->virtual_ip))));
60*3c602fabSXin LI 	ND_PRINT((ndo, " host IP: %s", ipaddr_string(ndo, &(hb->host_ip))));
61d03c0883SXin LI 	return;
62d03c0883SXin LI trunc:
63d03c0883SXin LI 	ND_PRINT((ndo, "[|MS NLB]"));
64d03c0883SXin LI }
65