本文整理汇总了C++中ND_DEFAULTPRINT函数的典型用法代码示例。如果您正苦于以下问题:C++ ND_DEFAULTPRINT函数的具体用法?C++ ND_DEFAULTPRINT怎么用?C++ ND_DEFAULTPRINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ND_DEFAULTPRINT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: medsa_print
void
medsa_print(netdissect_options *ndo,
const u_char *bp, u_int length, u_int caplen)
{
register const struct ether_header *ep;
const struct medsa_pkthdr *medsa;
u_short ether_type;
medsa = (const struct medsa_pkthdr *)bp;
ep = (const struct ether_header *)(bp - sizeof(*ep));
ND_TCHECK(*medsa);
if (!ndo->ndo_eflag)
ND_PRINT((ndo, "MEDSA %d.%d:%d: ",
SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
else
medsa_print_full(ndo, medsa, caplen);
bp += 8;
length -= 8;
caplen -= 8;
ether_type = EXTRACT_16BITS(&medsa->ether_type);
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(ndo, bp, length, caplen, ESRC(ep), EDST(ep)) < 0) {
/* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(bp, caplen);
}
} else {
if (ndo->ndo_eflag)
ND_PRINT((ndo, "ethertype %s (0x%04x) ",
tok2str(ethertype_values, "Unknown",
ether_type),
ether_type));
if (ethertype_print(ndo, ether_type, bp, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
ND_PRINT((ndo, "ethertype %s (0x%04x) ",
tok2str(ethertype_values, "Unknown",
ether_type),
ether_type));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(bp, caplen);
}
}
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
}
开发者ID:Distrotech,项目名称:tcpdump,代码行数:53,代码来源:print-medsa.c
示例2: ap1394_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
struct firewire_header *fp;
u_short ether_type;
if (caplen < FIREWIRE_HDRLEN) {
ND_PRINT((ndo, "[|ap1394]"));
return FIREWIRE_HDRLEN;
}
if (ndo->ndo_eflag)
ap1394_hdr_print(ndo, p, length);
length -= FIREWIRE_HDRLEN;
caplen -= FIREWIRE_HDRLEN;
fp = (struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
ap1394_hdr_print(ndo, (u_char *)fp, length + FIREWIRE_HDRLEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
return FIREWIRE_HDRLEN;
}
开发者ID:rwdxll,项目名称:tcpdump,代码行数:39,代码来源:print-ap1394.c
示例3: bt_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the bluetooth header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
ndo->ndo_protocol = "bt_if";
if (caplen < BT_HDRLEN || length < BT_HDRLEN)
goto trunc;
caplen -= BT_HDRLEN;
length -= BT_HDRLEN;
p += BT_HDRLEN;
ND_TCHECK_4(&hdr->direction);
if (ndo->ndo_eflag)
ND_PRINT("hci length %u, direction %s, ", length,
(EXTRACT_BE_U_4(&hdr->direction)&0x1) ? "in" : "out");
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
trunc:
ND_PRINT("%s", tstr);
return (BT_HDRLEN);
}
开发者ID:Wilm0r,项目名称:tcpdump,代码行数:31,代码来源:print-bt.c
示例4: ppi_print
static u_int
ppi_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
if_printer printer;
const ppi_header_t *hdr;
u_int caplen = h->caplen;
u_int length = h->len;
uint16_t len;
uint32_t dlt;
uint32_t hdrlen;
struct pcap_pkthdr nhdr;
if (caplen < sizeof(ppi_header_t)) {
ND_PRINT((ndo, "[|ppi]"));
return (caplen);
}
hdr = (const ppi_header_t *)p;
len = EXTRACT_LE_16BITS(&hdr->ppi_len);
if (caplen < len) {
/*
* If we don't have the entire PPI header, don't
* bother.
*/
ND_PRINT((ndo, "[|ppi]"));
return (caplen);
}
if (len < sizeof(ppi_header_t)) {
ND_PRINT((ndo, "[|ppi]"));
return (len);
}
dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
if (ndo->ndo_eflag)
ppi_header_print(ndo, p, length);
length -= len;
caplen -= len;
p += len;
if ((printer = lookup_printer(dlt)) != NULL) {
nhdr = *h;
nhdr.caplen = caplen;
nhdr.len = length;
hdrlen = printer(ndo, &nhdr, p);
} else {
if (!ndo->ndo_eflag)
ppi_header_print(ndo, (const u_char *)hdr, length + len);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
hdrlen = 0;
}
return (len + hdrlen);
}
开发者ID:GerardGarcia,项目名称:tcpdump,代码行数:56,代码来源:print-ppi.c
示例5: symantec_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
struct symantec_header *sp;
u_short ether_type;
if (caplen < sizeof (struct symantec_header)) {
ND_PRINT((ndo, "[|symantec]"));
return caplen;
}
if (ndo->ndo_eflag)
symantec_hdr_print(ndo, p, length);
length -= sizeof (struct symantec_header);
caplen -= sizeof (struct symantec_header);
sp = (struct symantec_header *)p;
p += sizeof (struct symantec_header);
ether_type = EXTRACT_16BITS(&sp->ether_type);
if (ether_type <= ETHERMTU) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
} else if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
return (sizeof (struct symantec_header));
}
开发者ID:0-kaladin,项目名称:ad-away,代码行数:47,代码来源:print-symantec.c
示例6: medsa_print_full
static void
medsa_print_full(netdissect_options *ndo,
const struct medsa_pkthdr *medsa,
u_int caplen)
{
u_char tag = TAG(medsa);
ND_PRINT((ndo, "%s",
tok2str(tag_values, "Unknown (%u)", tag)));
switch (tag) {
case TAG_TO_CPU:
ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
ND_PRINT((ndo, ", %s",
tok2str(code_values, "Unknown (%u)", CODE(medsa))));
if (CFI(medsa))
ND_PRINT((ndo, ", CFI"));
ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
break;
case TAG_FROM_CPU:
ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
if (CFI(medsa))
ND_PRINT((ndo, ", CFI"));
ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
break;
case TAG_FORWARD:
ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
if (TRUNK(medsa))
ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d",
SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
else
ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
if (CFI(medsa))
ND_PRINT((ndo, ", CFI"));
ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
break;
default:
ND_DEFAULTPRINT((const u_char *)medsa, caplen);
return;
}
}
开发者ID:Distrotech,项目名称:tcpdump,代码行数:52,代码来源:print-medsa.c
示例7: calm_fast_print
/*
* This is the top level routine of the printer. 'bp' points
* to the calm header of the packet.
*/
void
calm_fast_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int length)
{
int srcNwref = bp[0];
int dstNwref = bp[1];
length -= 2;
bp += 2;
ND_PRINT((ndo, "CALM FAST src:%s; ", etheraddr_string(eth+6)));
ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
if (ndo->ndo_vflag)
ND_DEFAULTPRINT(bp, length);
}
开发者ID:raniyuva,项目名称:tcpdump,代码行数:19,代码来源:print-calm-fast.c
示例8: arcnet_linux_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the ARCNET header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured. It is quite similar
* to the non-Linux style printer except that Linux doesn't ever
* supply packets that look like exception frames, it always supplies
* reassembled packets rather than raw frames, and headers have an
* extra "offset" field between the src/dest and packet type.
*/
u_int
arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
const struct arc_linux_header *ap;
int archdrlen = 0;
u_char arc_type;
if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
ND_PRINT("[|arcnet]");
return (caplen);
}
ap = (const struct arc_linux_header *)p;
arc_type = EXTRACT_U_1(ap->arc_type);
switch (arc_type) {
default:
archdrlen = ARC_LINUX_HDRNEWLEN;
if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
ND_PRINT("[|arcnet]");
return (caplen);
}
break;
case ARCTYPE_IP_OLD:
case ARCTYPE_ARP_OLD:
case ARCTYPE_DIAGNOSE:
archdrlen = ARC_LINUX_HDRLEN;
break;
}
if (ndo->ndo_eflag)
arcnet_print(ndo, p, length, 0, 0, 0);
/*
* Go past the ARCNET header.
*/
length -= archdrlen;
caplen -= archdrlen;
p += archdrlen;
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
}
开发者ID:bashow0316,项目名称:tcpdump,代码行数:58,代码来源:print-arcnet.c
示例9: cip_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the LLC/SNAP or raw header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
size_t cmplen;
int llc_hdrlen;
ndo->ndo_protocol = "cip_if";
cmplen = sizeof(rfcllc);
if (cmplen > caplen)
cmplen = caplen;
if (cmplen > length)
cmplen = length;
if (ndo->ndo_eflag)
cip_print(ndo, length);
if (cmplen == 0) {
ND_PRINT("[|cip]");
return 0;
}
if (memcmp(rfcllc, p, cmplen) == 0) {
/*
* LLC header is present. Try to print it & higher layers.
*/
llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
if (llc_hdrlen < 0) {
/* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
llc_hdrlen = -llc_hdrlen;
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
llc_hdrlen = 0;
ip_print(ndo, p, length);
}
return (llc_hdrlen);
}
开发者ID:Wilm0r,项目名称:tcpdump,代码行数:49,代码来源:print-cip.c
示例10: ipnet_print
static void
ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const ipnet_hdr_t *hdr;
if (caplen < sizeof(ipnet_hdr_t))
goto trunc;
if (ndo->ndo_eflag)
ipnet_hdr_print(ndo, p, length);
length -= sizeof(ipnet_hdr_t);
caplen -= sizeof(ipnet_hdr_t);
hdr = (const ipnet_hdr_t *)p;
p += sizeof(ipnet_hdr_t);
ND_TCHECK_1(hdr->iph_family);
switch (EXTRACT_U_1(hdr->iph_family)) {
case IPH_AF_INET:
ip_print(ndo, p, length);
break;
case IPH_AF_INET6:
ip6_print(ndo, p, length);
break;
default:
if (!ndo->ndo_eflag)
ipnet_hdr_print(ndo, (const u_char *)hdr,
length + sizeof(ipnet_hdr_t));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
break;
}
return;
trunc:
ND_PRINT(" %s", tstr);
}
开发者ID:lampmanyao,项目名称:tcpdump,代码行数:40,代码来源:print-ipnet.c
示例11: cip_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the LLC/SNAP or raw header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
u_short extracted_ethertype;
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
ND_PRINT((ndo, "[|cip]"));
return (0);
}
if (ndo->ndo_eflag)
cip_print(ndo, length);
if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
/*
* LLC header is present. Try to print it & higher layers.
*/
if (llc_print(ndo, p, length, caplen, NULL, NULL,
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
cip_print(ndo, length);
if (extracted_ethertype) {
ND_PRINT((ndo, "(LLC %s) ",
etherproto_string(htons(extracted_ethertype))));
}
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
ip_print(ndo, p, length);
}
return (0);
}
开发者ID:0-kaladin,项目名称:ad-away,代码行数:46,代码来源:print-cip.c
示例12: ap1394_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const struct firewire_header *fp;
u_short ether_type;
struct lladdr_info src, dst;
ndo->ndo_protocol = "ap1394_if";
if (caplen < FIREWIRE_HDRLEN) {
nd_print_trunc(ndo);
return FIREWIRE_HDRLEN;
}
if (ndo->ndo_eflag)
ap1394_hdr_print(ndo, p, length);
length -= FIREWIRE_HDRLEN;
caplen -= FIREWIRE_HDRLEN;
fp = (const struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
ether_type = GET_BE_U_2(fp->firewire_type);
src.addr = fp->firewire_shost;
src.addr_string = fwaddr_string;
dst.addr = fp->firewire_dhost;
dst.addr_string = fwaddr_string;
if (ethertype_print(ndo, ether_type, p, length, caplen, &src, &dst) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
ap1394_hdr_print(ndo, (const u_char *)fp, length + FIREWIRE_HDRLEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
return FIREWIRE_HDRLEN;
}
开发者ID:fenner,项目名称:tcpdump,代码行数:45,代码来源:print-ap1394.c
示例13: ipnet_print
static void
ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const ipnet_hdr_t *hdr;
if (caplen < sizeof(ipnet_hdr_t)) {
ND_PRINT((ndo, "[|ipnet]"));
return;
}
if (ndo->ndo_eflag)
ipnet_hdr_print(ndo, p, length);
length -= sizeof(ipnet_hdr_t);
caplen -= sizeof(ipnet_hdr_t);
hdr = (const ipnet_hdr_t *)p;
p += sizeof(ipnet_hdr_t);
switch (hdr->iph_family) {
case IPH_AF_INET:
ip_print(ndo, p, length);
break;
case IPH_AF_INET6:
ip6_print(ndo, p, length);
break;
default:
if (!ndo->ndo_eflag)
ipnet_hdr_print(ndo, (const u_char *)hdr,
length + sizeof(ipnet_hdr_t));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
break;
}
}
开发者ID:EliseuTorres,项目名称:tcpdump,代码行数:38,代码来源:print-ipnet.c
示例14: atmarp_print
static void
atmarp_print(netdissect_options *ndo,
const u_char *bp, u_int length, u_int caplen)
{
const struct atmarp_pkthdr *ap;
u_short pro, hrd, op;
ap = (const struct atmarp_pkthdr *)bp;
ND_TCHECK(*ap);
hrd = ATMHRD(ap);
pro = ATMPRO(ap);
op = ATMOP(ap);
if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {
ND_PRINT((ndo, "[|ARP]"));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
if (!ndo->ndo_eflag) {
ND_PRINT((ndo, "ARP, "));
}
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
ATMSPROTO_LEN(ap) != 4 ||
ATMTPROTO_LEN(ap) != 4 ||
ndo->ndo_vflag) {
ND_PRINT((ndo, "%s, %s (len %u/%u)",
tok2str(arphrd_values, "Unknown Hardware (%u)", hrd),
tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro),
ATMSPROTO_LEN(ap),
ATMTPROTO_LEN(ap)));
/* don't know know about the address formats */
if (!ndo->ndo_vflag) {
goto out;
}
}
/* print operation */
printf("%s%s ",
ndo->ndo_vflag ? ", " : "",
tok2str(arpop_values, "Unknown (%u)", op));
switch (op) {
case ARPOP_REQUEST:
ND_PRINT((ndo, "who-has %s", ipaddr_string(ATMTPA(ap))));
if (ATMTHRD_LEN(ap) != 0) {
ND_PRINT((ndo, " ("));
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
ATMTSA(ap), ATMTSLN(ap));
ND_PRINT((ndo, ")"));
}
ND_PRINT((ndo, "tell %s", ipaddr_string(ATMSPA(ap))));
break;
case ARPOP_REPLY:
ND_PRINT((ndo, "%s is-at ", ipaddr_string(ATMSPA(ap))));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
case ARPOP_INVREQUEST:
ND_PRINT((ndo, "who-is "));
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap),
ATMTSLN(ap));
ND_PRINT((ndo, " tell "));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
case ARPOP_INVREPLY:
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
ND_PRINT((ndo, "at %s", ipaddr_string(ATMSPA(ap))));
break;
case ARPOP_NAK:
ND_PRINT((ndo, "for %s", ipaddr_string(ATMSPA(ap))));
break;
default:
ND_DEFAULTPRINT((const u_char *)ap, caplen);
return;
}
out:
ND_PRINT((ndo, ", length %u", length));
return;
trunc:
ND_PRINT((ndo, "[|ARP]"));
}
开发者ID:2014-class,项目名称:freerouter,代码行数:95,代码来源:print-arp.c
示例15: _token_print
u_int
_token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct token_header *trp;
u_short extracted_ethertype;
struct ether_header ehdr;
u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
int seg;
trp = (const struct token_header *)p;
if (caplen < TOKEN_HDRLEN) {
ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
/*
* Get the TR addresses into a canonical form
*/
extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
/* Adjust for source routing information in the MAC header */
if (IS_SOURCE_ROUTED(trp)) {
/* Clear source-routed bit */
*ESRC(&ehdr) &= 0x7f;
if (ndo->ndo_eflag)
token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
if (caplen < TOKEN_HDRLEN + 2) {
ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
route_len = RIF_LENGTH(trp);
hdr_len += route_len;
if (caplen < hdr_len) {
ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
if (ndo->ndo_vflag) {
ND_PRINT((ndo, "%s ", broadcast_indicator[BROADCAST(trp)]));
ND_PRINT((ndo, "%s", direction[DIRECTION(trp)]));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),
BRIDGE_NUMBER(trp, seg)));
} else {
ND_PRINT((ndo, "rt = %x", EXTRACT_16BITS(&trp->token_rcf)));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
ND_PRINT((ndo, ":%x", EXTRACT_16BITS(&trp->token_rseg[seg])));
}
ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));
} else {
if (ndo->ndo_eflag)
token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
}
/* Skip over token ring MAC header and routing information */
length -= hdr_len;
p += hdr_len;
caplen -= hdr_len;
/* Frame Control field determines interpretation of packet */
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
token_hdr_print(ndo, trp,
length + TOKEN_HDRLEN + route_len,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
ND_PRINT((ndo, "(LLC %s) ",
etherproto_string(htons(extracted_ethertype))));
}
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
} else {
/* Some kinds of TR packet we cannot handle intelligently */
/* XXX - dissect MAC packets if frame type is 0 */
if (!ndo->ndo_eflag)
token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,
ESRC(&ehdr), EDST(&ehdr));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
return (hdr_len);
}
开发者ID:RichardsonAlex,项目名称:cheribsd,代码行数:91,代码来源:print-token.c
示例16: nflog_if_print
u_int
nflog_if_print(struct netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
const nflog_hdr_t *hdr = (const nflog_hdr_t *)p;
const nflog_tlv_t *tlv;
u_int16_t size;
u_int16_t h_size = sizeof(nflog_hdr_t);
u_int caplen = h->caplen;
u_int length = h->len;
if (caplen < (int) sizeof(nflog_hdr_t) || length < (int) sizeof(nflog_hdr_t)) {
ND_PRINT((ndo, "[|nflog]"));
return h_size;
}
if (!(hdr->nflog_version) == 0) {
ND_PRINT((ndo, "version %u (unknown)", hdr->nflog_version));
return h_size;
}
if (ndo->ndo_eflag)
nflog_hdr_print(ndo, hdr, length);
p += sizeof(nflog_hdr_t);
length -= sizeof(nflog_hdr_t);
caplen -= sizeof(nflog_hdr_t);
while (length > 0) {
/* We have some data. Do we have enough for the TLV header? */
if (caplen < sizeof(nflog_tlv_t) || length < sizeof(nflog_tlv_t)) {
/* No. */
ND_PRINT((ndo, "[|nflog]"));
return h_size;
}
tlv = (const nflog_tlv_t *) p;
size = tlv->tlv_length;
if (size % 4 != 0)
size += 4 - size % 4;
/* Is the TLV's length less than the minimum? */
if (size < sizeof(nflog_tlv_t)) {
/* Yes. Give up now. */
ND_PRINT((ndo, "[|nflog]"));
return h_size;
}
/* Do we have enough data for the full TLV? */
if (caplen < size || length < size) {
/* No. */
ND_PRINT((ndo, "[|nflog]"));
return h_size;
}
if (tlv->tlv_type == NFULA_PAYLOAD) {
/*
* This TLV's data is the packet payload.
* Skip past the TLV header, and break out
* of the loop so we print the packet data.
*/
p += sizeof(nflog_tlv_t);
h_size += sizeof(nflog_tlv_t);
length -= sizeof(nflog_tlv_t);
caplen -= sizeof(nflog_tlv_t);
break;
}
p += size;
h_size += size;
length -= size;
caplen -= size;
}
switch (hdr->nflog_family) {
case AF_INET:
ip_print(ndo, p, length);
break;
#ifdef INET6
case AF_INET6:
ip6_print(ndo, p, length);
break;
#endif /*INET6*/
default:
if (!ndo->ndo_eflag)
nflog_hdr_print(ndo, hdr,
length + sizeof(nflog_hdr_t));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
break;
}
return h_size;
}
开发者ID:raniyuva,项目名称:tcpdump,代码行数:98,代码来源:print-nflog.c
示例17: null_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
u_int family;
if (caplen < NULL_HDRLEN) {
ND_PRINT((ndo, "[|null]"));
return (NULL_HDRLEN);
}
memcpy((char *)&family, (char *)p, sizeof(family));
/*
* This isn't necessarily in our host byte order; if this is
* a DLT_LOOP capture, it's in network byte order, and if
* this is a DLT_NULL capture from a machine with the opposite
* byte-order, it's in the opposite byte order from ours.
*
* If the upper 16 bits aren't all zero, assume it's byte-swapped.
*/
if ((family & 0xFFFF0000) != 0)
family = SWAPLONG(family);
if (ndo->ndo_eflag)
null_hdr_print(ndo, family, length);
length -= NULL_HDRLEN;
caplen -= NULL_HDRLEN;
p += NULL_HDRLEN;
switch (family) {
case BSD_AFNUM_INET:
ip_print(ndo, p, length);
break;
case BSD_AFNUM_INET6_BSD:
case BSD_AFNUM_INET6_FREEBSD:
case BSD_AFNUM_INET6_DARWIN:
ip6_print(ndo, p, length);
break;
case BSD_AFNUM_ISO:
isoclns_print(ndo, p, length, caplen);
break;
case BSD_AFNUM_APPLETALK:
atalk_print(ndo, p, length);
break;
case BSD_AFNUM_IPX:
ipx_print(ndo, p, length);
break;
default:
/* unknown AF_ value */
if (!ndo->ndo_eflag)
null_hdr_print(ndo, family, length + NULL_HDRLEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
return (NULL_HDRLEN);
}
开发者ID:Longinus00,项目名称:tcpdump,代码行数:72,代码来源:print-null.c
示例18: pktap_if_print
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
pktap_if_print(struct netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
uint32_t dlt, hdrlen, rectype;
u_int caplen = h->caplen;
u_int length = h->len;
if_ndo_printer ndo_printer;
if_printer printer;
pktap_header_t *hdr;
if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
ND_PRINT((ndo, "[|pktap]"));
return (0);
}
hdr = (pktap_header_t *)p;
dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
if (hdrlen < sizeof(pktap_header_t)) {
/*
* Claimed header length < structure length.
* XXX - does this just mean some fields aren't
* being supplied, or is it truly an error (i.e.,
* is the length supplied so that the header can
* be expanded in the future)?
*/
ND_PRINT((ndo, "[|pktap]"));
return (0);
}
if (caplen < hdrlen || length < hdrlen) {
ND_PRINT((ndo, "[|pktap]"));
return (hdrlen);
}
if (ndo->ndo_eflag)
pktap_header_print(ndo, p, length);
length -= hdrlen;
caplen -= hdrlen;
p += hdrlen;
rectype = EXTRACT_LE_32BITS(&hdr->pkt_rectype);
switch (rectype) {
case PKT_REC_NONE:
ND_PRINT((ndo, "no data"));
break;
case PKT_REC_PACKET:
if ((printer = lookup_printer(dlt)) != NULL) {
printer(h, p);
} else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
ndo_printer(ndo, h, p);
} else {
if (!ndo->ndo_eflag)
pktap_header_print(ndo, (u_char *)hdr,
length + hdrlen);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
break;
}
return (hdrlen);
}
开发者ID:raniyuva,项目名称:tcpdump,代码行数:72,代码来源:print-pktap.c
示例19: _sctp_print
//.........这里部分代码省略.........
ND_PRINT((ndo, "[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId)));
ND_PRINT((ndo, "[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence)));
ND_PRINT((ndo, "[PPID %s] ",
tok2str(PayloadProto_idents, "0x%x", ppid)));
if (!isforces) {
isforces = (ppid == SCTP_PPID_FORCES_HP) ||
(ppid == SCTP_PPID_FORCES_MP) ||
(ppid == SCTP_PPID_FORCES_LP);
}
payloadPtr = (const u_char *) (dataHdrPtr + 1);
if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc) + 1) {
ND_PRINT((ndo, "bogus chunk length %u]", EXTRACT_16BITS(&chunkDescPtr->chunkLength)));
return;
}
payload_size = EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
(sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc));
if (isforces) {
forces_print(ndo, payloadPtr, payload_size);
} else if (ndo->ndo_vflag >= 2) { /* if verbose output is specified */
/* at the command line */
switch (ppid) {
case SCTP_PPID_M3UA :
m3ua_print(ndo, payloadPtr, payload_size);
break;
default:
ND_PRINT((ndo, "[Payload"));
if (!ndo->ndo_suppress_default_print) {
ND_PRINT((ndo, ":"));
ND_DEFAULTPRINT(payloadPtr, payload_size);
}
ND_PRINT((ndo, "]"));
break;
}
}
break;
}
case SCTP_INITIATION :
{
const struct sctpInitiation *init;
init=(const struct sctpInitiation*)(chunkDescPtr+1);
ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
"Optional params present, but not printed."));
#endif
break;
}
case SCTP_INITIATION_ACK :
{
const struct sctpInitiation *init;
init=(const struct sctpInitiation*)(chunkDescPtr+1);
ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
开发者ID:RichardsonAlex,项目名称:cheribsd,代码行数:67,代码来源:print-sctp.c
示例20: sll_if_print
/*
* This is the top level routine of the printer. 'p' points to the
* Linux "cooked capture" header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
register const struct sll_header *sllp;
u_short ether_type;
u_short extracted_ethertype;
if (caplen < SLL_HDR_LEN) {
/*
* XXX - this "can't happen" because "pcap-linux.c" always
* adds this many bytes of header to every packet in a
* cooked socket capture.
*/
ND_PRINT((ndo, "[|sll]"));
return (caplen);
}
sllp = (const struct sll_header *)p;
if (ndo->ndo_eflag)
sll_print(ndo, sllp, length);
/*
* Go past the cooked-mode header.
*/
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
recurse:
/*
* Is it (gag) an 802.3 encapsulation, or some non-Ethernet
* packet type?
*/
if (ether_type <= ETHERMTU) {
/*
* Yes - what type is it?
*/
switch (ether_type) {
case LINUX_SLL_P_802_3:
/*
* Ethernet_802.3 IPX frame.
*/
ipx_print(ndo, p, length);
break;
case LINUX_SLL_P_802_2:
/*
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
if (llc_print(ndo, p, length, caplen, NULL, NULL,
&extracted_ethertype) == 0)
goto unknown; /* unknown LLC type */
break;
default:
extracted_ethertype = 0;
/*FALLTHROUGH*/
unknown:
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
sll_print(ndo, sllp, length + SLL_HDR_LEN);
if (extracted_ethertype) {
ND_PRINT((ndo, "(LLC %s) ",
etherproto_string(htons(extracted_ethertype))));
}
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
break;
}
} else if (ether_type == ETHERTYPE_8021Q) {
/*
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
if (caplen < 4 || length < 4) {
ND_PRINT((ndo, "[|vlan]"));
return (SLL_HDR_LEN);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
ND_PRINT((ndo, "vlan %u, p %u%s, ",
tag & 0xfff,
tag >> 13,
(tag & 0x1000) ? ", CFI" : ""));
}
//.........这里部分代码省略.........
开发者ID:Danielweber7624,项目名称:tcpdump,代码行数:101,代码来源:print-sll.c
注:本文中的ND_DEFAULTPRINT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论