xref: /freebsd/contrib/libpcap/pcap/namedb.h (revision afdbf109c6a661a729938f68211054a0a50d38ac)
1a8e07101SRui Paulo /*
2a8e07101SRui Paulo  * Copyright (c) 1994, 1996
3a8e07101SRui Paulo  *	The Regents of the University of California.  All rights reserved.
4a8e07101SRui Paulo  *
5a8e07101SRui Paulo  * Redistribution and use in source and binary forms, with or without
6a8e07101SRui Paulo  * modification, are permitted provided that the following conditions
7a8e07101SRui Paulo  * are met:
8a8e07101SRui Paulo  * 1. Redistributions of source code must retain the above copyright
9a8e07101SRui Paulo  *    notice, this list of conditions and the following disclaimer.
10a8e07101SRui Paulo  * 2. Redistributions in binary form must reproduce the above copyright
11a8e07101SRui Paulo  *    notice, this list of conditions and the following disclaimer in the
12a8e07101SRui Paulo  *    documentation and/or other materials provided with the distribution.
13a8e07101SRui Paulo  * 3. All advertising materials mentioning features or use of this software
14a8e07101SRui Paulo  *    must display the following acknowledgement:
15a8e07101SRui Paulo  *	This product includes software developed by the Computer Systems
16a8e07101SRui Paulo  *	Engineering Group at Lawrence Berkeley Laboratory.
17a8e07101SRui Paulo  * 4. Neither the name of the University nor of the Laboratory may be used
18a8e07101SRui Paulo  *    to endorse or promote products derived from this software without
19a8e07101SRui Paulo  *    specific prior written permission.
20a8e07101SRui Paulo  *
21a8e07101SRui Paulo  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22a8e07101SRui Paulo  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23a8e07101SRui Paulo  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24a8e07101SRui Paulo  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25a8e07101SRui Paulo  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26a8e07101SRui Paulo  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27a8e07101SRui Paulo  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28a8e07101SRui Paulo  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29a8e07101SRui Paulo  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30a8e07101SRui Paulo  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31a8e07101SRui Paulo  * SUCH DAMAGE.
32a8e07101SRui Paulo  */
33a8e07101SRui Paulo 
34a8e07101SRui Paulo #ifndef lib_pcap_namedb_h
35a8e07101SRui Paulo #define lib_pcap_namedb_h
36a8e07101SRui Paulo 
37*afdbf109SJoseph Mingrone #include <stdio.h>		/* FILE */
38*afdbf109SJoseph Mingrone 
39*afdbf109SJoseph Mingrone #include <pcap/funcattrs.h>
40*afdbf109SJoseph Mingrone 
41a8e07101SRui Paulo #ifdef __cplusplus
42a8e07101SRui Paulo extern "C" {
43a8e07101SRui Paulo #endif
44a8e07101SRui Paulo 
45a8e07101SRui Paulo /*
46a8e07101SRui Paulo  * As returned by the pcap_next_etherent()
47a8e07101SRui Paulo  * XXX this stuff doesn't belong in this interface, but this
48a8e07101SRui Paulo  * library already must do name to address translation, so
49a8e07101SRui Paulo  * on systems that don't have support for /etc/ethers, we
50ada6f083SXin LI  * export these hooks since they're already being used by
51ada6f083SXin LI  * some applications (such as tcpdump) and already being
52ada6f083SXin LI  * marked as exported in some OSes offering libpcap (such
53ada6f083SXin LI  * as Debian).
54a8e07101SRui Paulo  */
55a8e07101SRui Paulo struct pcap_etherent {
56a8e07101SRui Paulo 	u_char addr[6];
57a8e07101SRui Paulo 	char name[122];
58a8e07101SRui Paulo };
59a8e07101SRui Paulo #ifndef PCAP_ETHERS_FILE
60a8e07101SRui Paulo #define PCAP_ETHERS_FILE "/etc/ethers"
61a8e07101SRui Paulo #endif
62*afdbf109SJoseph Mingrone 
63*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
64ada6f083SXin LI PCAP_API struct	pcap_etherent *pcap_next_etherent(FILE *);
65*afdbf109SJoseph Mingrone 
66*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
67ada6f083SXin LI PCAP_API u_char *pcap_ether_hostton(const char*);
68*afdbf109SJoseph Mingrone 
69*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
70ada6f083SXin LI PCAP_API u_char *pcap_ether_aton(const char *);
71a8e07101SRui Paulo 
72*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
736f9cba8fSJoseph Mingrone PCAP_API
746f9cba8fSJoseph Mingrone PCAP_DEPRECATED("this is not reentrant; use 'pcap_nametoaddrinfo' instead")
756f9cba8fSJoseph Mingrone bpf_u_int32 **pcap_nametoaddr(const char *);
76*afdbf109SJoseph Mingrone 
77*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_7
78ada6f083SXin LI PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *);
79*afdbf109SJoseph Mingrone 
80*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
81ada6f083SXin LI PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *);
82a8e07101SRui Paulo 
83*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
84ada6f083SXin LI PCAP_API int	pcap_nametoport(const char *, int *, int *);
85*afdbf109SJoseph Mingrone 
86*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_9
87ada6f083SXin LI PCAP_API int	pcap_nametoportrange(const char *, int *, int *, int *);
88*afdbf109SJoseph Mingrone 
89*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
90ada6f083SXin LI PCAP_API int	pcap_nametoproto(const char *);
91*afdbf109SJoseph Mingrone 
92*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_4
93ada6f083SXin LI PCAP_API int	pcap_nametoeproto(const char *);
94*afdbf109SJoseph Mingrone 
95*afdbf109SJoseph Mingrone PCAP_AVAILABLE_0_9
96ada6f083SXin LI PCAP_API int	pcap_nametollc(const char *);
97*afdbf109SJoseph Mingrone 
98a8e07101SRui Paulo /*
99a8e07101SRui Paulo  * If a protocol is unknown, PROTO_UNDEF is returned.
100a8e07101SRui Paulo  * Also, pcap_nametoport() returns the protocol along with the port number.
101*afdbf109SJoseph Mingrone  * If there are ambiguous entries in /etc/services (i.e. domain
102a8e07101SRui Paulo  * can be either tcp or udp) PROTO_UNDEF is returned.
103a8e07101SRui Paulo  */
104a8e07101SRui Paulo #define PROTO_UNDEF		-1
105a8e07101SRui Paulo 
106a8e07101SRui Paulo #ifdef __cplusplus
107a8e07101SRui Paulo }
108a8e07101SRui Paulo #endif
109a8e07101SRui Paulo 
110a8e07101SRui Paulo #endif
111