mactime: add a "top" command to watch device stats
[vpp.git] / src / plugins / mactime / mactime.api
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 /** @file
17     This file defines vpp mactime control-plane API messages
18 */
19 option version = "1.2.1";
20
21 /** @brief api to enable or disable the time-based src mac filter on
22     an interface
23 */
24
25 autoreply define mactime_enable_disable
26 {
27   u32 client_index;             /**< client index, from api_main */
28   u32 context;                  /**< application context */
29   u8 enable_disable;            /**< enable=1, disable=0 */
30   u32 sw_if_index;              /**< the interface handle  */
31   option vat_help = "<intfc> [disable]";
32 };
33
34 /** @brief a time range structure
35  * times are in double-precision fp seconds since 1/1/1970,
36  * which was a Thursday.
37  */
38 typedef time_range
39 {
40   f64 start;                    /**< start of the time range  */
41   f64 end;                      /**< end of the time range */
42 };
43
44 /** @brief configure per src-mac time ranges
45  *
46  * Usage:
47  *  to create a static allow entry:
48  *   set mac_address, device_name, is_add=1, and allow=1.
49  *
50  *  to create a static drop entry:
51  *   set mac_address, device_name, is_add=1, and drop=1.
52  *
53  *  to create a (time-range-based) dynamic allow entry:
54  *   set mac_address, device_name, is_add=1, set allow=1.
55  *   set count = number of ranges
56  *   set each range start/end in seconds since Sunday began
57  *   As in: start/end >= 0.0 && start/end < 7.0 *86400.0
58  *
59  *  to create a (time-range-based) dynamic allow entry with quota:
60  *   Outside of stated time ranges, such entries revert to allow with no quota.
61  *   previous setup, s/allow=1/allow_quota=1/
62  *
63  *  to create a (time-range-based) dynamic drop entry:
64  *   Same procedure to create a dynamic allow entry,
65  *   set drop=1 instead of allow=1
66  *
67  *  to delete a per src-mac entry (of any kind)
68  *   set mac_address, is_add=0
69  *   note: deletes all ranges.
70  *
71  * See mactime_test.c:api_mactime_add_del_range(...) for
72  * a working example.
73  */
74
75 autoreply define mactime_add_del_range
76 {
77   u32 client_index;             /**< client index, from api_main */
78   u32 context;                  /**< application context */
79   u8 is_add;                    /**< add=1, del=0  */
80   u8 drop;                      /**< drop flag */
81   u8 allow;                     /**< allow flag */
82   u8 allow_quota;               /**< allow subject to quota */
83   u8 no_udp_10001;              /**< drop udp to port 10001 */
84   u64 data_quota;               /**< max bytes this device */
85   u8 mac_address[6];            /**< src mac address */
86   u8 device_name[64];           /**< device name */
87   u32 count;                    /**< number of time ranges to follow */
88   /** time ranges, in seconds since Sunday began */
89   vl_api_time_range_t ranges[count];
90   option vat_help = "name <devname> mac <mac-addr> allow drop allow-range Mon - Fri 9:00 - 17:00";
91 };
92
93 /** @brief a time range, in fp seconds since Sunday midnight
94  */
95
96 typedef mactime_time_range
97 {
98   f64 start;
99   f64 end;
100 };
101
102 /** @brief dump mactime table
103  *
104  * Request a mactime client pool dump
105  * Sequence:
106  * client send vl_api_mactime_dump to vpp
107  * vpp replies with zero or more vl_api_mactime_entry_t's
108  * vpp replies with a vl_api_mactime_dump_reply_t
109  * @param my_table_epoch dump table only if update needed, 0 => full dump
110  */
111
112 define mactime_dump
113 {
114   u32 client_index;             /**< client index, from api_main */
115   u32 context;                  /**< application context */
116   u32 my_table_epoch;           /**< to suppress dump if no changes */
117 };
118
119 /** @brief mactime table entry details
120  */
121
122 define mactime_details
123 {
124   u32 context;
125   u32 pool_index;
126   u8 mac_address[6];
127   u64 data_quota;
128   u64 data_used_in_range;
129   u32 flags;
130   u8 device_name[64];
131   u32 nranges;
132   vl_api_mactime_time_range_t ranges[nranges];
133 };
134
135 /** @brief dump mactime table reply
136  * Includes the vpp table epoch, needed to optimize API traffic
137  */
138 define mactime_dump_reply
139 {
140   u32 context;
141   i32 retval;
142   u32 table_epoch;
143 };
144
145 /*
146  * Local Variables:
147  * eval: (c-set-style "gnu")
148  * End:
149  */