]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-atalk.c
Handle rpcaps:// URLs as well, for rpcap-over-TLS.
[tcpdump] / print-atalk.c
index 278495f83bb4b2c3bb42d6a48ab004d2c9293d09..8faa29f0ce9cefeeb43985f43e970fcdd7f86362 100644 (file)
@@ -106,7 +106,7 @@ llap_print(netdissect_options *ndo,
                return (length);
        }
        if (!ND_TTEST_LEN(bp, sizeof(*lp))) {
-               ND_PRINT(" [|llap]");
+               nd_print_trunc(ndo);
                return (0);     /* cut short by the snapshot length */
        }
        lp = (const struct LAP *)bp;
@@ -221,7 +221,7 @@ aarp_print(netdissect_options *ndo,
        ap = (const struct aarp *)bp;
        if (!ND_TTEST_SIZE(ap)) {
                /* Just bail if we don't have the whole chunk. */
-               ND_PRINT(" [|aarp]");
+               nd_print_trunc(ndo);
                return;
        }
        if (length < sizeof(*ap)) {
@@ -584,39 +584,57 @@ ataddr_string(netdissect_options *ndo,
        FILE *fp;
 
        /*
-        * if this is the first call, see if there's an AppleTalk
-        * number to name map file.
+        * Are we doing address to name resolution?
         */
-       if (first && (first = 0, !ndo->ndo_nflag)
-           && (fp = fopen("/etc/atalk.names", "r"))) {
-               char line[256];
-               u_int i1, i2;
-
-               while (fgets(line, sizeof(line), fp)) {
-                       if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
-                               continue;
-                       if (sscanf(line, "%u.%u %256s", &i1, &i2, nambuf) == 3)
-                               /* got a hostname. */
-                               i2 |= (i1 << 8);
-                       else if (sscanf(line, "%u %256s", &i1, nambuf) == 2)
-                               /* got a net name */
-                               i2 = (i1 << 8) | 255;
-                       else
-                               continue;
-
-                       for (tp = &hnametable[i2 & (HASHNAMESIZE-1)];
-                            tp->nxt; tp = tp->nxt)
-                               ;
-                       tp->addr = i2;
-                       tp->nxt = newhnamemem(ndo);
-                       tp->name = strdup(nambuf);
-                       if (tp->name == NULL)
-                               (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
-                                       "ataddr_string: strdup(nambuf)");
+       if (!ndo->ndo_nflag) {
+               /*
+                * Yes.  Have we tried to open and read an AppleTalk
+                * number to name map file?
+                */
+               if (!first) {
+                       /*
+                        * No; try to do so.
+                        */
+                       first = 0;
+                       fp = fopen("/etc/atalk.names", "r");
+                       if (fp != NULL) {
+                               char line[256];
+                               u_int i1, i2;
+
+                               while (fgets(line, sizeof(line), fp)) {
+                                       if (line[0] == '\n' || line[0] == 0 ||
+                                           line[0] == '#')
+                                               continue;
+                                       if (sscanf(line, "%u.%u %256s", &i1,
+                                           &i2, nambuf) == 3)
+                                               /* got a hostname. */
+                                               i2 |= (i1 << 8);
+                                       else if (sscanf(line, "%u %256s", &i1,
+                                           nambuf) == 2)
+                                               /* got a net name */
+                                               i2 = (i1 << 8) | 255;
+                                       else
+                                               continue;
+
+                                       for (tp = &hnametable[i2 & (HASHNAMESIZE-1)];
+                                            tp->nxt; tp = tp->nxt)
+                                               ;
+                                       tp->addr = i2;
+                                       tp->nxt = newhnamemem(ndo);
+                                       tp->name = strdup(nambuf);
+                                       if (tp->name == NULL)
+                                               (*ndo->ndo_error)(ndo,
+                                                   S_ERR_ND_MEM_ALLOC,
+                                                   "ataddr_string: strdup(nambuf)");
+                               }
+                               fclose(fp);
+                       }
                }
-               fclose(fp);
        }
 
+       /*
+        * Now try to look up the address in the table.
+        */
        for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
                if (tp->addr == i)
                        return (tp->name);