48 "Syntax: example_sflow \n\r"
50 "Paramaters: None \n\r"
52 "Example: The following command is used to demonstrate sFlow \n\r"
55 "Usage Guidelines: This program allows the user to configure sFlow \n\r"
56 "parameters. It also has a provision to display the sFlow sampled \n\r"
57 "packet on the console. \n\r"
59 "Note: Configure sFlow in such a way that less number of packets are \n\r"
60 "sampled, as it prints the packet on the console which is time consuming\n\r";
78 static int pkt_total_count = 0;
79 static int pkt_sflow_count = 0;
88 printf(
"==========================================\n\r");
89 printf(
"Packet %d of length %d is received:\n\r",
92 for (i = 0; i < 32; i++)
95 if(((i + 1) % 16) == 0)
104 printf(
"Received pkt on rx_port %d, src_port %d "
105 "flags 0x%x, vlan %d cos %d\n",
113 printf(
"The received packet is sFlow sampled packet. "
114 "Sample packet count: %d\n\r", pkt_sflow_count);
119 printf(
"==========================================\n\r");
134 int main(
int argc,
char *argv[])
139 unsigned int warm_boot;
144 if(strcmp(argv[0],
"gdb") == 0)
148 if((argc != (index + 1)) || ((argc > (index + 1))
149 && (strcmp(argv[index + 1],
"--help") == 0))) {
158 printf(
"\r\nFailed to initialize the system.\r\n");
167 printf(
"Adding ports to default vlan.\r\n");
171 printf(
"\r\nFailed to add default ports. rv: %s\r\n",
opennsl_errmsg(rv));
178 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
188 printf(
"RX start failed unit %d.\n", unit);
193 "sflow_rx_callback_function",
200 printf(
"Failed to register sFlow Rx callback function. Error %s\n",
204 printf(
"Registered callback function to received sFlow sampled packets\n");
207 printf(
"\r\nUser menu: Select one of the following options\r\n");
208 printf(
"1. Enable sFlow and configure sFlow sampling rate\n");
209 printf(
"2. Disable sFlow\n");
210 printf(
"3. Display sFlow configuration\n");
211 printf(
"4. Save the configuration to scache\n");
212 #ifdef INCLUDE_DIAG_SHELL
213 printf(
"9. Launch diagnostic shell\n");
215 printf(
"0. Quit the application.\r\n");
219 printf(
"Invalid option entered. Please re-enter.\n");
226 printf(
"Enter port number\n");
229 printf(
"Invalid option entered. Please re-enter.\n");
233 printf(
"Enter ingress sampling rate\n");
236 printf(
"Invalid option entered. Please re-enter.\n");
242 printf(
"Failed to configure sFlow sample rate. Error %s\n",
255 printf(
"Failed to configure sFlow port control. Error %s\n",
260 printf(
"Enabled sFlow on port %d with sample rate of %d\n",
268 printf(
"Enter port number\n");
271 printf(
"Invalid option entered. Please re-enter.\n");
277 printf(
"Failed to clear sFlow sample rate. Error %s\n",
289 printf(
"Failed to configure sFlow port control. Error %s\n",
293 printf(
"Disabled sFlow on port %d successfully\n", port);
300 printf(
"Enter port number\n");
303 printf(
"Invalid option entered. Please re-enter.\n");
309 printf(
"Failed to get sFlow configuration. Error %s\n",
313 printf(
"sFlow configuration parameters on port: %d\n", port);
314 printf(
" Ingress sampling rate: %d Egress sampling rate: %d\n",
325 printf(
"Failed to synchronize the configuration to scache. "
329 printf(
"Warmboot configuration is saved successfully.\n");
333 #ifdef INCLUDE_DIAG_SHELL
336 opennsl_driver_shell();
343 printf(
"Exiting the application.\n");