xref: /unit/src/nxt_http_route_addr.h (revision 1324:73562b05bf48)
1*1324Saxel.duch@nginx.com 
2*1324Saxel.duch@nginx.com /*
3*1324Saxel.duch@nginx.com  * Copyright (C) Axel Duch
4*1324Saxel.duch@nginx.com  * Copyright (C) NGINX, Inc.
5*1324Saxel.duch@nginx.com  */
6*1324Saxel.duch@nginx.com 
7*1324Saxel.duch@nginx.com #include <nxt_conf.h>
8*1324Saxel.duch@nginx.com 
9*1324Saxel.duch@nginx.com #ifndef _NXT_HTTP_ROUTE_ADDR_H_INCLUDED_
10*1324Saxel.duch@nginx.com #define _NXT_HTTP_ROUTE_ADDR_H_INCLUDED_
11*1324Saxel.duch@nginx.com 
12*1324Saxel.duch@nginx.com 
13*1324Saxel.duch@nginx.com enum {
14*1324Saxel.duch@nginx.com     NXT_HTTP_ROUTE_ADDR_ANY = 0,
15*1324Saxel.duch@nginx.com     NXT_HTTP_ROUTE_ADDR_RANGE,
16*1324Saxel.duch@nginx.com     NXT_HTTP_ROUTE_ADDR_EXACT,
17*1324Saxel.duch@nginx.com     NXT_HTTP_ROUTE_ADDR_CIDR,
18*1324Saxel.duch@nginx.com };
19*1324Saxel.duch@nginx.com 
20*1324Saxel.duch@nginx.com 
21*1324Saxel.duch@nginx.com enum {
22*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_PORT_ERROR = NXT_OK + 1,
23*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_CV_TYPE_ERROR,
24*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_LENGTH_ERROR,
25*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_FORMAT_ERROR,
26*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_RANGE_OVERLAP_ERROR,
27*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_CIDR_ERROR,
28*1324Saxel.duch@nginx.com     NXT_ADDR_PATTERN_NO_IPv6_ERROR,
29*1324Saxel.duch@nginx.com };
30*1324Saxel.duch@nginx.com 
31*1324Saxel.duch@nginx.com 
32*1324Saxel.duch@nginx.com typedef struct {
33*1324Saxel.duch@nginx.com     in_addr_t  start;
34*1324Saxel.duch@nginx.com     in_addr_t  end;
35*1324Saxel.duch@nginx.com } nxt_http_route_addr_range_t;
36*1324Saxel.duch@nginx.com 
37*1324Saxel.duch@nginx.com 
38*1324Saxel.duch@nginx.com #if (NXT_INET6)
39*1324Saxel.duch@nginx.com typedef struct {
40*1324Saxel.duch@nginx.com     struct in6_addr  start;
41*1324Saxel.duch@nginx.com     struct in6_addr  end;
42*1324Saxel.duch@nginx.com } nxt_http_route_in6_addr_range_t;
43*1324Saxel.duch@nginx.com #endif
44*1324Saxel.duch@nginx.com 
45*1324Saxel.duch@nginx.com 
46*1324Saxel.duch@nginx.com typedef struct {
47*1324Saxel.duch@nginx.com     uint8_t       match_type:2;
48*1324Saxel.duch@nginx.com     uint8_t       negative:1;
49*1324Saxel.duch@nginx.com     uint8_t       addr_family;
50*1324Saxel.duch@nginx.com 
51*1324Saxel.duch@nginx.com     struct {
52*1324Saxel.duch@nginx.com         uint16_t  start;
53*1324Saxel.duch@nginx.com         uint16_t  end;
54*1324Saxel.duch@nginx.com     } port;
55*1324Saxel.duch@nginx.com } nxt_http_route_addr_base_t;
56*1324Saxel.duch@nginx.com 
57*1324Saxel.duch@nginx.com 
58*1324Saxel.duch@nginx.com typedef struct {
59*1324Saxel.duch@nginx.com     nxt_http_route_addr_base_t           base;
60*1324Saxel.duch@nginx.com 
61*1324Saxel.duch@nginx.com     union {
62*1324Saxel.duch@nginx.com         nxt_http_route_addr_range_t      v4;
63*1324Saxel.duch@nginx.com #if (NXT_INET6)
64*1324Saxel.duch@nginx.com         nxt_http_route_in6_addr_range_t  v6;
65*1324Saxel.duch@nginx.com #endif
66*1324Saxel.duch@nginx.com     } addr;
67*1324Saxel.duch@nginx.com } nxt_http_route_addr_pattern_t;
68*1324Saxel.duch@nginx.com 
69*1324Saxel.duch@nginx.com 
70*1324Saxel.duch@nginx.com NXT_EXPORT nxt_int_t nxt_http_route_addr_pattern_parse(nxt_mp_t *mp,
71*1324Saxel.duch@nginx.com     nxt_http_route_addr_pattern_t *pattern, nxt_conf_value_t *cv);
72*1324Saxel.duch@nginx.com 
73*1324Saxel.duch@nginx.com #endif /* _NXT_HTTP_ROUTE_ADDR_H_INCLUDED_ */
74