Both nametoaddr.c and etherent.c are always compiled and each has an
identical static copy of xdtoi(). Rename the function to
pcapint_xdtoi(), leave only one copy in nametoaddr.c and add a
declaration to nametoaddr.h.
Rename __pcap_atoin() to pcapint_atoin(), rename __pcap_atodn() to
pcapint_atodn(). Add a header guard to nametoaddr.h.
#include <string.h>
#include "pcap-int.h"
#include <string.h>
#include "pcap-int.h"
static inline int skip_space(FILE *);
static inline int skip_line(FILE *);
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.
/*
* 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) {
/* must be the start of an address */
for (i = 0; i < 6; i += 1) {
+ d = pcapint_xdtoi((u_char)c);
c = getc(fp);
if (c == EOF)
return (NULL);
if (PCAP_ISXDIGIT(c)) {
d <<= 4;
c = getc(fp);
if (c == EOF)
return (NULL);
if (PCAP_ISXDIGIT(c)) {
d <<= 4;
+ d |= pcapint_xdtoi((u_char)c);
c = getc(fp);
if (c == EOF)
return (NULL);
c = getc(fp);
if (c == EOF)
return (NULL);
if (setjmp(cstate->top_ctx))
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) {
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 */
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.
*/
* {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 {
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.
*/
* {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);
}
if (vlen < 0)
bpf_error(cstate, "invalid IPv4 address '%s'", s);
}
}
/* Hex digit to 8-bit unsigned integer. */
}
/* 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');
{
if (c >= '0' && c <= '9')
return (u_char)(c - '0');
-__pcap_atoin(const char *s, bpf_u_int32 *addr)
+pcapint_atoin(const char *s, bpf_u_int32 *addr)
* normal addressing purposes, but either can appear on the wire.
*/
int
* 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
{
#define AREASHIFT 10
#define AREAMASK 0176000
while (*s) {
if (*s == ':' || *s == '.' || *s == '-')
s += 1;
while (*s) {
if (*s == ':' || *s == '.' || *s == '-')
s += 1;
+ d = pcapint_xdtoi(*s++);
if (PCAP_ISXDIGIT(*s)) {
d <<= 4;
if (PCAP_ISXDIGIT(*s)) {
d <<= 4;
+ d |= pcapint_xdtoi(*s++);
+#ifndef nametoaddr_h_
+#define nametoaddr_h_
+
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
extern "C" {
#endif
* Routines used for name-or-address-string-to-address resolution
* that are *not* exported to code using libpcap.
*/
* 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
#ifdef __cplusplus
}
#endif
+
+#endif // nametoaddr_h_