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