|
OpenNSL API Guide and Reference Manual
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sal/driver.h>#include <opennsl/error.h>#include <opennsl/vlan.h>#include <opennsl/port.h>#include <opennsl/field.h>#include <examples/util.h>Go to the source code of this file.
Macros | |
| #define | CALL_IF_ERROR_RETURN(op) |
| #define | DEFAULT_STAT_ID 2 |
| #define | DEFAULT_UNIT 0 |
| #define | MAC_DA {0x00, 0x00, 0x01, 0x00, 0x02, 0x00} |
| #define | MAC_MASK {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} |
| #define | NEWCOS_VAL 3 |
Functions | |
| int | example_fp_redirect (int unit, int dport) |
| Install filters to redirect traffic to a destination port. | |
| int | main (int argc, char *argv[]) |
| Main function for redirecting traffic based on destination MAC address. | |
Variables | |
| opennsl_field_entry_t | eid = 0 |
| char | example_usage [] |
| opennsl_field_group_t | grp = 1 |
| int | stat_id = DEFAULT_STAT_ID |
| opennsl_field_stat_t | stats = opennslFieldStatPackets |
| #define CALL_IF_ERROR_RETURN | ( | op | ) |
Definition at line 67 of file example_field_redirect.c.
Referenced by example_fp_redirect(), and main().
| #define DEFAULT_STAT_ID 2 |
Definition at line 59 of file example_field_redirect.c.
Referenced by example_fp_redirect().
| #define DEFAULT_UNIT 0 |
Definition at line 53 of file example_field_redirect.c.
Referenced by main().
| #define MAC_DA {0x00, 0x00, 0x01, 0x00, 0x02, 0x00} |
Definition at line 55 of file example_field_redirect.c.
Referenced by example_fp_redirect().
| #define MAC_MASK {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} |
Definition at line 57 of file example_field_redirect.c.
Referenced by example_fp_redirect().
| #define NEWCOS_VAL 3 |
Definition at line 54 of file example_field_redirect.c.
Referenced by example_fp_redirect().
| int example_fp_redirect | ( | int | unit, |
| int | dport | ||
| ) |
Install filters to redirect traffic to a destination port.
| unit | [IN] Unit number |
| port | [IN] Port to which the traffic needs to redirected |
Create qualification set
Create action set
initialize a group with the create qset
add entries to qualify the packets with configured MAC address and then count it, redirect it to a destination port
add an entry to the group
add actions associated with this entry
Definition at line 88 of file example_field_redirect.c.
References CALL_IF_ERROR_RETURN, DEFAULT_STAT_ID, eid, grp, l2_print_mac(), MAC_DA, MAC_MASK, NEWCOS_VAL, OPENNSL_E_NONE, opennsl_errmsg, opennsl_field_action_add(), OPENNSL_FIELD_ASET_ADD, OPENNSL_FIELD_ASET_INIT, opennsl_field_entry_create_id(), opennsl_field_group_action_set(), opennsl_field_group_create_id(), opennsl_field_group_destroy(), opennsl_field_group_install(), OPENNSL_FIELD_GROUP_PRIO_ANY, OPENNSL_FIELD_QSET_ADD, OPENNSL_FIELD_QSET_INIT, opennsl_field_qualify_DstMac(), opennsl_field_stat_create_id(), OPENNSL_FIELD_STAT_ID_COUNTER_GET, OPENNSL_FIELD_STAT_ID_PROCESSOR_GET, OPENNSL_FIELD_STAT_ID_SET, OPENNSL_GPORT_LOCAL_SET, opennslFieldActionPrioIntNew, opennslFieldActionRedirectPort, opennslFieldActionStat, opennslFieldQualifyDstMac, stat_id, and stats.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Main function for redirecting traffic based on destination MAC address.
| argc,argv | commands line arguments |
Definition at line 183 of file example_field_redirect.c.
References CALL_IF_ERROR_RETURN, DEFAULT_UNIT, eid, example_fp_redirect(), example_port_default_config(), example_read_user_choice(), example_switch_default_vlan_config(), example_usage, grp, NULL, opennsl_driver_exit(), opennsl_driver_init(), OPENNSL_E_NONE, OPENNSL_E_PARAM, opennsl_errmsg, opennsl_field_entry_destroy(), opennsl_field_entry_stat_detach(), opennsl_field_entry_stat_get(), opennsl_field_group_destroy(), opennsl_field_stat_destroy(), opennsl_field_stat_get(), OPENNSL_FIELD_STAT_ID_COUNTER_GET, OPENNSL_FIELD_STAT_ID_PROCESSOR_GET, OPENNSL_FIELD_STAT_ID_SET, port(), stat_id, and stats.
| opennsl_field_entry_t eid = 0 |
Definition at line 62 of file example_field_redirect.c.
Referenced by example_fp_redirect(), and main().
| char example_usage[] |
Definition at line 39 of file example_field_redirect.c.
| opennsl_field_group_t grp = 1 |
Definition at line 61 of file example_field_redirect.c.
Referenced by example_create_policy(), example_fp_redirect(), and main().
| int stat_id = DEFAULT_STAT_ID |
Definition at line 63 of file example_field_redirect.c.
Referenced by example_create_policy(), example_fp_redirect(), and main().
Definition at line 65 of file example_field_redirect.c.
Referenced by example_create_policer(), example_create_policy(), example_fp_redirect(), and main().