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