Juraj Sloboda | dd3b8f7 | 2018-05-04 14:20:06 +0200 | [diff] [blame^] | 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 <vnet/dhcp/dhcp6_client_common_dp.h> |
| 21 | #include <vnet/dhcp/dhcp6_packet.h> |
| 22 | #include <vnet/vnet_msg_enum.h> |
| 23 | #include <vlibapi/api_common.h> |
| 24 | #include <vlibmemory/api.h> |
| 25 | |
| 26 | #define vl_typedefs /* define message structures */ |
| 27 | #include <vnet/vnet_all_api_h.h> |
| 28 | #undef vl_typedefs |
| 29 | |
| 30 | #define vl_endianfun /* define message structures */ |
| 31 | #include <vnet/vnet_all_api_h.h> |
| 32 | #undef vl_endianfun |
| 33 | |
| 34 | /* instantiate all the print functions we know about */ |
| 35 | #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) |
| 36 | #define vl_printfun |
| 37 | #include <vnet/vnet_all_api_h.h> |
| 38 | #undef vl_printfun |
| 39 | |
| 40 | #include <vlibapi/api_helper_macros.h> |
| 41 | |
| 42 | typedef struct |
| 43 | { |
| 44 | u32 sw_if_index; |
| 45 | u32 server_index; |
| 46 | u8 msg_type; |
| 47 | u32 T1; |
| 48 | u32 T2; |
| 49 | u16 inner_status_code; |
| 50 | u16 status_code; |
| 51 | u8 preference; |
| 52 | } dhcp6_report_common_t; |
| 53 | |
| 54 | typedef struct |
| 55 | { |
| 56 | u8 *data; |
| 57 | u16 len; |
| 58 | } server_id_t; |
| 59 | |
| 60 | typedef struct |
| 61 | { |
| 62 | server_id_t *server_ids; |
| 63 | } dhcp6_client_common_main_t; |
| 64 | |
| 65 | extern dhcp6_client_common_main_t dhcp6_client_common_main; |
| 66 | |
| 67 | typedef union |
| 68 | { |
| 69 | CLIB_PACKED (struct |
| 70 | { |
| 71 | u16 duid_type; |
| 72 | u16 hardware_type; |
| 73 | u8 lla[6]; |
| 74 | }); |
| 75 | char bin_string[10]; |
| 76 | } dhcpv6_duid_ll_string_t; |
| 77 | |
| 78 | extern dhcpv6_duid_ll_string_t client_duid; |
| 79 | #define CLIENT_DUID_LENGTH sizeof (client_duid) |
| 80 | #define DHCPV6_CLIENT_IAID 1 |
| 81 | |
| 82 | void dhcp6_clients_enable_disable (u8 enable); |
| 83 | u32 server_index_get_or_create (u8 * data, u16 len); |
| 84 | |
| 85 | #define vl_typedefs /* define message structures */ |
| 86 | #include <vnet/vnet_all_api_h.h> |
| 87 | #undef vl_typedefs |
| 88 | |
| 89 | void vl_api_dhcp6_duid_ll_set_t_handler (vl_api_dhcp6_duid_ll_set_t * mp); |
| 90 | |
| 91 | static_always_inline f64 |
| 92 | random_f64_from_to (f64 from, f64 to) |
| 93 | { |
| 94 | static u32 seed = 0; |
| 95 | static u8 seed_set = 0; |
| 96 | if (!seed_set) |
| 97 | { |
| 98 | seed = random_default_seed (); |
| 99 | seed_set = 1; |
| 100 | } |
| 101 | return random_f64 (&seed) * (to - from) + from; |
| 102 | } |
| 103 | |
| 104 | static const ip6_address_t all_dhcp6_relay_agents_and_servers = { |
| 105 | .as_u8 = { |
| 106 | 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02} |
| 108 | }; |
| 109 | |
| 110 | #endif /* included_vnet_dhcp6_client_common_dp_h */ |
| 111 | |
| 112 | /* |
| 113 | * fd.io coding-style-patch-verification: ON |
| 114 | * |
| 115 | * Local Variables: |
| 116 | * eval: (c-set-style "gnu") |
| 117 | * End: |
| 118 | */ |