37 #define DEFAULT_UNIT 0
38 #define DEFAULT_VLAN 1
41 "Syntax: example_mirror mode sport dport \n\r"
44 " mode - 1, to turn on ingress mirroring. \n\r"
45 " 2, to turn on egress mirroring. \n\r"
46 " 3, to turn on ingress and egress mirroring. \n\r"
47 " sport - Port on which mirroring needs to be enabled. \n\r"
48 " dport - Port on which traffic needs to be probed. \n\r"
50 "Example: The following command is used to monitor ingress and egress \n\r"
51 " traffic from port 5 on port 10. \n\r"
52 " example_mirror 3 5 10 \n\r"
54 "Usage Guidelines: None. \n\r";
56 static int example_mirror_setup(
int unit,
int mode,
int source_port,
66 int main(
int argc,
char *argv[])
75 if((argc != 4) || ((argc > 1) && (strcmp(argv[1],
"--help") == 0))) {
84 printf(
"\r\nFailed to initialize the system. Error: %s\r\n",
92 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
97 printf(
"Adding ports to default vlan.\r\n");
100 printf(
"\r\nFailed to add default ports. Error: %s\r\n",
105 mode = atoi(argv[1]);
106 source_port = atoi(argv[2]);
107 probe_port = atoi(argv[3]);
109 if(mode < 1 || mode > 3) {
110 printf(
"Invalid mode is entered.\r\n");
113 printf(
"\r\nInput parameters: Mode %d, Source Port %d,"
114 " Probe Port %d.\r\n", mode, source_port, probe_port);
117 rv = example_mirror_setup(unit, mode, source_port, probe_port);
119 printf(
"\r\nFailed to set port mirroring. Error: %s.\r\n",
123 printf(
"\r\nPort %d is mirrored to port %d successfully.\r\n",
124 source_port, probe_port);
128 printf(
"\r\nUser menu: Select one of the following options\r\n");
129 #ifdef INCLUDE_DIAG_SHELL
130 printf(
"9. Launch diagnostic shell\n");
132 printf(
"0. Quit the application.\r\n");
136 printf(
"Invalid option entered. Please re-enter.\n");
142 #ifdef INCLUDE_DIAG_SHELL
145 opennsl_driver_shell();
152 printf(
"Exiting the application.\n");
175 static int example_mirror_setup(
int unit,
int mode,
int source_port,
180 unsigned int flags = 0;
185 printf(
"\r\nFailed to init mirror module. Error: %s\r\n",
195 printf(
"\r\nFailed to create mirror dest. Error: %s\r\n",
223 printf(
"\r\nFailed to enable mirroring on the port. Error: %s\r\n",