|
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/init.h>#include <opennsl/l2.h>#include <opennsl/vlan.h>#include <opennsl/stg.h>#include <opennsl/link.h>#include <examples/util.h>Go to the source code of this file.
Macros | |
| #define | DEFAULT_VLAN 1 |
| #define | MAC_ADDR_LEN 17 |
| #define | MAX_DIGITS_IN_CHOICE 5 |
Functions | |
| int | example_is_dnx_device (int unit) |
| Returns true if the device belongs to DNX family of devices. | |
| int | example_is_qmx_device (int unit) |
| Returns true if the device is Qumran-MX device. | |
| int | example_max_port_count_get (int unit, int *count) |
| To get the number of front panel ports. | |
| int | example_port_default_config (int unit) |
| Set default configuration (like STP state, speed/duplex) for all ports. | |
| int | example_read_user_choice (int *choice) |
| Read numeric menu choice from user. | |
| char * | example_read_user_string (char *buf, size_t buflen) |
| Read a string from user. | |
| int | example_switch_default_vlan_config (int unit) |
| Add all ports to default vlan. | |
| void | l2_print_mac (char *str, opennsl_mac_t mac_address) |
| To print the MAC address. | |
| int | opennsl_ctoi (const char *s, char **end) |
| To convert a C-style constant to integer. | |
| int | opennsl_ip_parse (char *ip_str, unsigned int *ip_val) |
| Parse IP string into a IP value. | |
| int | opennsl_mac_parse (char *buf, unsigned char *macp) |
| Parse MAC address string. | |
| void | print_ip_addr (char *str, unsigned int host) |
| To print IP address in dotted decimal format. | |
| #define DEFAULT_VLAN 1 |
Definition at line 38 of file util.c.
Referenced by example_switch_default_vlan_config().
| #define MAC_ADDR_LEN 17 |
Referenced by opennsl_mac_parse().
| #define MAX_DIGITS_IN_CHOICE 5 |
Definition at line 39 of file util.c.
Referenced by example_read_user_choice().
| int example_is_dnx_device | ( | int | unit | ) |
Returns true if the device belongs to DNX family of devices.
| unit | [IN] unit number |
This API needs to be invoked after initializing the OpenNSL driver
Definition at line 51 of file util.c.
References opennsl_info_s::device, FALSE, opennsl_info_get(), and TRUE.
Referenced by example_port_default_config().
| int example_is_qmx_device | ( | int | unit | ) |
Returns true if the device is Qumran-MX device.
| unit | [IN] unit number |
This API needs to be invoked after initializing the OpenNSL driver
Definition at line 75 of file util.c.
References opennsl_info_s::device, FALSE, opennsl_info_get(), and TRUE.
Referenced by example_l3_intf_rif_create(), and init_portmap().
| int example_max_port_count_get | ( | int | unit, |
| int * | count | ||
| ) |
To get the number of front panel ports.
| unit | [IN] unit number |
| int | [OUT] Number of front panel ports |
Definition at line 495 of file util.c.
References opennsl_port_config_s::ge, OPENNSL_E_NONE, opennsl_errmsg, OPENNSL_PBMP_COUNT, opennsl_port_config_get(), and opennsl_port_config_s::xe.
| int example_port_default_config | ( | int | unit | ) |
Set default configuration (like STP state, speed/duplex) for all ports.
| unit | [IN] unit number |
Definition at line 97 of file util.c.
References opennsl_port_info_s::action_mask, opennsl_port_info_s::autoneg, opennsl_port_info_s::duplex, opennsl_port_config_s::e, opennsl_port_info_s::enable, example_is_dnx_device(), FALSE, opennsl_port_info_s::linkscan, OPENNSL_E_NONE, opennsl_errmsg, OPENNSL_FAILURE, OPENNSL_LINKSCAN_MODE_SW, OPENNSL_PBMP_ITER, OPENNSL_PORT_ABILITY_PAUSE_RX, OPENNSL_PORT_ABILITY_PAUSE_TX, OPENNSL_PORT_ATTR_AUTONEG_MASK, OPENNSL_PORT_ATTR_DUPLEX_MASK, OPENNSL_PORT_ATTR_ENABLE_MASK, OPENNSL_PORT_ATTR_LINKSCAN_MASK, OPENNSL_PORT_ATTR_PAUSE_RX_MASK, OPENNSL_PORT_ATTR_PAUSE_TX_MASK, OPENNSL_PORT_ATTR_SPEED_MASK, opennsl_port_config_get(), opennsl_port_config_t_init(), OPENNSL_PORT_DUPLEX_FULL, opennsl_port_info_t_init(), opennsl_port_selective_set(), OPENNSL_STG_STP_FORWARD, opennsl_stg_stp_set(), opennsl_port_info_s::pause_rx, opennsl_port_info_s::pause_tx, port(), and opennsl_port_info_s::speed.
Referenced by main().
| int example_read_user_choice | ( | int * | choice | ) |
Read numeric menu choice from user.
| choice | [IN/OUT] choice |
Definition at line 252 of file util.c.
References FALSE, MAX_DIGITS_IN_CHOICE, OPENNSL_E_FAIL, OPENNSL_E_NONE, and TRUE.
Referenced by example_knet_intf_create(), and main().
| char* example_read_user_string | ( | char * | buf, |
| size_t | buflen | ||
| ) |
Read a string from user.
| buf | [IN/OUT] Buffer to store the string |
| buflen | [IN] Buffer length |
Definition at line 225 of file util.c.
Referenced by example_knet_intf_create(), example_knet_intf_delete(), and main().
| int example_switch_default_vlan_config | ( | int | unit | ) |
Add all ports to default vlan.
| unit | [IN] unit number |
Definition at line 180 of file util.c.
References DEFAULT_VLAN, opennsl_port_config_s::e, OPENNSL_E_NONE, opennsl_errmsg, OPENNSL_FAILURE, OPENNSL_PBMP_ITER, opennsl_port_config_get(), opennsl_port_untagged_vlan_set(), opennsl_vlan_port_add(), and port().
Referenced by main().
| void l2_print_mac | ( | char * | str, |
| opennsl_mac_t | mac_address | ||
| ) |
To print the MAC address.
Definition at line 358 of file util.c.
Referenced by example_create_l3_intf(), example_fp_redirect(), and example_l2_addr_add().
| int opennsl_ctoi | ( | const char * | s, |
| char ** | end | ||
| ) |
| int opennsl_ip_parse | ( | char * | ip_str, |
| unsigned int * | ip_val | ||
| ) |
| int opennsl_mac_parse | ( | char * | buf, |
| unsigned char * | macp | ||
| ) |
Parse MAC address string.
| buf | [IN] MAC address in string format |
| macp | [OUT] MAC address in integer format |
Definition at line 293 of file util.c.
References MAC_ADDR_LEN, NULL, OPENNSL_E_FAIL, and OPENNSL_E_NONE.
Referenced by main().
| void print_ip_addr | ( | char * | str, |
| unsigned int | host | ||
| ) |
To print IP address in dotted decimal format.
| str | [OUT] Buffer to store the IP address |
| host | [IN] MAC address in integer format |
Definition at line 425 of file util.c.
Referenced by example_add_host(), example_fp_ip_block(), example_ip_tunnel_term_print_key(), example_set_default_route(), example_vxlan_egress_tunnel_create(), print_host(), and print_route().