Annotation of embedaddon/mpd/src/ip.h, revision 1.1.1.3
1.1 misho 1:
2: /*
3: * ip.h
4: *
5: * Written by Alexander Motin <mav@FreeBSD.org>
6: */
7:
8: #ifndef _IP_H_
9: #define _IP_H_
10:
11: #include <sys/types.h>
12: #include <sys/param.h>
1.1.1.3 ! misho 13: #include <netinet/in.h>
1.1 misho 14: #include <netinet/in_systm.h>
15: #include <netinet/ip.h>
16:
17: /*
18: * DEFINITIONS
19: */
20:
21: struct u_addr {
22: sa_family_t family;
23: union {
24: struct in_addr ip4;
25: struct in6_addr ip6;
26: } u;
27: };
28:
29: struct u_range {
30: struct u_addr addr;
31: u_char width;
32: };
33:
34: enum {
35: ALLOW_IPV4=1,
36: ALLOW_IPV6,
37: ALLOW_MASK
38: };
39:
40: /*
41: * FUNCTIONS
42: */
43:
1.1.1.3 ! misho 44: extern int IpShowRoutes(Context ctx, int ac, const char *const av[], const void *arg);
1.1 misho 45: extern int IpAddrInRange(struct u_range *range, struct u_addr *addr);
46:
47: extern int ParseAddr(const char *s, struct u_addr *addr, u_char allow);
48: extern int ParseRange(const char *s, struct u_range *range, u_char allow);
1.1.1.3 ! misho 49: extern struct sockaddr_storage * ParseAddrPort(int ac, const char *const av[], u_char allow);
1.1 misho 50:
51: extern sa_family_t u_addrfamily(struct u_addr *addr);
52: extern sa_family_t u_rangefamily(struct u_range *range);
53:
54: extern char *u_addrtoa(struct u_addr *addr, char *dst, size_t size);
55: extern char *u_rangetoa(struct u_range *range, char *dst, size_t size);
56:
1.1.1.2 misho 57: extern void u_addrcopy(const struct u_addr *src, struct u_addr *dst);
58: extern void u_rangecopy(const struct u_range *src, struct u_range *dst);
1.1 misho 59:
1.1.1.2 misho 60: extern void in_addrtou_addr(const struct in_addr *src, struct u_addr *dst);
61: extern void in6_addrtou_addr(const struct in6_addr *src, struct u_addr *dst);
1.1 misho 62:
1.1.1.2 misho 63: extern void u_addrtoin_addr(const struct u_addr *src, struct in_addr *dst);
64: extern void u_addrtoin6_addr(const struct u_addr *src, struct in6_addr *dst);
1.1 misho 65:
1.1.1.2 misho 66: extern void in_addrtou_range(const struct in_addr *src, u_char width, struct u_range *dst);
67: extern void in6_addrtou_range(const struct in6_addr *src, u_char width, struct u_range *dst);
1.1 misho 68:
1.1.1.2 misho 69: extern void u_rangetosockaddrs(struct u_range *range, struct sockaddr_storage *dst, struct sockaddr_storage *msk);
70: extern void u_addrtosockaddr(struct u_addr *addr, in_port_t port, struct sockaddr_storage *dst);
71: extern void sockaddrtou_addr(struct sockaddr_storage *src, struct u_addr *addr, in_port_t *port);
1.1 misho 72:
1.1.1.2 misho 73: extern void u_addrclear(struct u_addr *addr);
74: extern void u_rangeclear(struct u_range *range);
1.1 misho 75:
76: extern int u_addrempty(struct u_addr *addr);
77: extern int u_rangeempty(struct u_range *range);
78: extern int u_rangehost(struct u_range *range);
79:
80: extern int u_addrcompare(const struct u_addr *addr1, const struct u_addr *addr2);
81: extern int u_rangecompare(const struct u_range *range1, const struct u_range *range2);
82:
83: extern uint32_t u_addrtoid(const struct u_addr *addr);
84:
85: extern u_char in_addrtowidth(struct in_addr *mask);
86: extern struct in_addr *widthtoin_addr(u_char width, struct in_addr *mask);
87:
88: #endif
89:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>