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 srcPort,
int probePort);
65 int main(
int argc,
char *argv[])
74 if((argc != 4) || ((argc > 1) && (strcmp(argv[1],
"--help") == 0))) {
83 printf(
"\r\nFailed to initialize the system. Error: %s\r\n",
91 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
96 printf(
"Adding ports to default vlan.\r\n");
99 printf(
"\r\nFailed to add default ports. Error: %s\r\n",
104 mode = atoi(argv[1]);
105 srcPort = atoi(argv[2]);
106 probePort = atoi(argv[3]);
108 if(mode < 1 || mode > 3) {
109 printf(
"Invalid mode is entered.\r\n");
112 printf(
"\r\nInput parameters: Mode %d, Source Port %d,"
113 " Probe Port %d.\r\n", mode, srcPort, probePort);
116 rv = example_mirror_setup(unit, mode, srcPort, probePort);
118 printf(
"\r\nFailed to set port mirroring. Error: %s.\r\n",
122 printf(
"\r\nPort %d is mirrored to port %d successfully.\r\n",
127 printf(
"\r\nUser menu: Select one of the following options\r\n");
128 #ifdef INCLUDE_DIAG_SHELL
129 printf(
"9. Launch diagnostic shell\n");
131 printf(
"0. Quit the application.\r\n");
135 printf(
"Invalid option entered. Please re-enter.\n");
141 #ifdef INCLUDE_DIAG_SHELL
144 opennsl_driver_shell();
151 printf(
"Exiting the application.\n");
174 static int example_mirror_setup(
int unit,
int mode,
int srcPort,
int probePort)
178 unsigned int flags = 0;
183 printf(
"\r\nFailed to init mirror module. Error: %s\r\n",
189 mirror_dest.
gport = gport;
193 printf(
"\r\nFailed to create mirror dest. Error: %s\r\n",
221 printf(
"\r\nFailed to enable mirroring on the port. Error: %s\r\n",