namedb.h revision 190225
1184610Salfred/*
2184610Salfred * Copyright (c) 1994, 1996
3184610Salfred *	The Regents of the University of California.  All rights reserved.
4184610Salfred *
5184610Salfred * Redistribution and use in source and binary forms, with or without
6184610Salfred * modification, are permitted provided that the following conditions
7184610Salfred * are met:
8184610Salfred * 1. Redistributions of source code must retain the above copyright
9184610Salfred *    notice, this list of conditions and the following disclaimer.
10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright
11184610Salfred *    notice, this list of conditions and the following disclaimer in the
12184610Salfred *    documentation and/or other materials provided with the distribution.
13184610Salfred * 3. All advertising materials mentioning features or use of this software
14184610Salfred *    must display the following acknowledgement:
15184610Salfred *	This product includes software developed by the Computer Systems
16184610Salfred *	Engineering Group at Lawrence Berkeley Laboratory.
17184610Salfred * 4. Neither the name of the University nor of the Laboratory may be used
18184610Salfred *    to endorse or promote products derived from this software without
19184610Salfred *    specific prior written permission.
20184610Salfred *
21184610Salfred * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24184610Salfred * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26184610Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27184610Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29194230Sthompsa * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30194230Sthompsa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31184610Salfred * SUCH DAMAGE.
32188942Sthompsa *
33187994Salfred * @(#) $Header: /tcpdump/master/libpcap/pcap/namedb.h,v 1.1 2006/10/04 18:09:22 guy Exp $ (LBL)
34184610Salfred */
35184610Salfred
36184610Salfred#ifndef lib_pcap_namedb_h
37184610Salfred#define lib_pcap_namedb_h
38184610Salfred
39184610Salfred#ifdef __cplusplus
40184610Salfredextern "C" {
41184610Salfred#endif
42184610Salfred
43184610Salfred/*
44184610Salfred * As returned by the pcap_next_etherent()
45184610Salfred * XXX this stuff doesn't belong in this interface, but this
46192984Sthompsa * library already must do name to address translation, so
47184610Salfred * on systems that don't have support for /etc/ethers, we
48184610Salfred * export these hooks since they'll
49184610Salfred */
50184610Salfredstruct pcap_etherent {
51184610Salfred	u_char addr[6];
52184610Salfred	char name[122];
53184610Salfred};
54184610Salfred#ifndef PCAP_ETHERS_FILE
55184610Salfred#define PCAP_ETHERS_FILE "/etc/ethers"
56184610Salfred#endif
57184610Salfredstruct	pcap_etherent *pcap_next_etherent(FILE *);
58184610Salfredu_char *pcap_ether_hostton(const char*);
59184610Salfredu_char *pcap_ether_aton(const char *);
60184610Salfred
61184610Salfredbpf_u_int32 **pcap_nametoaddr(const char *);
62184610Salfred#ifdef INET6
63184610Salfredstruct addrinfo *pcap_nametoaddrinfo(const char *);
64184610Salfred#endif
65184610Salfredbpf_u_int32 pcap_nametonetaddr(const char *);
66184610Salfred
67184610Salfredint	pcap_nametoport(const char *, int *, int *);
68184610Salfredint	pcap_nametoportrange(const char *, int *, int *, int *);
69184610Salfredint	pcap_nametoproto(const char *);
70184610Salfredint	pcap_nametoeproto(const char *);
71184610Salfredint	pcap_nametollc(const char *);
72184610Salfred/*
73184610Salfred * If a protocol is unknown, PROTO_UNDEF is returned.
74184610Salfred * Also, pcap_nametoport() returns the protocol along with the port number.
75184610Salfred * If there are ambiguous entried in /etc/services (i.e. domain
76184610Salfred * can be either tcp or udp) PROTO_UNDEF is returned.
77184610Salfred */
78184610Salfred#define PROTO_UNDEF		-1
79184610Salfred
80184610Salfred/* XXX move these to pcap-int.h? */
81184610Salfredint __pcap_atodn(const char *, bpf_u_int32 *);
82184610Salfredint __pcap_atoin(const char *, bpf_u_int32 *);
83184610Salfredu_short	__pcap_nametodnaddr(const char *);
84184610Salfred
85184610Salfred#ifdef __cplusplus
86184610Salfred}
87184610Salfred#endif
88184610Salfred
89184610Salfred#endif
90184610Salfred