Deleted Added
full compact
nametoaddr.c (39294) nametoaddr.c (56891)
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
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

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

15 * or promote products derived from this software without specific prior
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 * Name to id translation routines used by the scanner.
22 * These functions are not time critical.
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
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

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

15 * or promote products derived from this software without specific prior
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 * Name to id translation routines used by the scanner.
22 * These functions are not time critical.
23 *
24 * $FreeBSD: head/contrib/libpcap/nametoaddr.c 56891 2000-01-30 00:43:38Z fenner $
23 */
24
25#ifndef lint
26static const char rcsid[] =
25 */
26
27#ifndef lint
28static const char rcsid[] =
27 "@(#) $Header: nametoaddr.c,v 1.48 98/07/12 13:15:36 leres Exp $ (LBL)";
29 "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.51 1999/11/25 08:25:35 itojun Exp $ (LBL)";
28#endif
29
30#include <sys/param.h>
31#include <sys/types.h> /* concession to AIX */
32#include <sys/socket.h>
33#include <sys/time.h>
34
35#if __STDC__
36struct mbuf;
37struct rtentry;
38#endif
39
40#include <net/if.h>
41#include <net/ethernet.h>
42#include <netinet/in.h>
43#include <arpa/inet.h>
30#endif
31
32#include <sys/param.h>
33#include <sys/types.h> /* concession to AIX */
34#include <sys/socket.h>
35#include <sys/time.h>
36
37#if __STDC__
38struct mbuf;
39struct rtentry;
40#endif
41
42#include <net/if.h>
43#include <net/ethernet.h>
44#include <netinet/in.h>
45#include <arpa/inet.h>
46#ifdef INET6
47#include <netdb.h>
48#include <sys/socket.h>
49#endif /*INET6*/
44
45#include <ctype.h>
46#include <errno.h>
47#include <stdlib.h>
48#include <memory.h>
49#include <netdb.h>
50#include <stdio.h>
51

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

65#endif
66
67static inline int xdtoi(int);
68
69/*
70 * Convert host name to internet address.
71 * Return 0 upon failure.
72 */
50
51#include <ctype.h>
52#include <errno.h>
53#include <stdlib.h>
54#include <memory.h>
55#include <netdb.h>
56#include <stdio.h>
57

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

71#endif
72
73static inline int xdtoi(int);
74
75/*
76 * Convert host name to internet address.
77 * Return 0 upon failure.
78 */
79#ifndef INET6
73bpf_u_int32 **
74pcap_nametoaddr(const char *name)
75{
76#ifndef h_addr
77 static bpf_u_int32 *hlist[2];
78#endif
79 bpf_u_int32 **p;
80 struct hostent *hp;

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

88 for (p = (bpf_u_int32 **)hp->h_addr_list; *p; ++p)
89 NTOHL(**p);
90 return (bpf_u_int32 **)hp->h_addr_list;
91#endif
92 }
93 else
94 return 0;
95}
80bpf_u_int32 **
81pcap_nametoaddr(const char *name)
82{
83#ifndef h_addr
84 static bpf_u_int32 *hlist[2];
85#endif
86 bpf_u_int32 **p;
87 struct hostent *hp;

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

95 for (p = (bpf_u_int32 **)hp->h_addr_list; *p; ++p)
96 NTOHL(**p);
97 return (bpf_u_int32 **)hp->h_addr_list;
98#endif
99 }
100 else
101 return 0;
102}
103#else
104struct addrinfo *
105pcap_nametoaddr(const char *name)
106{
107 struct addrinfo hints, *res;
108 int error;
96
109
110 memset(&hints, 0, sizeof(hints));
111 hints.ai_family = PF_UNSPEC;
112 hints.ai_socktype = SOCK_STREAM; /*not really*/
113 error = getaddrinfo(name, NULL, &hints, &res);
114 if (error)
115 return NULL;
116 else
117 return res;
118}
119#endif /*INET6*/
120
97/*
98 * Convert net name to internet address.
99 * Return 0 upon failure.
100 */
101bpf_u_int32
102pcap_nametonetaddr(const char *name)
103{
104 struct netent *np;

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

177
178struct eproto {
179 char *s;
180 u_short p;
181};
182
183/* Static data base of ether protocol types. */
184struct eproto eproto_db[] = {
121/*
122 * Convert net name to internet address.
123 * Return 0 upon failure.
124 */
125bpf_u_int32
126pcap_nametonetaddr(const char *name)
127{
128 struct netent *np;

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

201
202struct eproto {
203 char *s;
204 u_short p;
205};
206
207/* Static data base of ether protocol types. */
208struct eproto eproto_db[] = {
209#if 0
210 /* The FreeBSD elf linker generates a request to copy this array
211 * (including its size) when you link with -lpcap. In order to
212 * not bump the major version number of this libpcap.so, we need
213 * to ensure that the array stays the same size. Since PUP is
214 * likely never seen in real life any more, it's the first to
215 * be sacrificed (in favor of ip6).
216 */
185 { "pup", ETHERTYPE_PUP },
217 { "pup", ETHERTYPE_PUP },
218#endif
186 { "xns", ETHERTYPE_NS },
187 { "ip", ETHERTYPE_IP },
219 { "xns", ETHERTYPE_NS },
220 { "ip", ETHERTYPE_IP },
221#ifdef INET6
222 { "ip6", ETHERTYPE_IPV6 },
223#endif
188 { "arp", ETHERTYPE_ARP },
189 { "rarp", ETHERTYPE_REVARP },
190 { "sprite", ETHERTYPE_SPRITE },
191 { "mopdl", ETHERTYPE_MOPDL },
192 { "moprc", ETHERTYPE_MOPRC },
193 { "decnet", ETHERTYPE_DN },
194 { "lat", ETHERTYPE_LAT },
195 { "sca", ETHERTYPE_SCA },

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

325 }
326 break;
327 }
328 }
329 return (NULL);
330}
331#else
332
224 { "arp", ETHERTYPE_ARP },
225 { "rarp", ETHERTYPE_REVARP },
226 { "sprite", ETHERTYPE_SPRITE },
227 { "mopdl", ETHERTYPE_MOPDL },
228 { "moprc", ETHERTYPE_MOPRC },
229 { "decnet", ETHERTYPE_DN },
230 { "lat", ETHERTYPE_LAT },
231 { "sca", ETHERTYPE_SCA },

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

361 }
362 break;
363 }
364 }
365 return (NULL);
366}
367#else
368
333#ifndef sgi
369#if !defined(sgi) && !defined(__NetBSD__)
334extern int ether_hostton(char *, struct ether_addr *);
335#endif
336
337/* Use the os supplied routines */
338u_char *
339pcap_ether_hostton(const char *name)
340{
341 register u_char *ap;

--- 31 unchanged lines hidden ---
370extern int ether_hostton(char *, struct ether_addr *);
371#endif
372
373/* Use the os supplied routines */
374u_char *
375pcap_ether_hostton(const char *name)
376{
377 register u_char *ap;

--- 31 unchanged lines hidden ---