52 #define DEFAULT_UNIT 0
53 #define DEFAULT_VLAN 1
54 #define MAX_DIGITS_IN_CHOICE 5
58 "Syntax: example_l2_firewall \n\r"
60 "Paramaters: None. \n\r"
62 "Example: The following command is used to allow or block station A \n\r"
63 "and station D that are part of VLAN 1 with MAC addresses \n\r"
64 "00:00:00:00:00:01 and 00:00:00:00:00:04 respectively. \n\r"
65 " example_l2_firewall \n\r"
67 "Usage Guidelines: None. \n\r";
136 printf(
"MAC=%02x:%02x:%02x:%02x:%02x:%02x VLAN=%d PORT=%d\n", info->
mac[0],info->
mac[1],info->
mac[2],info->
mac[3],info->
mac[4],info->
mac[5], info->
vid, info->
port);
149 int main(
int argc,
char *argv[])
155 void *user_data =
NULL;
156 unsigned int warm_boot;
160 if(strcmp(argv[0],
"gdb") == 0)
166 opennsl_mac_t station_a = {0x00, 0x00, 0x00, 0x00, 0x00, 0x1};
167 opennsl_mac_t station_d = {0x00, 0x00, 0x00, 0x00, 0x00, 0x4};
169 if((argc != (index + 1)) || ((argc > (index + 1)) && (strcmp(argv[index + 1],
"--help") == 0))) {
175 printf(
"Initializing the system.\r\n");
179 printf(
"\r\nFailed to initialize the system. Error %s\r\n",
191 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
197 printf(
"Adding ports to default vlan.\r\n");
200 printf(
"\r\nFailed to add default ports. rv: %s\r\n",
opennsl_errmsg(rv));
206 printf(
"\r\nUser menu: Select one of the following options\r\n");
207 printf(
"1. Apply firewall\n");
208 printf(
"2. Remove firewall\n");
209 printf(
"3. Show L2 table\n");
210 printf(
"4. Save the configuration to scache\n");
211 printf(
"5. Set L2 age interval\n");
212 #ifdef INCLUDE_DIAG_SHELL
213 printf(
"9. Launch diagnostic shell\n");
215 printf(
"0. Quit the application\n");
219 printf(
"Invalid option entered. Please re-enter.\n");
229 printf(
"L2 firewall: station A blocked successfully\n");
231 printf(
"L2 firewall: failed to apply rule. Error %s\n",
238 printf(
"L2 firewall rule: station D blocked successfully\n");
240 printf(
"L2 firewall: failed to apply rule. Error %s\n",
252 printf(
"L2 firewall: station A un-blocked successfully\n");
254 printf(
"L2 firewall: failed to apply rule. Error %s\n",
261 printf(
"L2 firewall rule: station D un-blocked successfully\n");
263 printf(
"L2 firewall: failed to apply rule. Error %s\n",
276 printf(
"\r\nFailed to iterate over L2 table. rv: %s\r\n",
opennsl_errmsg(rv));
279 printf(
"\nTotal number of L2 entries: %d\n",
max_l2_count);
288 printf(
"Failed to synchronize the configuration to scache. "
292 printf(
"Warmboot configuration is saved successfully.\n");
300 printf(
"Failed to get the l2 age interval. "
304 printf(
"Current L2 age interval: %d secs\n", age_seconds);
309 printf(
"Failed to set the l2 age interval. "
313 printf(
"New L2 age interval: %d secs\n", age_seconds);
318 #ifdef INCLUDE_DIAG_SHELL
321 opennsl_driver_shell();
328 printf(
"Exiting the application.\n");