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 <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, int port, int count)
 Form a packet and send multiple packets from the specified port.
 
int example_pkt_send (int unit, int port, char *data, int len)
 Send a packet on the specified port.
 
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 40 of file example_packet_transmit.c.

Referenced by main().

#define DEFAULT_VLAN   1

Definition at line 41 of file example_packet_transmit.c.

#define MAX_DIGITS_IN_CHOICE   5

Definition at line 42 of file example_packet_transmit.c.

Function Documentation

void example_multi_pkt_send ( int  unit,
int  port,
int  count 
)

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

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

Definition at line 105 of file example_packet_transmit.c.

References example_pkt_send(), opennsl_errmsg, and OPENNSL_SUCCESS.

int example_pkt_send ( int  unit,
int  port,
char *  data,
int  len 
)

Send a packet on the specified port.

Parameters
unit[IN] Unit number.
port[IN] Port number.
data[IN] Pointer to packet data.
len[IN] Size of the packet data.
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 65 of file example_packet_transmit.c.

References NULL, OPENNSL_PBMP_PORT_SET, opennsl_pkt_alloc(), opennsl_pkt_free(), opennsl_pkt_memcpy(), OPENNSL_SUCCESS, opennsl_tx(), and opennsl_pkt_s::tx_pbmp.

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 139 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 44 of file example_packet_transmit.c.