aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/mactime/mactime.api
blob: 631d81e64eb7a505640b448a2a0518901ee5a849 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (c) 2018 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.
 */

/** @file
    This file defines vpp mactime control-plane API messages
*/
option version = "2.0.0";

import "vnet/ethernet/ethernet_types.api";
import "vnet/interface_types.api";

/** @brief api to enable or disable the time-based src mac filter on
    an interface
*/

autoreply define mactime_enable_disable
{
  u32 client_index;             /**< client index, from api_main */
  u32 context;                  /**< application context */
  bool enable_disable;            /**< enable=1, disable=0 */
  vl_api_interface_index_t sw_if_index;              /**< the interface handle  */
  option vat_help = "<intfc> [disable]";
};

/** @brief a time range structure
 * times are in double-precision fp seconds since 1/1/1970,
 * which was a Thursday.
 */
typedef time_range
{
  f64 start;                    /**< start of the time range  */
  f64 end;                      /**< end of the time range */
};

/** @brief configure per src-mac time ranges
 *
 * Usage:
 *  to create a static allow entry:
 *   set mac_address, device_name, is_add=1, and allow=1.
 *
 *  to create a static drop entry:
 *   set mac_address, device_name, is_add=1, and drop=1.
 *
 *  to create a (time-range-based) dynamic allow entry:
 *   set mac_address, device_name, is_add=1, set allow=1.
 *   set count = number of ranges
 *   set each range start/end in seconds since Sunday began
 *   As in: start/end >= 0.0 && start/end < 7.0 *86400.0
 *
 *  to create a (time-range-based) dynamic allow entry with quota:
 *   Outside of stated time ranges, such entries revert to allow with no quota.
 *   previous setup, s/allow=1/allow_quota=1/
 *
 *  to create a (time-range-based) dynamic drop entry:
 *   Same procedure to create a dynamic allow entry,
 *   set drop=1 instead of allow=1
 *
 *  to delete a per src-mac entry (of any kind)
 *   set mac_address, is_add=0
 *   note: deletes all ranges.
 *
 * See mactime_test.c:api_mactime_add_del_range(...) for
 * a working example.
 */

autoreply define mactime_add_del_range
{
  u32 client_index;             /**< client index, from api_main */
  u32 context;                  /**< application context */
  bool is_add;                    /**< add=1, del=0  */
  bool drop;                      /**< drop flag */
  bool allow;                     /**< allow flag */
  u8 allow_quota;               /**< allow subject to quota */
  bool no_udp_10001;              /**< drop udp to port 10001 */
  u64 data_quota;		/**< max bytes this device */
  vl_api_mac_address_t mac_address;            /**< src mac address */
  string device_name[64];           /**< device name */
  u32 count;                    /**< number of time ranges to follow */
  /** time ranges, in seconds since Sunday began */
  vl_api_time_range_t ranges[count];
  option vat_help = "name <devname> mac <mac-addr> allow drop allow-range Mon - Fri 9:00 - 17:00";
};

/** @brief a time range, in fp seconds since Sunday midnight
 */

typedef mactime_time_range
{
  f64 start;
  f64 end;
};

/** @brief dump mactime table
 *
 * Request a mactime client pool dump
 * Sequence:
 * client send vl_api_mactime_dump to vpp
 * vpp replies with zero or more vl_api_mactime_entry_t's
 * vpp replies with a vl_api_mactime_dump_reply_t
 * @param my_table_epoch dump table only if update needed, 0 => full dump
 */

define mactime_dump
{
  u32 client_index;             /**< client index, from api_main */
  u32 context;                  /**< application context */
  u32 my_table_epoch;           /**< to suppress dump if no changes */
};

/** @brief mactime table entry details
 */

define mactime_details
{
  u32 context;
  u32 pool_index;
  vl_api_mac_address_t mac_address;
  u64 data_quota;
  u64 data_used_in_range;
  u32 flags;
  string device_name[64];
  u32 nranges;
  vl_api_mactime_time_range_t ranges[nranges];
};

/** @brief dump mactime table reply
 * Includes the vpp table epoch, needed to optimize API traffic
 */
define mactime_dump_reply
{
  u32 context;
  i32 retval;
  u32 table_epoch;
};

/*
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */