]>
git.proxmox.com Git - mirror_iproute2.git/blob - lib/dnet_pton.c
3 #include <netinet/in.h>
7 static __inline__ u_int16_t
dn_htons(u_int16_t addr
)
15 return ((u_int16_t
)u
.byte
[0]) | (((u_int16_t
)u
.byte
[1]) << 8);
19 static int dnet_num(const char *src
, u_int16_t
* dst
)
25 while ((tmp
= *src
++) != 0) {
27 if ((tmp
< 0) || (tmp
> 9))
38 static int dnet_pton1(const char *src
, struct dn_naddr
*dna
)
44 pos
= dnet_num(src
, &area
);
45 if ((pos
== 0) || (area
> 63) || (*(src
+ pos
) != '.'))
47 pos
= dnet_num(src
+ pos
+ 1, &node
);
48 if ((pos
== 0) || (node
> 1023))
51 *(u_int16_t
*)dna
->a_addr
= dn_htons((area
<< 10) | node
);
56 int dnet_pton(int af
, const char *src
, void *addr
)
63 err
= dnet_pton1(src
, (struct dn_naddr
*)addr
);