summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-atalk.c
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2002-06-21 00:49:02 +0000
committerfenner <fenner@FreeBSD.org>2002-06-21 00:49:02 +0000
commit6d9538de202e4b8787f1b1a2ee8dce6273a43dc2 (patch)
treecf4df09e1e89ebd11358792543230083e577ad0f /contrib/tcpdump/print-atalk.c
parentd832be42ce7cc0a492cddc15e8429bc29fb46462 (diff)
downloadFreeBSD-src-6d9538de202e4b8787f1b1a2ee8dce6273a43dc2.zip
FreeBSD-src-6d9538de202e4b8787f1b1a2ee8dce6273a43dc2.tar.gz
Merge tcpdump 3.7.1
MFC after: 2 weeks
Diffstat (limited to 'contrib/tcpdump/print-atalk.c')
-rw-r--r--contrib/tcpdump/print-atalk.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index 195638b..9e72cbe 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.64 2000/10/30 06:22:14 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.70 2001/11/15 08:23:12 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,13 +42,13 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
+#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
#include "appletalk.h"
-#include "savestr.h"
static struct tok type2str[] = {
{ ddpRTMP, "rtmp" },
@@ -86,6 +86,24 @@ static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
static const char *ddpskt_string(int);
/*
+ * Print LLAP packets received on a physical LocalTalk interface.
+ */
+void
+ltalk_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+ snapend = p + h->caplen;
+ ++infodelay;
+ ts_print(&h->ts);
+ llap_print(p, h->caplen);
+ if(xflag)
+ default_print(p, h->caplen);
+ putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
+}
+
+/*
* Print AppleTalk LLAP packets.
*/
void
@@ -97,7 +115,7 @@ llap_print(register const u_char *bp, u_int length)
u_short snet;
#if 0
- lp = (struct LAP *)bp;
+ lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
#else
@@ -165,8 +183,8 @@ atalk_print(register const u_char *bp, u_int length)
u_short snet;
if (length < ddpSize) {
- (void)printf(" [|ddp %d]", length);
- return;
+ (void)printf(" [|ddp %d]", length);
+ return;
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
@@ -177,6 +195,21 @@ atalk_print(register const u_char *bp, u_int length)
ddpskt_string(dp->dstSkt));
bp += ddpSize;
length -= ddpSize;
+#ifdef LBL_ALIGN
+ if ((long)bp & 3) {
+ static u_char *abuf = NULL;
+
+ if (abuf == NULL) {
+ abuf = (u_char *)malloc(snaplen);
+ if (abuf == NULL)
+ error("atalk_print: malloc");
+ }
+ memcpy((char *)abuf, (char *)bp, min(length, snaplen));
+ snapend += abuf - (u_char *)bp;
+ packetp = abuf;
+ bp = abuf;
+ }
+#endif
ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
}
@@ -366,7 +399,7 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tp =
- (struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
+ (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
int i;
const u_char *ep;
@@ -442,7 +475,7 @@ print_cstring(register const char *cp, register const u_char *ep)
return (0);
}
while ((int)--length >= 0) {
- if (cp >= (char *)ep) {
+ if (cp >= (const char *)ep) {
fputs(tstr, stdout);
return (0);
}
@@ -551,7 +584,7 @@ ataddr_string(u_short atnet, u_char athost)
;
tp->addr = i2;
tp->nxt = newhnamemem();
- tp->name = savestr(nambuf);
+ tp->name = strdup(nambuf);
}
fclose(fp);
}
@@ -568,7 +601,7 @@ ataddr_string(u_short atnet, u_char athost)
tp->nxt = newhnamemem();
(void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
tp2->name, athost);
- tp->name = savestr(nambuf);
+ tp->name = strdup(nambuf);
return (tp->name);
}
@@ -580,7 +613,7 @@ ataddr_string(u_short atnet, u_char athost)
else
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
atnet & 0xff);
- tp->name = savestr(nambuf);
+ tp->name = strdup(nambuf);
return (tp->name);
}
OpenPOWER on IntegriCloud