LCOV - code coverage report
Current view: top level - vnet/ip - ip46_address.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 9 30 30.0 %
Date: 2023-10-26 01:39:38 Functions: 2 4 50.0 %

          Line data    Source code
       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           0 : format_ip46_type (u8 * s, va_list * args)
      20             : {
      21           0 :   ip46_type_t type = va_arg (*args, ip46_type_t);
      22             : 
      23           0 :   switch (type)
      24             :     {
      25           0 :     case IP46_TYPE_IP4:
      26           0 :       return (format (s, "ip4"));
      27           0 :     case IP46_TYPE_IP6:
      28           0 :       return (format (s, "ip6"));
      29           0 :     case IP46_TYPE_ANY:
      30           0 :       return (format (s, "any"));
      31             :     }
      32             : 
      33           0 :   return (format (s, "unknown"));
      34             : }
      35             : 
      36             : void
      37           5 : ip4_address_increment (ip4_address_t * i)
      38             : {
      39           5 :   u32 t = clib_net_to_host_u32 (i->as_u32);
      40           5 :   t++;
      41           5 :   i->as_u32 = clib_net_to_host_u32 (t);
      42           5 : }
      43             : 
      44             : void
      45           0 : ip6_address_increment (ip6_address_t * i)
      46             : {
      47           0 :   u64 tmp = clib_net_to_host_u64 (i->as_u64[1]);
      48             : 
      49           0 :   tmp++;
      50           0 :   i->as_u64[1] = clib_host_to_net_u64 (tmp);
      51             : 
      52           0 :   if (!tmp)
      53             :     {
      54           0 :       tmp = clib_net_to_host_u64 (i->as_u64[0]);
      55           0 :       tmp++;
      56           0 :       i->as_u64[0] = clib_host_to_net_u64 (tmp);
      57             :     }
      58           0 : }
      59             : 
      60             : void
      61           5 : ip46_address_increment (ip46_type_t type, ip46_address_t * ip)
      62             : {
      63           5 :   if (IP46_TYPE_IP4 == type ||
      64           0 :       (IP46_TYPE_ANY == type && ip46_address_is_ip4 (ip)))
      65           5 :     ip4_address_increment (&ip->ip4);
      66             :   else
      67           0 :     ip6_address_increment (&ip->ip6);
      68           5 : }
      69             : 
      70             : /*
      71             :  * fd.io coding-style-patch-verification: ON
      72             :  *
      73             :  * Local Variables:
      74             :  * eval: (c-set-style "gnu")
      75             :  * End:
      76             :  */

Generated by: LCOV version 1.14