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_UNIT 0 |
#define | DEFAULT_VLAN 1 |
#define | ETHERMASK 0xffff |
#define | ETHERTYPE 0x0800 |
#define | IPADDR_36 0xC0A8C724 /* 192.168.199.36 */ |
#define | IPADDR_39 0xC0A8C727 /* 192.168.199.39 */ |
#define | IPADDR_40 0xC0A8C728 /* 192.168.199.40 */ |
#define | IPADDR_47 0xC0A8C72F /* 192.168.199.47 */ |
#define | IPMASK_BLOCK_36_39 0xFFFFFFFC /* Mask: 192.168.199.36-39 */ |
#define | IPMASK_BLOCK_40_47 0xFFFFFFF8 /* Mask: 192.168.199.40-47 */ |
#define | IPMASK_HOST_UNBLOCK 0xFFFFFFFF /* Unblock host mask */ |
#define | MAX_DIGITS_IN_CHOICE 5 |
Functions | |
int | example_fp_ip_block (int unit) |
Install filters to block traffic. | |
int | main (int argc, char *argv[]) |
Main function for blocking traffic based on source IP addresses. | |
Variables | |
char | example_usage [] |
int | verbose = 3 |
#define CALL_IF_ERROR_RETURN | ( | op | ) |
Definition at line 64 of file example_field_ip_block.c.
#define DEFAULT_UNIT 0 |
Definition at line 50 of file example_field_ip_block.c.
Referenced by main().
#define DEFAULT_VLAN 1 |
Definition at line 51 of file example_field_ip_block.c.
#define ETHERMASK 0xffff |
Definition at line 55 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define ETHERTYPE 0x0800 |
Definition at line 54 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPADDR_36 0xC0A8C724 /* 192.168.199.36 */ |
Definition at line 56 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPADDR_39 0xC0A8C727 /* 192.168.199.39 */ |
Definition at line 57 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPADDR_40 0xC0A8C728 /* 192.168.199.40 */ |
Definition at line 59 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPADDR_47 0xC0A8C72F /* 192.168.199.47 */ |
Definition at line 62 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPMASK_BLOCK_36_39 0xFFFFFFFC /* Mask: 192.168.199.36-39 */ |
Definition at line 58 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPMASK_BLOCK_40_47 0xFFFFFFF8 /* Mask: 192.168.199.40-47 */ |
Definition at line 60 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define IPMASK_HOST_UNBLOCK 0xFFFFFFFF /* Unblock host mask */ |
Definition at line 61 of file example_field_ip_block.c.
Referenced by example_fp_ip_block().
#define MAX_DIGITS_IN_CHOICE 5 |
Definition at line 52 of file example_field_ip_block.c.
int example_fp_ip_block | ( | int | unit | ) |
Install filters to block traffic.
unit | [IN] Unit number |
Create qualification set
initialize a group with the create qset
add entries to not drop traffic from IP: 192.168.199.40
add an entry to the group
add action associate with this entry
add entries to drop traffic from IP address range: 192.168.199.36-39
add an entry to the group
add drop action associate with this entry
add entries to drop traffic from IP address range: 192.168.199.40-47
add an entry to the group
add drop action associate with this entry
Definition at line 86 of file example_field_ip_block.c.
References ETHERMASK, ETHERTYPE, IPADDR_36, IPADDR_39, IPADDR_40, IPADDR_47, IPMASK_BLOCK_36_39, IPMASK_BLOCK_40_47, IPMASK_HOST_UNBLOCK, OPENNSL_E_NONE, opennsl_field_action_add(), opennsl_field_entry_create(), opennsl_field_entry_install(), opennsl_field_group_create(), OPENNSL_FIELD_GROUP_PRIO_ANY, OPENNSL_FIELD_QSET_ADD, OPENNSL_FIELD_QSET_INIT, opennsl_field_qualify_EtherType(), opennsl_field_qualify_SrcIp(), OPENNSL_IF_ERROR_RETURN, opennslFieldActionDrop, opennslFieldActionDropCancel, opennslFieldQualifyEtherType, opennslFieldQualifySrcIp, print_ip_addr(), and verbose.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Main function for blocking traffic based on source IP addresses.
argc,argv | commands line arguments |
Definition at line 183 of file example_field_ip_block.c.
References DEFAULT_UNIT, example_fp_ip_block(), 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, and opennsl_errmsg.
char example_usage[] |
Definition at line 38 of file example_field_ip_block.c.
int verbose = 3 |
Definition at line 77 of file example_field_ip_block.c.