|
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/switch.h>#include <opennsl/l2.h>#include <opennsl/l3.h>#include <examples/util.h>Go to the source code of this file.
Macros | |
| #define | DEFAULT_SUBNET_IP 0x37000000 /* 55.0.0.0 */ |
| #define | DEFAULT_SUBNET_MASK 0xff000000 /* /8 network */ |
| #define | EGRESS_VLAN 20 |
| #define | HOST1 0x14010102 /* 20.1.1.2 */ |
| #define | INGRESS_VLAN 10 |
| #define | MAX_DIGITS_IN_CHOICE 5 |
| #define | MY_MAC {0x00, 0x11, 0x22, 0x33, 0x99, 0x58} |
| #define | NEXTHOP_MAC {0x00, 0x00, 0x70, 0x5B, 0xC7, 0x34} |
Functions | |
| int | example_add_host (int unit, unsigned int addr, int intf) |
| Add host address to the routing table. | |
| int | example_create_l3_egress (int unit, unsigned int flags, int out_port, int vlan, int l3_eg_intf, opennsl_mac_t next_hop_mac_addr, int *intf) |
| create l3 egress object object includes next hop information. | |
| int | example_create_l3_intf (int unit, int open_vlan, opennsl_gport_t port, opennsl_vlan_t vid, opennsl_mac_t mac_addr, int *l3_id) |
| Creates Router interface. | |
| int | example_l2_addr_add (int unit, opennsl_mac_t mac, int port, int vid) |
| To add a given MAC and VID to the L2 forwarding database. | |
| int | example_set_default_route (int unit, int subnet, int mask, int intf, opennsl_gport_t trap_port) |
| Add default route to a subnet. | |
| int | example_vlan_port_add (int unit, int open_vlan, opennsl_vlan_t vlan, int port) |
| To add a port to the VLAN. | |
| int | main (int argc, char *argv[]) |
| Main function for routing sample application. | |
Variables | |
| char | example_usage [] |
| int | verbose = 3 |
| #define DEFAULT_SUBNET_IP 0x37000000 /* 55.0.0.0 */ |
Definition at line 79 of file example_routing.c.
Referenced by main().
| #define DEFAULT_SUBNET_MASK 0xff000000 /* /8 network */ |
Definition at line 80 of file example_routing.c.
Referenced by main().
| #define EGRESS_VLAN 20 |
Definition at line 77 of file example_routing.c.
Referenced by main().
| #define HOST1 0x14010102 /* 20.1.1.2 */ |
Definition at line 78 of file example_routing.c.
Referenced by main().
| #define INGRESS_VLAN 10 |
Definition at line 76 of file example_routing.c.
Referenced by main().
| #define MAX_DIGITS_IN_CHOICE 5 |
Definition at line 85 of file example_routing.c.
| #define MY_MAC {0x00, 0x11, 0x22, 0x33, 0x99, 0x58} |
Definition at line 81 of file example_routing.c.
Referenced by main().
| #define NEXTHOP_MAC {0x00, 0x00, 0x70, 0x5B, 0xC7, 0x34} |
Definition at line 83 of file example_routing.c.
Referenced by main().
| int example_add_host | ( | int | unit, |
| unsigned int | addr, | ||
| int | intf | ||
| ) |
Add host address to the routing table.
| unit | [IN] Unit number. |
| addr | [IN] 32 bit IP address value |
| intf | [IN] egress object created using example_create_l3_egress |
Definition at line 281 of file example_routing.c.
References opennsl_l3_host_s::l3a_flags, opennsl_l3_host_s::l3a_intf, opennsl_l3_host_s::l3a_ip_addr, opennsl_l3_host_s::l3a_port_tgid, OPENNSL_E_NONE, opennsl_errmsg, opennsl_l3_host_add(), opennsl_l3_host_t_init(), print_ip_addr(), and verbose.
Referenced by main().
| int example_create_l3_egress | ( | int | unit, |
| unsigned int | flags, | ||
| int | out_port, | ||
| int | vlan, | ||
| int | l3_eg_intf, | ||
| opennsl_mac_t | next_hop_mac_addr, | ||
| int * | intf | ||
| ) |
create l3 egress object object includes next hop information.
- packets sent to this interface will be send through out_port over
given l3_eg_intf with next next_hop_mac_addr VLAN. SA is driven from
l3_eg_intf as configure in example_create_l3_intf().
| unit | [IN] Unit number |
| flags | [IN] special controls set to zero |
| out_port | [IN] egress port |
| vlan | [IN] VLAN identifier |
| l3_eg_intf | [IN] egress router interface will derive (VLAN, SA) |
| next_hop_mac_addr | [IN] next hop mac address |
| *intf | [OUT] returned interface ID |
Definition at line 237 of file example_routing.c.
References opennsl_l3_egress_s::intf, opennsl_l3_egress_s::mac_addr, opennsl_l3_egress_s::module, OPENNSL_E_NONE, opennsl_l3_egress_create(), opennsl_l3_egress_t_init(), opennsl_l3_egress_s::port, verbose, and opennsl_l3_egress_s::vlan.
| int example_create_l3_intf | ( | int | unit, |
| int | open_vlan, | ||
| opennsl_gport_t | port, | ||
| opennsl_vlan_t | vid, | ||
| opennsl_mac_t | mac_addr, | ||
| int * | l3_id | ||
| ) |
Creates Router interface.
- packets sent in from this interface identified by <port, vlan> with
specificed MAC address is subject of routing
- packets sent out through this interface will be encapsulated with
<vlan, mac_addr>
| unit | [IN] Unit number. |
| open_vlan | [IN] if TRUE create given vlan, FALSE: vlan already opened juts use it |
| port | [IN] Port number |
| vid | [IN] router interface VLAN |
| mac_addr | [IN] my MAC address |
| l3_id | [OUT] returned handle of opened l3-interface |
Definition at line 179 of file example_routing.c.
References example_vlan_port_add(), l2_print_mac(), opennsl_l3_intf_s::l3a_intf_id, opennsl_l3_intf_s::l3a_mac_addr, opennsl_l3_intf_s::l3a_vid, OPENNSL_E_EXISTS, OPENNSL_E_NONE, opennsl_errmsg, opennsl_l3_intf_create(), opennsl_l3_intf_t_init(), and verbose.
| int example_l2_addr_add | ( | int | unit, |
| opennsl_mac_t | mac, | ||
| int | port, | ||
| int | vid | ||
| ) |
To add a given MAC and VID to the L2 forwarding database.
| unit | [IN] Unit number. |
| mac | [IN] MAC address |
| port | [IN] Port number |
| vid | [IN] VLAN identifier |
Definition at line 101 of file example_routing.c.
References opennsl_l2_addr_s::flags, OPENNSL_E_NONE, opennsl_l2_addr_add(), opennsl_l2_addr_t_init(), OPENNSL_L2_L3LOOKUP, OPENNSL_L2_STATIC, opennsl_l2_addr_s::port, and port().
| int example_set_default_route | ( | int | unit, |
| int | subnet, | ||
| int | mask, | ||
| int | intf, | ||
| opennsl_gport_t | trap_port | ||
| ) |
Add default route to a subnet.
| unit | [IN] Unit number. |
| subnet | [IN] 32 bit IP subnet |
| mask | [IN] 32 bit value network mask |
| intf | [IN] Egress object created using example_create_l3_egress |
| trap_port | [IN] Trap destination. if trap_port is valid trap then it used for default destination. otherwise intf (egress-object) is used |
Definition at line 320 of file example_routing.c.
References opennsl_l3_route_s::l3a_flags, opennsl_l3_route_s::l3a_intf, opennsl_l3_route_s::l3a_ip_mask, opennsl_l3_route_s::l3a_port_tgid, opennsl_l3_route_s::l3a_subnet, OPENNSL_E_NONE, opennsl_errmsg, opennsl_l3_route_add(), opennsl_l3_route_t_init(), print_ip_addr(), and verbose.
Referenced by main().
| int example_vlan_port_add | ( | int | unit, |
| int | open_vlan, | ||
| opennsl_vlan_t | vlan, | ||
| int | port | ||
| ) |
To add a port to the VLAN.
| unit | [IN] Unit number. |
| open_vlan | [IN] if TRUE create given vlan, FALSE: vlan already opened juts use it |
| vlan | [IN] VLAN identifier |
| port | [IN] Port number |
Definition at line 131 of file example_routing.c.
References OPENNSL_E_EXISTS, OPENNSL_E_NONE, opennsl_errmsg, OPENNSL_PBMP_CLEAR, OPENNSL_PBMP_PORT_ADD, opennsl_vlan_create(), opennsl_vlan_port_add(), and verbose.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Main function for routing sample application.
| argc,argv | commands line arguments |
Definition at line 359 of file example_routing.c.
References DEFAULT_SUBNET_IP, DEFAULT_SUBNET_MASK, EGRESS_VLAN, example_add_host(), example_create_l3_egress(), example_create_l3_intf(), example_l2_addr_add(), example_port_default_config(), example_read_user_choice(), example_set_default_route(), example_usage, HOST1, INGRESS_VLAN, MY_MAC, NEXTHOP_MAC, NULL, OPENNSL_BOOT_F_WARM_BOOT, opennsl_driver_boot_flags_get(), opennsl_driver_exit(), opennsl_driver_init(), OPENNSL_E_NONE, OPENNSL_E_PARAM, opennsl_errmsg, opennsl_switch_control_set(), opennslSwitchControlSync, opennslSwitchL3EgressMode, and verbose.
| char example_usage[] |
Definition at line 52 of file example_routing.c.
| int verbose = 3 |
Definition at line 88 of file example_routing.c.