4 #include <netinet/in.h>
8 static u_int32_t hexget(char c)
10 if (c >= 'A' && c <= 'F')
12 if (c >= 'a' && c <= 'f')
14 if (c >= '0' && c <= '9')
20 static int ipx_getnet(u_int32_t *net, const char *str)
25 for(i = 0; *str && (i < 8); i++) {
27 if ((tmp = hexget(*str)) & 0xf0) {
45 static int ipx_getnode(u_int8_t *node, const char *str)
50 for(i = 0; i < 6; i++) {
51 if ((tmp = hexget(*str++)) & 0xf0)
53 node[i] = (u_int8_t)tmp;
55 if ((tmp = hexget(*str++)) & 0xf0)
57 node[i] |= (u_int8_t)tmp;
65 static int ipx_pton1(const char *src, struct ipx_addr *addr)
67 char *sep = (char *)src;
70 memset(addr, 0, sizeof(struct ipx_addr));
72 while(*sep && (*sep != '.'))
78 if (ipx_getnet(&addr->ipx_net, src))
81 addr->ipx_net = htonl(addr->ipx_net);
86 if (ipx_getnode(addr->ipx_node, sep + 1))
92 int ipx_pton(int af, const char *src, void *addr)
99 err = ipx_pton1(src, (struct ipx_addr *)addr);
102 errno = EAFNOSUPPORT;