OpenNSL API Guide and Reference Manual
Data Structures | Macros | Functions | Variables
example_knet.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sal/driver.h>
#include <opennsl/error.h>
#include <opennsl/vlan.h>
#include <opennsl/rx.h>
#include <opennsl/knet.h>
#include <examples/util.h>

Go to the source code of this file.

Data Structures

struct  knet_if_data_t
 

Macros

#define DEFAULT_PORT   1
 
#define DEFAULT_UNIT   0
 
#define DEFAULT_VLAN   1
 
#define IP_ADDR_LEN   16
 
#define KNET_INTF_COUNT   20
 
#define MAX_DIGITS_IN_CHOICE   5
 
#define NETMASK_LEN   16
 

Functions

void example_ip_config (char *ifName, char *ip, char *netmask)
 
void example_knet_database_show ()
 Update KNET interface database.
 
void example_knet_database_update (int port, char *ifName, int nID, int fID)
 Update KNET interface database.
 
void example_knet_intf_create (int unit)
 
void example_knet_intf_delete (int unit)
 
int example_linux_interface_create (int unit, int port, char *ifName)
 
int main (int argc, char *argv[])
 Main function for KNET sample application.
 

Variables

char example_usage []
 
knet_if_data_t knet_if_data [KNET_INTF_COUNT]
 
int knet_intf_count = 0
 

Macro Definition Documentation

#define DEFAULT_PORT   1

Definition at line 42 of file example_knet.c.

#define DEFAULT_UNIT   0

Definition at line 41 of file example_knet.c.

Referenced by main().

#define DEFAULT_VLAN   1

Definition at line 43 of file example_knet.c.

Referenced by main().

#define IP_ADDR_LEN   16

Definition at line 46 of file example_knet.c.

Referenced by example_knet_intf_create().

#define KNET_INTF_COUNT   20
#define MAX_DIGITS_IN_CHOICE   5

Definition at line 44 of file example_knet.c.

#define NETMASK_LEN   16

Definition at line 47 of file example_knet.c.

Referenced by example_knet_intf_create().

Function Documentation

void example_ip_config ( char *  ifName,
char *  ip,
char *  netmask 
)

Definition at line 251 of file example_knet.c.

References system().

Referenced by example_knet_intf_create().

void example_knet_database_show ( )

Update KNET interface database.

Returns
None

Definition at line 143 of file example_knet.c.

References KNET_INTF_COUNT, knet_intf_count, and port().

Referenced by main().

void example_knet_database_update ( int  port,
char *  ifName,
int  nID,
int  fID 
)

Update KNET interface database.

Parameters
port[IN] port number
ifName[IN] interface name
nID[IN] KNET interface ID
fID[IN] KNET filter ID
Returns
None

Definition at line 97 of file example_knet.c.

References knet_if_data_t::filterID, KNET_INTF_COUNT, knet_intf_count, knet_if_data_t::netIfID, knet_if_data_t::port, and port().

Referenced by example_linux_interface_create().

void example_knet_intf_create ( int  unit)
void example_knet_intf_delete ( int  unit)
int example_linux_interface_create ( int  unit,
int  port,
char *  ifName 
)
int main ( int  argc,
char *  argv[] 
)

Variable Documentation

char example_usage[]
Initial value:
=
"Syntax: example_knet \n\r"
" \n\r"
"Paramaters: None. \n\r"
" \n\r"
"Example: The following command is used to create KNET interfaces \n\r"
" that can be configurable from Linux shell. \n\r"
" example_knet \n\r"
" \n\r"
"Usage Guidelines: This program request the user to enter the following\n\r"
" parameters interactively \n\r"
" port - port number \n\r"
" ifName - interface name \n\r"
" ipaddr - IP adddress to be assigned to the interface \n\r"
" netmask - IP netmask to be assigned to the interface \n\r"
" \n\r"
" Testing: \n\r"
" 1) Assign IP address to the interface using Create KNET \n\r"
" interface option. \n\r"
" 2) Assign IP address to the partner that is connected to \n\r"
" physical port in the same subnet. \n\r"
" 3) Verify that ping to the IP assigned in step 1 works fine. \n\r"
" \n\r"

Definition at line 49 of file example_knet.c.

Definition at line 84 of file example_knet.c.

int knet_intf_count = 0