aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/srv6-as/as.h
blob: 8f05918715109fd28001461670074af375d76a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __included_srv6_as_h__
#define __included_srv6_as_h__

#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/srv6/sr.h>
#include <vnet/srv6/sr_packet.h>

#include <vppinfra/error.h>
#include <vppinfra/elog.h>

#define DA_IP4 4
#define DA_IP6 6

typedef struct
{
  u16 msg_id_base;			/**< API message ID base */

  vlib_main_t *vlib_main;		/**< [convenience] vlib main */
  vnet_main_t *vnet_main;		/**< [convenience] vnet main */

  dpo_type_t srv6_as_dpo_type;		/**< DPO type */

  u32 srv6_localsid_behavior_id;	/**< SRv6 LocalSID behavior number */

  u32 *sw_iface_localsid4;		/**< Retrieve local SID from iface */
  u32 *sw_iface_localsid6;		/**< Retrieve local SID from iface */
} srv6_as_main_t;

/*
 * This is the memory that will be stored per each localsid
 * the user instantiates
 */
typedef struct
{
  ip46_address_t nh_addr;		/**< Proxied device address */
  u32 sw_if_index_out;			/**< Outgoing iface to proxied dev. */
  u32 nh_adj;				/**< Adjacency index for out. iface */
  u8 ip_version;

  u32 sw_if_index_in;			/**< Incoming iface from proxied dev. */
  u8 *rewrite;				/**< Headers to be rewritten */
  ip6_address_t src_addr;		/**< Source address to be restored */
  ip6_address_t *sid_list;		/**< SID list to be restored */
  char *sid_list_str;
} srv6_as_localsid_t;

srv6_as_main_t srv6_as_main;

format_function_t format_srv6_as_localsid;
unformat_function_t unformat_srv6_as_localsid;

void srv6_as_dpo_lock (dpo_id_t * dpo);
void srv6_as_dpo_unlock (dpo_id_t * dpo);

extern vlib_node_registration_t srv6_as_localsid_node;

#endif /* __included_srv6_as_h__ */

/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
an>tb); /* Test it */ now = clib_timebase_now (tb); /* show current time */ fformat (stdout, "Current time in UTC%f, US daylight time rules:\n", tb->timezone_offset / 3600.0); fformat (stdout, "%U", format_clib_timebase_time, now); /* Test conversion to component structure */ clib_timebase_time_to_components (now, cp); now = clib_timebase_components_to_time (cp); fformat (stdout, " -> %U\n", format_clib_timebase_time, now); /* * test a few other dates, to verify summer time operation * 2011: started sunday 3/13, ended sunday 11/6 */ fformat (stdout, "Test daylight time rules:\n"); clib_memset (cp, 0, sizeof (*cp)); /* Just before DST starts */ cp->year = 2011; cp->month = 2; cp->day = 13; cp->hour = 1; cp->minute = 59; cp->second = 59; then = clib_timebase_components_to_time (cp); timezone_offset = clib_timebase_summer_offset_fastpath (tb, then); fformat (stdout, "%U should not be in DST, and it %s\n", format_clib_timebase_time, then, (timezone_offset != 0.0) ? "is" : "is not"); /* add two seconds */ then += 2.0; timezone_offset = clib_timebase_summer_offset_fastpath (tb, then); fformat (stdout, "%U should be in DST, and it %s\n", format_clib_timebase_time, then, (timezone_offset != 0.0) ? "is" : "is not"); /* Just before DST ends */ cp->year = 2011; cp->month = 10; cp->day = 6; cp->hour = 1; cp->minute = 59; cp->second = 59; then = clib_timebase_components_to_time (cp); timezone_offset = clib_timebase_summer_offset_fastpath (tb, then); fformat (stdout, "%U should be in DST, and it %s\n", format_clib_timebase_time, then, (timezone_offset != 0.0) ? "is" : "is not"); /* add two seconds. */ then += 2.0; timezone_offset = clib_timebase_summer_offset_fastpath (tb, then); fformat (stdout, "%U should not be in DST, and it %s\n", format_clib_timebase_time, then, (timezone_offset != 0.0) ? "is" : "is not"); /* Back to the future... */ clib_timebase_time_to_components (now, cp); fformat (stdout, "Test time range calculations:\n"); /* Find previous Sunday midnight */ sunday_midnight = now = clib_timebase_find_sunday_midnight (now); clib_timebase_time_to_components (now, cp); fformat (stdout, "Sunday midnight: %U\n", format_clib_timebase_time, now); test_range_string = "Mon 11 - 17 Tue 7 - 11 Wed - Fri 8 - 18"; unformat_init_string (input2, test_range_string, strlen (test_range_string)); if (unformat (input2, "%U", unformat_clib_timebase_range_vector, &rp)) { vec_foreach (this_rp, rp) { start_time = sunday_midnight + this_rp->start; end_time = sunday_midnight + this_rp->end; fformat (stdout, "range: %U - %U\n", format_clib_timebase_time, start_time, format_clib_timebase_time, end_time); } vec_free (rp); } else { fformat (stdout, "Time convert fail!\n"); } unformat_free (input2); clib_mem_free (tb->clib_time); return 0; } /* * GDB callable function: vl - Return vector length of vector */ u32 vl (void *p) { return vec_len (p); } #ifdef CLIB_UNIX int main (int argc, char *argv[]) { unformat_input_t i; int ret; clib_mem_init (0, 64ULL << 20); unformat_init_command_line (&i, argv); ret = test_time_range_main (&i); unformat_free (&i); return ret; } #endif /* CLIB_UNIX */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */