Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * proxy.h: dhcp proxy |
| 3 | * |
| 4 | * Copyright (c) 2013 Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef included_dhcp_proxy_h |
| 19 | #define included_dhcp_proxy_h |
| 20 | |
| 21 | #include <vnet/vnet.h> |
| 22 | #include <vnet/dhcp/packet.h> |
| 23 | #include <vnet/ethernet/ethernet.h> |
| 24 | #include <vnet/ip/ip.h> |
| 25 | #include <vnet/ip/ip4.h> |
| 26 | #include <vnet/ip/ip4_packet.h> |
| 27 | #include <vnet/pg/pg.h> |
| 28 | #include <vnet/ip/format.h> |
| 29 | #include <vnet/ip/udp.h> |
| 30 | #include <vnet/dhcp/client.h> |
| 31 | |
| 32 | typedef enum { |
| 33 | #define dhcp_proxy_error(n,s) DHCP_PROXY_ERROR_##n, |
| 34 | #include <vnet/dhcp/proxy_error.def> |
| 35 | #undef dhcp_proxy_error |
| 36 | DHCP_PROXY_N_ERROR, |
| 37 | } dhcp_proxy_error_t; |
| 38 | |
| 39 | typedef struct { |
| 40 | u32 oui; |
| 41 | u32 fib_id; |
| 42 | } vss_id; |
| 43 | |
| 44 | typedef union { |
| 45 | u8 as_u8[8]; |
| 46 | vss_id vpn_id; |
| 47 | } vss_info; |
| 48 | |
| 49 | typedef struct { |
| 50 | ip4_address_t dhcp_server; |
| 51 | ip4_address_t dhcp_src_address; |
| 52 | u32 insert_option_82; |
| 53 | u32 server_fib_index; |
| 54 | u32 valid; |
| 55 | } dhcp_server_t; |
| 56 | |
| 57 | typedef struct { |
| 58 | /* Pool of DHCP servers */ |
| 59 | dhcp_server_t * dhcp_servers; |
| 60 | |
| 61 | /* Pool of selected DHCP server. Zero is the default server */ |
| 62 | u32 * dhcp_server_index_by_rx_fib_index; |
| 63 | |
| 64 | /* to drop pkts in server-to-client direction */ |
| 65 | u32 error_drop_node_index; |
| 66 | |
| 67 | vss_info *opt82vss; |
| 68 | |
| 69 | /* hash lookup specific vrf_id -> option 82 vss suboption */ |
| 70 | uword * opt82vss_index_by_vrf_id; |
| 71 | |
| 72 | /* convenience */ |
| 73 | dhcp_client_main_t * dhcp_client_main; |
| 74 | vlib_main_t * vlib_main; |
| 75 | vnet_main_t * vnet_main; |
| 76 | } dhcp_proxy_main_t; |
| 77 | |
| 78 | dhcp_proxy_main_t dhcp_proxy_main; |
| 79 | |
| 80 | int dhcp_proxy_set_server (ip4_address_t *addr, ip4_address_t *src_address, |
| 81 | u32 fib_id, int insert_option_82, int is_del); |
| 82 | |
| 83 | int dhcp_proxy_set_server_2 (ip4_address_t *addr, ip4_address_t *src_address, |
| 84 | u32 rx_fib_id, |
| 85 | u32 server_fib_id, |
| 86 | int insert_option_82, int is_del); |
| 87 | |
| 88 | int dhcp_proxy_set_option82_vss(u32 vrf_id, |
| 89 | u32 oui, |
| 90 | u32 fib_id, |
| 91 | int is_del); |
| 92 | #endif /* included_dhcp_proxy_h */ |