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 | DEFAULT_UNIT 0 |
#define | EGRESS_VLAN 20 |
#define | HOST1 0x14010102 /* 20.1.1.2 */ |
#define | INGRESS_VLAN 10 |
#define | MY_MAC {0x00, 0x11, 0x22, 0x33, 0x99, 0x58} |
#define | NEXTHOP_MAC {0x00, 0x00, 0x70, 0x5B, 0xC7, 0x34} |
Functions | |
int | example_create_l3_egress (int unit, uint32 flags, int out_port, int vlan, int l3_eg_intf, opennsl_mac_t nhop_mac_addr, int *intf, int *encap_id) |
create l3 egress object object includes next hop information. | |
int | example_create_l3_intf (int unit, uint32 flags, opennsl_gport_t port, int vlan, int vrf, opennsl_mac_t mac_addr, int ttl, int *intf) |
Creates Router interface. | |
int | example_host_add (int unit, uint32 addr, int vrf, int intf) |
To add host based route. | |
int | example_ipv4_route_setup (int unit, int in_port, int out_port) |
To setup host based IPv4 route. | |
int | example_route_add (int unit, uint32 addr, uint32 mask, int vrf, int intf) |
To add subnet based route. | |
int | main (int argc, char *argv[]) |
Main function for routing sample application. | |
void | print_host (char *type, opennsl_ip_t host, int vrf) |
To print the host entry. | |
void | print_route (char *type, uint32 addr, uint32 mask, int vrf) |
To print the route entry. | |
Variables | |
char | example_usage [] |
#define DEFAULT_SUBNET_IP 0x37000000 /* 55.0.0.0 */ |
Definition at line 76 of file example_routing.c.
Referenced by example_ipv4_route_setup().
#define DEFAULT_SUBNET_MASK 0xff000000 /* /8 network */ |
Definition at line 77 of file example_routing.c.
Referenced by example_ipv4_route_setup().
#define DEFAULT_UNIT 0 |
Definition at line 68 of file example_routing.c.
Referenced by main().
#define EGRESS_VLAN 20 |
Definition at line 70 of file example_routing.c.
Referenced by example_ipv4_route_setup().
#define HOST1 0x14010102 /* 20.1.1.2 */ |
Definition at line 71 of file example_routing.c.
Referenced by example_ipv4_route_setup().
#define INGRESS_VLAN 10 |
Definition at line 69 of file example_routing.c.
Referenced by example_ipv4_route_setup().
#define MY_MAC {0x00, 0x11, 0x22, 0x33, 0x99, 0x58} |
Definition at line 72 of file example_routing.c.
Referenced by example_ipv4_route_setup().
#define NEXTHOP_MAC {0x00, 0x00, 0x70, 0x5B, 0xC7, 0x34} |
Definition at line 74 of file example_routing.c.
Referenced by example_ipv4_route_setup().
int example_create_l3_egress | ( | int | unit, |
uint32 | flags, | ||
int | out_port, | ||
int | vlan, | ||
int | l3_eg_intf, | ||
opennsl_mac_t | nhop_mac_addr, | ||
int * | intf, | ||
int * | encap_id | ||
) |
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) |
nhop_mac_addr | [IN] next hop mac address |
*intf | [OUT] returned interface ID |
*encap_id | [OUT] returned encapsulation ID |
Definition at line 292 of file example_routing.c.
References opennsl_l3_egress_s::encap_id, opennsl_l3_egress_s::flags, 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, and opennsl_l3_egress_s::vlan.
Referenced by example_ipv4_route_setup(), and main().
int example_create_l3_intf | ( | int | unit, |
uint32 | flags, | ||
opennsl_gport_t | port, | ||
int | vlan, | ||
int | vrf, | ||
opennsl_mac_t | mac_addr, | ||
int | ttl, | ||
int * | intf | ||
) |
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. |
flags | [IN] Flags |
port | [IN] Port number |
vlan | [IN] VLAN ID |
vrf | [IN] Virtual Router Interface ID |
mac_addr | [IN] my MAC address |
ttl | [IN] Time To Live field value |
intf | [OUT] returned handle of opened l3-interface |
Definition at line 204 of file example_routing.c.
References opennsl_l2_station_s::dst_mac, opennsl_l2_station_s::dst_mac_mask, opennsl_l3_ingress_s::flags, opennsl_l2_station_s::flags, opennsl_l3_intf_s::l3a_flags, opennsl_l3_intf_s::l3a_intf_id, opennsl_l3_intf_s::l3a_mac_addr, opennsl_l3_intf_s::l3a_mtu, opennsl_l3_intf_s::l3a_ttl, opennsl_l3_intf_s::l3a_vid, OPENNSL_E_EXISTS, OPENNSL_E_NONE, opennsl_l2_station_add(), opennsl_l2_station_t_init(), opennsl_l3_ingress_create(), OPENNSL_L3_INGRESS_GLOBAL_ROUTE, opennsl_l3_ingress_t_init(), OPENNSL_L3_INGRESS_WITH_ID, opennsl_l3_intf_create(), opennsl_l3_intf_t_init(), opennsl_vlan_create(), opennsl_vlan_gport_add(), opennsl_l2_station_s::vlan_mask, and opennsl_l3_ingress_s::vrf.
Referenced by example_ipv4_route_setup(), and main().
int example_host_add | ( | int | unit, |
uint32 | addr, | ||
int | vrf, | ||
int | intf | ||
) |
To add host based route.
unit | [IN] Unit number. |
addr | [IN] IPV4 host address |
vrf | [IN] VRF ID |
intf | [IN] egress interface |
Definition at line 125 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_l3_host_s::l3a_vrf, OPENNSL_E_NONE, opennsl_l3_host_add(), and opennsl_l3_host_t_init().
Referenced by example_ipv4_route_setup().
int example_ipv4_route_setup | ( | int | unit, |
int | in_port, | ||
int | out_port | ||
) |
To setup host based IPv4 route.
unit | [IN] Unit number. |
in_port | [IN] Incoming Port number |
out_port | [IN] Outgoing Port number |
Definition at line 332 of file example_routing.c.
References DEFAULT_SUBNET_IP, DEFAULT_SUBNET_MASK, EGRESS_VLAN, example_create_l3_egress(), example_create_l3_intf(), example_host_add(), example_route_add(), HOST1, INGRESS_VLAN, MY_MAC, NEXTHOP_MAC, OPENNSL_E_NONE, and print_host().
Referenced by main().
To add subnet based route.
unit | [IN] Unit number. |
addr | [IN] IPV4 host address |
mask | [IN] IPV4 mask. 1: to consider 0: to ingore, for example for /24 mask = 0xffffff00 |
vrf | [IN] VRF ID |
intf | [IN] egress interface |
Definition at line 160 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_l3_route_s::l3a_vrf, OPENNSL_E_NONE, opennsl_l3_route_add(), opennsl_l3_route_t_init(), and print_route().
Referenced by example_ipv4_route_setup().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Main function for routing sample application.
argc,argv | commands line arguments |
Definition at line 404 of file example_routing.c.
References DEFAULT_UNIT, example_ipv4_route_setup(), example_port_default_config(), example_read_user_choice(), example_usage, NULL, opennsl_driver_exit(), opennsl_driver_init(), OPENNSL_E_NONE, OPENNSL_E_PARAM, and opennsl_errmsg.
void print_host | ( | char * | type, |
opennsl_ip_t | host, | ||
int | vrf | ||
) |
To print the host entry.
type | [IN] string header |
host | [IN] IPV4 host address |
vrf | [IN] VRF ID |
Definition at line 88 of file example_routing.c.
References print_ip_addr().
Referenced by example_ipv4_route_setup().
To print the route entry.
type | [IN] string header |
addr | [IN] IPV4 host address |
mask | [IN] IPV4 mask |
vrf | [IN] VRF ID |
Definition at line 105 of file example_routing.c.
References print_ip_addr().
Referenced by example_route_add().
char example_usage[] |
Definition at line 44 of file example_routing.c.