2 * Definitions for network object lookup
6 * Laurent Deniel <laurent.deniel@free.fr>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 /* The buffers returned by these functions are all allocated with a
27 * packet lifetime and does not have have to be freed.
28 * However, take into account that when the packet dissection
29 * completes, these buffers will be automatically reclaimed/freed.
30 * If you need the buffer to remain for a longer scope than packet lifetime
31 * you must copy the content to an se_alloc() buffer.
37 #include <epan/address.h>
41 #endif /* __cplusplus */
44 #define MAXNAMELEN 64 /* max name length (hostname and port name) */
48 * Flag controlling what names to resolve.
50 WS_VAR_IMPORT guint32 g_resolv_flags;
52 /* 32 types are sufficient (as are 640k of RAM) */
53 /* FIXME: Maybe MANUF/m, IP/i, IP6/6, IPX/x, UDP+TCP/t etc would be
54 more useful/consistent */
55 #define RESOLV_NONE 0x0
56 #define RESOLV_MAC 0x1
57 #define RESOLV_NETWORK 0x2
58 #define RESOLV_TRANSPORT 0x4
59 #define RESOLV_CONCURRENT 0x8
61 #define RESOLV_ALL_ADDRS (RESOLV_MAC|RESOLV_NETWORK|RESOLV_TRANSPORT)
62 #define RESOLV_ALL 0xFFFFFFFF
64 /* global variables */
66 extern gchar *g_ethers_path;
67 extern gchar *g_ipxnets_path;
68 extern gchar *g_pethers_path;
69 extern gchar *g_pipxnets_path;
71 /* Functions in resolv.c */
73 /* Set the flags controlling what names to resolve */
74 extern void resolv_set_flags(guint32 flags);
77 * get_udp_port() returns the port name corresponding to that UDP port,
78 * or the port number as a string if not found.
80 extern gchar *get_udp_port(guint port);
83 * get_tcp_port() returns the port name corresponding to that TCP port,
84 * or the port number as a string if not found.
86 extern gchar *get_tcp_port(guint port);
89 * get_dccp_port() returns the port name corresponding to that DCCP port,
90 * or the port number as a string if not found.
92 extern gchar *get_dccp_port(guint port);
95 * get_sctp_port() returns the port name corresponding to that SCTP port,
96 * or the port number as a string if not found.
98 extern gchar *get_sctp_port(guint port);
100 /* get_addr_name takes as input an "address", as defined in address.h */
101 /* it returns a string that contains: */
102 /* - if the address is of a type that can be translated into a name, and the user */
103 /* has activated name resolution, the translated name */
104 /* - if the address is of type AT_NONE, a pointer to the string "NONE" */
105 /* - if the address is of any other type, the result of address_to_str on the argument, */
106 /* which should be a string representation for the answer -e.g. "10.10.10.10" for IPv4 */
107 /* address 10.10.10.10 */
109 const gchar *get_addr_name(address *addr);
111 /* get_addr_name_buf solves an address in the same way as get_addr_name above */
112 /* The difference is that get_addr_name_buf takes as input a buffer, in which it puts */
113 /* the result, and a maximum string length -size-. the buffer should be large enough to */
114 /* contain size characters plus the terminator */
116 void get_addr_name_buf(address *addr, gchar *buf, guint size);
120 * Asynchronous host name lookup initialization, processing, and cleanup
123 /* host_name_lookup_init fires up an ADNS socket if we're using ADNS */
124 extern void host_name_lookup_init(void);
126 /* host_name_lookup_process does ADNS processing in GTK+ timeouts in Wireshark,
127 and before processing each packet in TShark, if we're using ADNS */
128 extern gint host_name_lookup_process(gpointer data);
130 /* host_name_lookup_cleanup cleans up an ADNS socket if we're using ADNS */
131 extern void host_name_lookup_cleanup(void);
133 /* get_hostname returns the host name or "%d.%d.%d.%d" if not found */
134 extern gchar *get_hostname(guint addr);
136 /* get_hostname6 returns the host name, or numeric addr if not found */
138 const gchar* get_hostname6(struct e_in6_addr *ad);
140 /* get_ether_name returns the logical name if found in ethers files else
141 "<vendor>_%02x:%02x:%02x" if the vendor code is known else
142 "%02x:%02x:%02x:%02x:%02x:%02x" */
143 extern gchar *get_ether_name(const guint8 *addr);
145 /* get_ether_name returns the logical name if found in ethers files else NULL */
146 extern gchar *get_ether_name_if_known(const guint8 *addr);
148 /* get_manuf_name returns the vendor name or "%02x:%02x:%02x" if not known */
149 extern const gchar *get_manuf_name(const guint8 *addr);
151 /* get_manuf_name returns the vendor name or NULL if not known */
152 extern const gchar *get_manuf_name_if_known(const guint8 *addr);
154 /* get_ipxnet_name returns the logical name if found in an ipxnets file,
155 * or a string formatted with "%X" if not */
156 extern const gchar *get_ipxnet_name(const guint32 addr);
158 /* returns the ethernet address corresponding to name or NULL if not known */
159 extern guint8 *get_ether_addr(const gchar *name);
161 /* returns the ipx network corresponding to name. If name is unknown,
162 * 0 is returned and 'known' is set to FALSE. On success, 'known'
164 guint32 get_ipxnet_addr(const gchar *name, gboolean *known);
166 /* adds a hostname/IPv4 in the hash table */
167 extern void add_ipv4_name(guint addr, const gchar *name);
169 /* adds a hostname/IPv6 in the hash table */
170 extern void add_ipv6_name(struct e_in6_addr *addr, const gchar *name);
172 /* add ethernet address / name corresponding to IP address */
173 extern void add_ether_byip(guint ip, const guint8 *eth);
175 /* Translates a string representing the hostname or dotted-decimal IP address
176 * into a numeric IP address value, returning TRUE if it succeeds and
177 * FALSE if it fails. */
178 gboolean get_host_ipaddr(const char *host, guint32 *addrp);
181 * Translate IPv6 numeric address or FQDN hostname, into binary IPv6 address.
182 * Return TRUE if we succeed and set "*addrp" to that numeric IP address;
183 * return FALSE if we fail.
185 gboolean get_host_ipaddr6(const char *host, struct e_in6_addr *addrp);
188 * Find out whether a hostname resolves to an ip or ipv6 address
189 * Return "ip6" if it is IPv6, "ip" otherwise (including the case
190 * that we don't know)
192 const char* host_ip_af(const char *host);
196 #endif /* __cplusplus */
198 #endif /* __RESOLV_H__ */