12949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/*
253f17a9db278d33517d9888dd77848f554522a38JP Abgrall * Copyright (c) 2013 Romain Francoise <romain@orebokech.com>
32949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *
42949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Redistribution and use in source and binary forms, with or without
52949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * modification, are permitted provided that the following conditions
62949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * are met:
72949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 1. Redistributions of source code must retain the above copyright
82949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
92949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright
102949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    notice, this list of conditions and the following disclaimer in the
112949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    documentation and/or other materials provided with the distribution.
122949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 3. Neither the name of the project nor the names of its contributors
132949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    may be used to endorse or promote products derived from this software
142949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    without specific prior written permission.
152949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *
162949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
172949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
182949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
192949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
202949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
212949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
222949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
232949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
252949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
262949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * SUCH DAMAGE.
272949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */
282949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
29892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes#define NETDISSECT_REWORKED
3053f17a9db278d33517d9888dd77848f554522a38JP Abgrall#ifdef HAVE_CONFIG_H
3153f17a9db278d33517d9888dd77848f554522a38JP Abgrall#include "config.h"
322949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif
332949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
3453f17a9db278d33517d9888dd77848f554522a38JP Abgrall#include <tcpdump-stdinc.h>
3553f17a9db278d33517d9888dd77848f554522a38JP Abgrall
36892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes#include "interface.h"
3753f17a9db278d33517d9888dd77848f554522a38JP Abgrall#include "addrtoname.h"
3853f17a9db278d33517d9888dd77848f554522a38JP Abgrall#include "extract.h"
3953f17a9db278d33517d9888dd77848f554522a38JP Abgrall
4053f17a9db278d33517d9888dd77848f554522a38JP Abgrallstruct msnlb_heartbeat_pkt {
41892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	uint32_t unknown1;
42892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	uint32_t unknown2;
43892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	uint32_t host_prio;	/* little-endian */
44892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	uint32_t virtual_ip;
45892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	uint32_t host_ip;
4653f17a9db278d33517d9888dd77848f554522a38JP Abgrall	/* the protocol is undocumented so we ignore the rest */
472949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project};
482949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
4953f17a9db278d33517d9888dd77848f554522a38JP Abgrallvoid
5053f17a9db278d33517d9888dd77848f554522a38JP Abgrallmsnlb_print(netdissect_options *ndo, const u_char *bp)
5153f17a9db278d33517d9888dd77848f554522a38JP Abgrall{
5253f17a9db278d33517d9888dd77848f554522a38JP Abgrall	const struct msnlb_heartbeat_pkt *hb;
5353f17a9db278d33517d9888dd77848f554522a38JP Abgrall
5453f17a9db278d33517d9888dd77848f554522a38JP Abgrall	hb = (struct msnlb_heartbeat_pkt *)bp;
5553f17a9db278d33517d9888dd77848f554522a38JP Abgrall	ND_TCHECK(*hb);
5653f17a9db278d33517d9888dd77848f554522a38JP Abgrall
5753f17a9db278d33517d9888dd77848f554522a38JP Abgrall	ND_PRINT((ndo, "MS NLB heartbeat, host priority: %u,",
5853f17a9db278d33517d9888dd77848f554522a38JP Abgrall		EXTRACT_LE_32BITS(&(hb->host_prio))));
59892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(ndo, &(hb->virtual_ip))));
60892a68bdf2f50b40781212e4d7ee7369c8165953Elliott Hughes	ND_PRINT((ndo, " host IP: %s", ipaddr_string(ndo, &(hb->host_ip))));
6153f17a9db278d33517d9888dd77848f554522a38JP Abgrall	return;
6253f17a9db278d33517d9888dd77848f554522a38JP Abgralltrunc:
6353f17a9db278d33517d9888dd77848f554522a38JP Abgrall	ND_PRINT((ndo, "[|MS NLB]"));
6453f17a9db278d33517d9888dd77848f554522a38JP Abgrall}
65