OpenNSL API Guide and Reference Manual
Macros | Functions | Variables
example_packet_transmit.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sal/driver.h>
#include <sal/version.h>
#include <opennsl/error.h>
#include <opennsl/vlan.h>
#include <opennsl/port.h>
#include <opennsl/switch.h>
#include <opennsl/pkt.h>
#include <opennsl/tx.h>
#include <opennsl/stack.h>
#include <examples/util.h>

Go to the source code of this file.

Macros

#define DEFAULT_UNIT   0
 
#define DEFAULT_VLAN   1
 
#define MAX_DIGITS_IN_CHOICE   5
 

Functions

void example_multi_pkt_send (int unit, opennsl_port_t port, opennsl_vlan_t vlan, int count)
 Form a packet and send multiple packets from the specified port.
 
int example_pkt_dump (uint8 *data, int len)
 print packet contents
 
int example_pkt_send (int unit, opennsl_port_t port, opennsl_vlan_t vlan)
 Send a packet on the specified port and VLAN.
 
int main (int argc, char *argv[])
 Main function for packet transmission.
 

Variables

char example_usage []
 

Macro Definition Documentation

#define DEFAULT_UNIT   0

Definition at line 41 of file example_packet_transmit.c.

Referenced by main().

#define DEFAULT_VLAN   1

Definition at line 42 of file example_packet_transmit.c.

#define MAX_DIGITS_IN_CHOICE   5

Definition at line 43 of file example_packet_transmit.c.

Function Documentation

void example_multi_pkt_send ( int  unit,
opennsl_port_t  port,
opennsl_vlan_t  vlan,
int  count 
)

Form a packet and send multiple packets from the specified port.

Parameters
unit[IN] Unit number.
port[IN] Port number.
port[IN] VLAN ID.
count[IN] Number of packets to be transmitted.
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 188 of file example_packet_transmit.c.

References example_pkt_send(), opennsl_errmsg, and OPENNSL_SUCCESS.

Referenced by main().

int example_pkt_dump ( uint8 data,
int  len 
)

print packet contents

Parameters
data[IN] buffer holding the packet content.
len[IN] Size of the packet data.
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 64 of file example_packet_transmit.c.

Referenced by example_pkt_send().

int example_pkt_send ( int  unit,
opennsl_port_t  port,
opennsl_vlan_t  vlan 
)

Send a packet on the specified port and VLAN.

Parameters
unit[IN] Unit number.
port[IN] Port number.
vlan[IN] VLAN ID.
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 96 of file example_packet_transmit.c.

References opennsl_pkt_s::blk_count, opennsl_pkt_s::call_back, example_pkt_dump(), OPENNSL_E_NONE, opennsl_errmsg, opennsl_pkt_alloc(), opennsl_pkt_free(), opennsl_pkt_memcpy(), opennsl_stk_gport_sysport_get(), opennsl_tx(), OPENNSL_TX_CRC_ALLOC, and opennsl_pkt_s::unit.

Referenced by example_multi_pkt_send().

int main ( int  argc,
char *  argv[] 
)

Main function for packet transmission.

Parameters
argc,argvcommands line arguments
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 217 of file example_packet_transmit.c.

References DEFAULT_UNIT, example_multi_pkt_send(), 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, opennsl_errmsg, opennsl_version_get(), and port().

Variable Documentation

char example_usage[]
Initial value:
=
"Syntax: example_packet_transmit \n\r"
" \n\r"
"Paramaters: None. \n\r"
" \n\r"
"Example: The following command is used to demonstrate transmit and \n\r"
" packet API's. \n\r"
" example_packet_transmit \n\r"
" \n\r"
"Usage Guidelines: None. \n\r"

Definition at line 45 of file example_packet_transmit.c.