FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ip46_address.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019 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 #include <vnet/ip/ip46_address.h>
17 
18 u8 *
19 format_ip46_type (u8 * s, va_list * args)
20 {
21  ip46_type_t type = va_arg (*args, ip46_type_t);
22 
23  switch (type)
24  {
25  case IP46_TYPE_IP4:
26  return (format (s, "ip4"));
27  case IP46_TYPE_IP6:
28  return (format (s, "ip6"));
29  case IP46_TYPE_ANY:
30  return (format (s, "any"));
31  }
32 
33  return (format (s, "unknown"));
34 }
35 
36 void
38 {
39  u32 t = clib_net_to_host_u32 (i->as_u32);
40  t++;
41  i->as_u32 = clib_net_to_host_u32 (t);
42 }
43 
44 void
45 ip6_address_increment (ip6_address_t * i)
46 {
47  u64 tmp = clib_net_to_host_u64 (i->as_u64[1]);
48 
49  tmp++;
50  i->as_u64[1] = clib_host_to_net_u64 (tmp);
51 
52  if (!tmp)
53  {
54  tmp = clib_net_to_host_u64 (i->as_u64[0]);
55  tmp++;
56  i->as_u64[0] = clib_host_to_net_u64 (tmp);
57  }
58 }
59 
60 void
62 {
63  if (IP46_TYPE_IP4 == type ||
65  ip4_address_increment (&ip->ip4);
66  else
67  ip6_address_increment (&ip->ip6);
68 }
69 
70 /*
71  * fd.io coding-style-patch-verification: ON
72  *
73  * Local Variables:
74  * eval: (c-set-style "gnu")
75  * End:
76  */
tmp
u32 * tmp
Definition: interface_output.c:1078
ip46_address_increment
void ip46_address_increment(ip46_type_t type, ip46_address_t *ip)
Definition: ip46_address.c:61
ip6_address_increment
void ip6_address_increment(ip6_address_t *i)
Definition: ip46_address.c:45
ip46_address_is_ip4
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
Definition: ip46_address.h:55
IP46_TYPE_IP4
@ IP46_TYPE_IP4
Definition: ip46_address.h:26
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
ip4_address_t
Definition: ip4_packet.h:50
IP46_TYPE_IP6
@ IP46_TYPE_IP6
Definition: ip46_address.h:27
ip4_address_increment
void ip4_address_increment(ip4_address_t *i)
Definition: ip46_address.c:37
ip46_address.h
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
u32
unsigned int u32
Definition: types.h:88
u8
unsigned char u8
Definition: types.h:56
ip
vl_api_address_t ip
Definition: l2.api:558
ip46_type_t
ip46_type_t
Definition: ip46_address.h:22
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
format_ip46_type
u8 * format_ip46_type(u8 *s, va_list *args)
Definition: ip46_address.c:19
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123