xref: /netbsd-src/external/bsd/tcpdump/dist/print-msnlb.c (revision 26ba0b503b498a5194a71ac319838b7f5497f3fe)
1026d7285Schristos /*
2026d7285Schristos  * Copyright (c) 2013 Romain Francoise <romain@orebokech.com>
3026d7285Schristos  *
4026d7285Schristos  * Redistribution and use in source and binary forms, with or without
5026d7285Schristos  * modification, are permitted provided that the following conditions
6026d7285Schristos  * are met:
7026d7285Schristos  * 1. Redistributions of source code must retain the above copyright
8026d7285Schristos  *    notice, this list of conditions and the following disclaimer.
9026d7285Schristos  * 2. Redistributions in binary form must reproduce the above copyright
10026d7285Schristos  *    notice, this list of conditions and the following disclaimer in the
11026d7285Schristos  *    documentation and/or other materials provided with the distribution.
12026d7285Schristos  * 3. Neither the name of the project nor the names of its contributors
13026d7285Schristos  *    may be used to endorse or promote products derived from this software
14026d7285Schristos  *    without specific prior written permission.
15026d7285Schristos  *
16026d7285Schristos  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17026d7285Schristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18026d7285Schristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19026d7285Schristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20026d7285Schristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21026d7285Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22026d7285Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23026d7285Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24026d7285Schristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25026d7285Schristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26026d7285Schristos  * SUCH DAMAGE.
27026d7285Schristos  */
28026d7285Schristos 
29fdccd7e4Schristos #include <sys/cdefs.h>
30fdccd7e4Schristos #ifndef lint
31*26ba0b50Schristos __RCSID("$NetBSD: print-msnlb.c,v 1.6 2024/09/02 16:15:32 christos Exp $");
32fdccd7e4Schristos #endif
33fdccd7e4Schristos 
34dc860a36Sspz /* \summary: MS Network Load Balancing's (NLB) heartbeat printer */
35dc860a36Sspz 
36c74ad251Schristos #include <config.h>
37026d7285Schristos 
38c74ad251Schristos #include "netdissect-stdinc.h"
39026d7285Schristos 
40784088dfSchristos #include "netdissect.h"
41026d7285Schristos #include "addrtoname.h"
42026d7285Schristos #include "extract.h"
43026d7285Schristos 
44026d7285Schristos struct msnlb_heartbeat_pkt {
45c74ad251Schristos 	nd_byte     unknown1[4];
46c74ad251Schristos 	nd_byte     unknown2[4];
47c74ad251Schristos 	nd_uint32_t host_prio;	/* little-endian */
48c74ad251Schristos 	nd_ipv4     virtual_ip;
49c74ad251Schristos 	nd_ipv4     host_ip;
50026d7285Schristos 	/* the protocol is undocumented so we ignore the rest */
51026d7285Schristos };
52026d7285Schristos 
53a8e08e94Skamil UNALIGNED_OK
54026d7285Schristos void
55026d7285Schristos msnlb_print(netdissect_options *ndo, const u_char *bp)
56026d7285Schristos {
57026d7285Schristos 	const struct msnlb_heartbeat_pkt *hb;
58026d7285Schristos 
59c74ad251Schristos 	ndo->ndo_protocol = "msnlb";
60784088dfSchristos 	hb = (const struct msnlb_heartbeat_pkt *)bp;
61026d7285Schristos 
62c74ad251Schristos 	ND_PRINT("MS NLB heartbeat");
63c74ad251Schristos 	ND_PRINT(", host priority: %u", GET_LE_U_4((hb->host_prio)));
64c74ad251Schristos 	ND_PRINT(", cluster IP: %s", GET_IPADDR_STRING(hb->virtual_ip));
65c74ad251Schristos 	ND_PRINT(", host IP: %s", GET_IPADDR_STRING(hb->host_ip));
66026d7285Schristos }
67