FD.io VPP  v21.01.1
Vector Packet Processing
dhcp6_client_common_dp.h
Go to the documentation of this file.
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 {
33 
34 typedef struct
35 {
36  u8 *data;
38 } server_id_t;
39 
40 typedef struct
41 {
44 
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];
57 
59 #define CLIENT_DUID_LENGTH sizeof (client_duid)
60 #define DHCPV6_CLIENT_IAID 1
61 
62 void dhcp6_clients_enable_disable (u8 enable);
64 
66 
69 {
70  static u32 seed = 0;
71  static u8 seed_set = 0;
72  if (!seed_set)
73  {
74  seed = random_default_seed ();
75  seed_set = 1;
76  }
77  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  */
static uword random_default_seed(void)
Default random seed (unix/linux user-mode)
Definition: random.h:91
unsigned char u8
Definition: types.h:56
u8 data[128]
Definition: ipsec_types.api:90
double f64
Definition: types.h:142
#define static_always_inline
Definition: clib.h:109
dhcpv6_duid_ll_string_t client_duid
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
dhcp6_client_common_main_t dhcp6_client_common_main
u8 len
Definition: ip_types.api:103
void dhcp6_clients_enable_disable(u8 enable)
u32 server_index_get_or_create(u8 *data, u16 len)
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
Definition: random.h:145
static const ip6_address_t all_dhcp6_relay_agents_and_servers
#define CLIB_PACKED(x)
Definition: clib.h:86
static_always_inline f64 random_f64_from_to(f64 from, f64 to)