OpenNSL API Guide and Reference Manual
Macros | Functions | Variables
example_policer.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <opennsl/error.h>
#include <opennsl/init.h>
#include <opennsl/port.h>
#include <opennsl/l2.h>
#include <opennsl/vlan.h>
#include <opennsl/field.h>
#include <opennsl/policer.h>
#include <opennsl/cosqX.h>
#include <examples/util.h>

Go to the source code of this file.

Macros

#define DEFAULT_UNIT   0
 
#define DEFAULT_VLAN   1
 
#define MAC_DA   {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
 
#define MAC_MASK   {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
 

Functions

opennsl_error_t example_create_meter (int unit)
 
opennsl_error_t example_create_policy (int unit, opennsl_port_t in_port, opennsl_port_t out_port)
 
int main (int argc, char *argv[])
 Main function for policer application.
 

Variables

opennsl_field_stat_t accept_stats = opennslFieldStatAcceptedPackets
 
opennsl_field_stat_t drop_stats = opennslFieldStatDroppedPackets
 
char example_usage []
 
opennsl_policer_t policer_id
 
int stat_id = 2
 

Macro Definition Documentation

#define DEFAULT_UNIT   0

Definition at line 76 of file example_policer.c.

Referenced by main().

#define DEFAULT_VLAN   1

Definition at line 77 of file example_policer.c.

#define MAC_DA   {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}

Definition at line 78 of file example_policer.c.

Referenced by example_create_policy().

#define MAC_MASK   {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}

Definition at line 80 of file example_policer.c.

Referenced by example_create_policy().

Function Documentation

opennsl_error_t example_create_meter ( int  unit)
opennsl_error_t example_create_policy ( int  unit,
opennsl_port_t  in_port,
opennsl_port_t  out_port 
)
int main ( int  argc,
char *  argv[] 
)

Main function for policer application.

Parameters
argc,argvcommands line arguments
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 271 of file example_policer.c.

References accept_stats, DEFAULT_UNIT, drop_stats, example_create_policy(), example_port_default_config(), example_read_user_choice(), example_switch_default_vlan_config(), example_usage, NULL, opennsl_driver_exit(), opennsl_driver_init(), OPENNSL_E_NONE, OPENNSL_E_PARAM, opennsl_errmsg, opennsl_field_stat_get(), and stat_id.

Variable Documentation

Definition at line 86 of file example_policer.c.

Referenced by main().

Definition at line 87 of file example_policer.c.

Referenced by main().

char example_usage[]
Initial value:
=
"Syntax: example_policer \n\r"
" \n\r"
"Paramaters: None. \n\r"
" \n\r"
"Example: The following command is used to create a policer and attach \n\r"
" it to a field processor rule matching traffic with \n\r"
" destination MAC = MAC_DA. \n\r"
" It also provides an option to display the number of packets \n\r"
" redirected to destination port. \n\r"
" \n\r"
" example_policer \n\r"
" \n\r"
"Usage Guidelines: None. \n\r"

Definition at line 61 of file example_policer.c.

opennsl_policer_t policer_id
int stat_id = 2

Definition at line 85 of file example_policer.c.