Line data Source code
1 : /* 2 : * Copyright (c) 2018 Cisco and/or its affiliates. 3 : * Licensed under the Apache License, Version 2.0 (the "License"); 4 : * you may not use this file except in compliance with the License. 5 : * You may obtain a copy of the License at: 6 : * 7 : * http://www.apache.org/licenses/LICENSE-2.0 8 : * 9 : * Unless required by applicable law or agreed to in writing, software 10 : * distributed under the License is distributed on an "AS IS" BASIS, 11 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : * See the License for the specific language governing permissions and 13 : * limitations under the License. 14 : */ 15 : 16 : #ifndef included_vnet_dhcp6_client_common_dp_h 17 : #define included_vnet_dhcp6_client_common_dp_h 18 : 19 : #include <vlib/vlib.h> 20 : #include <dhcp/dhcp6_packet.h> 21 : 22 : typedef struct 23 : { 24 : u32 sw_if_index; 25 : u32 server_index; 26 : u8 msg_type; 27 : u32 T1; 28 : u32 T2; 29 : u16 inner_status_code; 30 : u16 status_code; 31 : u8 preference; 32 : } dhcp6_report_common_t; 33 : 34 : typedef struct 35 : { 36 : u8 *data; 37 : u16 len; 38 : } server_id_t; 39 : 40 : typedef struct 41 : { 42 : server_id_t *server_ids; 43 : } dhcp6_client_common_main_t; 44 : 45 : extern dhcp6_client_common_main_t dhcp6_client_common_main; 46 : 47 : typedef union 48 : { 49 : CLIB_PACKED (struct 50 : { 51 : u16 duid_type; 52 : u16 hardware_type; 53 : u8 lla[6]; 54 : }); 55 : char bin_string[10]; 56 : } dhcpv6_duid_ll_string_t; 57 : 58 : extern dhcpv6_duid_ll_string_t client_duid; 59 : #define CLIENT_DUID_LENGTH sizeof (client_duid) 60 : #define DHCPV6_CLIENT_IAID 1 61 : 62 : void dhcp6_clients_enable_disable (u8 enable); 63 : u32 server_index_get_or_create (u8 * data, u16 len); 64 : 65 : extern dhcpv6_duid_ll_string_t client_duid; 66 : 67 : static_always_inline f64 68 76 : random_f64_from_to (f64 from, f64 to) 69 : { 70 : static u32 seed = 0; 71 : static u8 seed_set = 0; 72 76 : if (!seed_set) 73 : { 74 4 : seed = random_default_seed (); 75 4 : seed_set = 1; 76 : } 77 76 : return random_f64 (&seed) * (to - from) + from; 78 : } 79 : 80 : static const ip6_address_t all_dhcp6_relay_agents_and_servers = { 81 : .as_u8 = { 82 : 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02} 84 : }; 85 : 86 : #endif /* included_vnet_dhcp6_client_common_dp_h */ 87 : 88 : /* 89 : * fd.io coding-style-patch-verification: ON 90 : * 91 : * Local Variables: 92 : * eval: (c-set-style "gnu") 93 : * End: 94 : */