Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.6.0.3
Packet

This document provides a brief description of the Packet OpEN APIs. The Packet OpEN APIs allows processes outside of the ICOS main process (switchdrvr) access to packet services. It provides the following services:

Example C Application tx_pkt_example

Initialization

In the main function, the sample application initializes the OpEN API RPC service by calling openapiClientRegister() and waits for the RPC service in switchdrvr to start. A Client Handle is returned by openapiClientRegister() which is used while invoking the OpEN APIs. The application then exercises the associated OpEN APIs and logs informational and/or error messages on the console. The example application runs to its completion and exits.

tx_pkt_example

tx_pkt_example.c is a sample application that demonstrates the use of the Packet OpEN APIs. tx_pkt_example is started from the command line as tx_pkt_example <ifNum>. This example application constructs a mock packet initialized with 0xcc characters and transmits the packet to the specified interface via the UNICAST protocol.

Sample Output (LiNe/LinuxHost platform)

# ./tx_pkt_example 1

ICOS version = 12.18.10.45

packet transmitted on interface : 1

Example C Application rx_pkt_example

Initialization

In the main function, the sample application initializes the OpEN API RPC service by calling openapiClientRegister() and waits for the RPC service in switchdrvr to start. A Client Handle is returned by openapiClientRegister() which is used while invoking the OpEN APIs. The application then exercises the associated OpEN APIs and logs informational and/or error messages on the console. The example application runs to its completion and exits.

rx_pkt_example

rx_pkt_example.c is a sample application that demonstrates the use of the Packet OpEN APIs. rx_pkt_example is started from the command line as rx_pkt_example <agentNum> <packetCount> <fileName>. The <agentNum> is a unique number used to identify the agent. The <packetCount> determines how many packets the application will wait to receive. The received packet contents are saved and written to the output <fileName>. Once started, the user is prompted for a TCM policy priority and TCM policy type. The user is then presented with menu selections which allows for the definition of various TCM policy classifications. When finished, the TCM policy is then assigned to the specified interface. A socket end-point is created to receive frames and the application enters a while loop waiting to receive the desired <packetCount>.

Sample Output (LiNe/LinuxHost platform)

# ./rx_pkt_example 1 2 packet.log

ICOS version = 12.18.10.45
TCAM API version = 0.1

Enter policy priority
1
Select policy type 1 for openflow 2 for Gen (IPv6) 3 for Egress
1
This selection will add multiple classifiers to the policy
Enter classification type
1 to match dest MAC
2 to match Src MAC
3 to match VLAN
4 to match VLAN Priority
5 to match ether type
6 to match dest IP address
7 to match src IP address
8 to match dest IPv6 address
9 to match src IPv6 address
10 quit
10
Enter intf string
0/1

# ls -l packet.log
-rw-r–r– 1 root root 1284 Dec 19 14:20 packet.log

Example Python Applications tx_pkt_example and rx_pkt_example

In addition to tx_pkt_example.c and rx_pkt_example.c, a python implementation has also been provided for demonstration purposes. These python scripts (tx_pkt_example.py and rx_pkt_example.py) are essentially duplications of tx_pkt_example.c and rx_pkt_example.c.

Example Ruby Applications tx_pkt_example and rx_pkt_example

In addition to tx_pkt_example.c and rx_pkt_example.c, a ruby implementation has also been provided for demonstration purposes. These ruby applications (tx_pkt_example.rb and rx_pkt_example.rb) are essentially duplications of tx_pkt_example.c and rx_pkt_example.c.