#include <string.h>
#include "pcap-int.h"
+#include "nametoaddr.h"
#include <pcap/namedb.h>
static inline int skip_space(FILE *);
static inline int skip_line(FILE *);
-/* Hex digit to integer. */
-static inline u_char
-xdtoi(u_char c)
-{
- if (c >= '0' && c <= '9')
- return (u_char)(c - '0');
- else if (c >= 'a' && c <= 'f')
- return (u_char)(c - 'a' + 10);
- else
- return (u_char)(c - 'A' + 10);
-}
-
/*
* Skip linear white space (space and tab) and any CRs before LF.
* Stop when we hit a non-white-space character or an end-of-line LF.
/* must be the start of an address */
for (i = 0; i < 6; i += 1) {
- d = xdtoi((u_char)c);
+ d = pcapint_xdtoi((u_char)c);
c = getc(fp);
if (c == EOF)
return (NULL);
if (PCAP_ISXDIGIT(c)) {
d <<= 4;
- d |= xdtoi((u_char)c);
+ d |= pcapint_xdtoi((u_char)c);
c = getc(fp);
if (c == EOF)
return (NULL);
if (setjmp(cstate->top_ctx))
return (NULL);
- nlen = __pcap_atoin(s1, &n);
+ nlen = pcapint_atoin(s1, &n);
if (nlen < 0)
bpf_error(cstate, "invalid IPv4 address '%s'", s1);
/* Promote short ipaddr */
n <<= 32 - nlen;
if (s2 != NULL) {
- mlen = __pcap_atoin(s2, &m);
+ mlen = pcapint_atoin(s2, &m);
if (mlen < 0)
bpf_error(cstate, "invalid IPv4 address '%s'", s2);
/* Promote short ipaddr */
* {N}.{N}.{N}.{N}, of which only the first potentially stands
* for a valid DECnet address.
*/
- vlen = __pcap_atodn(s, &v);
+ vlen = pcapint_atodn(s, &v);
if (vlen == 0)
bpf_error(cstate, "invalid DECnet address '%s'", s);
} else {
* {N}.{N}.{N}.{N}, all of which potentially stand for a valid
* IPv4 address.
*/
- vlen = __pcap_atoin(s, &v);
+ vlen = pcapint_atoin(s, &v);
if (vlen < 0)
bpf_error(cstate, "invalid IPv4 address '%s'", s);
}
}
/* Hex digit to 8-bit unsigned integer. */
-static inline u_char
-xdtoi(u_char c)
+u_char
+pcapint_xdtoi(const u_char c)
{
if (c >= '0' && c <= '9')
return (u_char)(c - '0');
}
int
-__pcap_atoin(const char *s, bpf_u_int32 *addr)
+pcapint_atoin(const char *s, bpf_u_int32 *addr)
{
u_int n;
int len;
* normal addressing purposes, but either can appear on the wire.
*/
int
-__pcap_atodn(const char *s, bpf_u_int32 *addr)
+pcapint_atodn(const char *s, bpf_u_int32 *addr)
{
#define AREASHIFT 10
#define AREAMASK 0176000
while (*s) {
if (*s == ':' || *s == '.' || *s == '-')
s += 1;
- d = xdtoi(*s++);
+ d = pcapint_xdtoi(*s++);
if (PCAP_ISXDIGIT(*s)) {
d <<= 4;
- d |= xdtoi(*s++);
+ d |= pcapint_xdtoi(*s++);
}
*ep++ = d;
}
* SUCH DAMAGE.
*/
+#ifndef nametoaddr_h_
+#define nametoaddr_h_
+
#ifdef __cplusplus
extern "C" {
#endif
* Routines used for name-or-address-string-to-address resolution
* that are *not* exported to code using libpcap.
*/
-int __pcap_atodn(const char *, bpf_u_int32 *);
-int __pcap_atoin(const char *, bpf_u_int32 *);
+extern int pcapint_atodn(const char *, bpf_u_int32 *);
+extern int pcapint_atoin(const char *, bpf_u_int32 *);
+extern u_char pcapint_xdtoi(const u_char);
#ifdef __cplusplus
}
#endif
+
+#endif // nametoaddr_h_