]>
git.proxmox.com Git - mirror_iproute2.git/blob - lib/ipx_pton.c
1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <sys/socket.h>
6 #include <netinet/in.h>
10 static int ipx_getnet(u_int32_t
*net
, const char *str
)
15 for(i
= 0; *str
&& (i
< 8); i
++) {
17 if ((tmp
= get_hex(*str
)) == -1) {
35 static int ipx_getnode(u_int8_t
*node
, const char *str
)
40 for(i
= 0; i
< 6; i
++) {
41 if ((tmp
= get_hex(*str
++)) == -1)
43 node
[i
] = (u_int8_t
)tmp
;
45 if ((tmp
= get_hex(*str
++)) == -1)
47 node
[i
] |= (u_int8_t
)tmp
;
55 static int ipx_pton1(const char *src
, struct ipx_addr
*addr
)
57 char *sep
= (char *)src
;
60 memset(addr
, 0, sizeof(struct ipx_addr
));
62 while(*sep
&& (*sep
!= '.'))
68 if (ipx_getnet(&addr
->ipx_net
, src
))
71 addr
->ipx_net
= htonl(addr
->ipx_net
);
76 if (ipx_getnode(addr
->ipx_node
, sep
+ 1))
82 int ipx_pton(int af
, const char *src
, void *addr
)
89 err
= ipx_pton1(src
, (struct ipx_addr
*)addr
);