1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#include <config.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#define MOBILE_SIZE (8)
struct mobile_ip {
nd_uint16_t proto;
nd_uint16_t hcheck;
nd_uint32_t odst;
nd_uint32_t osrc;
};
#define OSRC_PRES 0x0080
void
mobile_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const struct mobile_ip *mob;
struct cksum_vec vec[1];
u_short proto,crc;
u_char osp =0;
ndo->ndo_protocol = "mobile";
mob = (const struct mobile_ip *)bp;
if (length < MOBILE_SIZE || !ND_TTEST_SIZE(mob)) {
nd_print_trunc(ndo);
return;
}
ND_PRINT("mobile: ");
proto = GET_BE_U_2(mob->proto);
crc = GET_BE_U_2(mob->hcheck);
if (proto & OSRC_PRES) {
osp=1;
}
if (osp) {
ND_PRINT("[S] ");
if (ndo->ndo_vflag)
ND_PRINT("%s ", GET_IPADDR_STRING(mob->osrc));
} else {
ND_PRINT("[] ");
}
if (ndo->ndo_vflag) {
ND_PRINT("> %s ", GET_IPADDR_STRING(mob->odst));
ND_PRINT("(oproto=%u)", proto>>8);
}
vec[0].ptr = (const uint8_t *)(const void *)mob;
vec[0].len = osp ? 12 : 8;
if (in_cksum(vec, 1)!=0) {
ND_PRINT(" (bad checksum %u)", crc);
}
}
|