Deleted Added
full compact
addrtoname.c (172686) addrtoname.c (190207)
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Internet, ethernet, port, and protocol string to address
22 * and address to string conversion routines
23 *
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Internet, ethernet, port, and protocol string to address
22 * and address to string conversion routines
23 *
24 * $FreeBSD: head/contrib/tcpdump/addrtoname.c 172686 2007-10-16 02:31:48Z mlaier $
24 * $FreeBSD: head/contrib/tcpdump/addrtoname.c 190207 2009-03-21 18:30:25Z rpaulo $
25 */
26#ifndef lint
27static const char rcsid[] _U_ =
25 */
26#ifndef lint
27static const char rcsid[] _U_ =
28 "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.9 2007/09/14 00:26:18 guy Exp $ (LBL)";
28 "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp $ (LBL)";
29#endif
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
35#include <tcpdump-stdinc.h>
36

--- 39 unchanged lines hidden (view full) ---

76
77/*
78 * hash tables for whatever-to-name translations
79 *
80 * XXX there has to be error checks against strdup(3) failure
81 */
82
83#define HASHNAMESIZE 4096
29#endif
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
35#include <tcpdump-stdinc.h>
36

--- 39 unchanged lines hidden (view full) ---

76
77/*
78 * hash tables for whatever-to-name translations
79 *
80 * XXX there has to be error checks against strdup(3) failure
81 */
82
83#define HASHNAMESIZE 4096
84#define BUFSIZE 128
85
86struct hnamemem {
87 u_int32_t addr;
88 const char *name;
89 struct hnamemem *nxt;
90};
91
92struct hnamemem hnametable[HASHNAMESIZE];

--- 413 unchanged lines hidden (view full) ---

506 tok2str(oui_values, "Unknown", oui));
507 } else
508 *cp = '\0';
509 tp->e_name = strdup(buf);
510 return (tp->e_name);
511}
512
513const char *
84
85struct hnamemem {
86 u_int32_t addr;
87 const char *name;
88 struct hnamemem *nxt;
89};
90
91struct hnamemem hnametable[HASHNAMESIZE];

--- 413 unchanged lines hidden (view full) ---

505 tok2str(oui_values, "Unknown", oui));
506 } else
507 *cp = '\0';
508 tp->e_name = strdup(buf);
509 return (tp->e_name);
510}
511
512const char *
514linkaddr_string(const u_char *ep, const unsigned int len)
513linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len)
515{
516 register u_int i;
517 register char *cp;
518 register struct enamemem *tp;
519
514{
515 register u_int i;
516 register char *cp;
517 register struct enamemem *tp;
518
520 if (len == ETHER_ADDR_LEN) /* XXX not totally correct... */
521 return etheraddr_string(ep);
519 if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) {
520 return etheraddr_string(ep);
521 }
522
522
523 if (type == LINKADDR_FRELAY) {
524 return q922_string(ep);
525 }
526
523 tp = lookup_bytestring(ep, len);
524 if (tp->e_name)
525 return (tp->e_name);
526
527 tp->e_name = cp = (char *)malloc(len*3);
528 if (tp->e_name == NULL)
529 error("linkaddr_string: malloc");
530 *cp++ = hex[*ep >> 4];

--- 650 unchanged lines hidden ---
527 tp = lookup_bytestring(ep, len);
528 if (tp->e_name)
529 return (tp->e_name);
530
531 tp->e_name = cp = (char *)malloc(len*3);
532 if (tp->e_name == NULL)
533 error("linkaddr_string: malloc");
534 *cp++ = hex[*ep >> 4];

--- 650 unchanged lines hidden ---