tfAddVlanInterface
Table of Contents >> Programmer's Reference
| #include <trsocket.h> |
| ttUserInterface tfAddVlanInterface | ( |
| const char * vNamePtr, | |
| const char * ifNamePtr, | |
| ttUser32Bit vlanId, | |
| int * drvAddErrorPtr | |
| ); |
Contents
Function Description
Virtual LANs give you the ability to sub-divide a LAN. The stack can accept VLAN tagged traffic and presents each VLAN ID as a different network interface (virtual interface) (eg: "ETH0-1" for VLAN ID 1) This function will add a virtual interface to the Treck TCP/IP system. Note: Virtual Interfaces are added in the CLOSED state.
Usage:
Add an Ethernet Tagged Link layer, i.e. call tfUseEthernetTagged().Add a physical interface, i.e. call tfAddInterface(), specifying the link layer handle returned by tfUseEthernetTagged().
Add one or more virtual interfaces linked to the just added physical interface, i.e. call tfAddVlanInterface(), specifying the physical interface name as the second parameter.
Open/Configure a newly added virtual interface with an IP address using existing APIs: tfOpenInterface() , tfNgOpenInterface(), tfConfigInterface(), tfNgConfigInterface(), and specifying the virtual interface handle returned by tfAddVlanInterface() as the first parameter.
Add default gateway, static routes, as needed, using the opened/configured virtual interface(s), i.e. and specifying the virtual interface handle returned by tfAddVlanInterface() as the first parameter.
Then use regular APIs to send, receive, etc...
Use the virtual device name (eg:"ETH0-1"), if setting the SO_BINDTODEVICE socket option.
Unconfigure, or Close the virtual interface using existing APIs, specifying the virtual interface handle returned by tfAddVlanInterface() as the first parameter.
Example:
Test/Example code can be found in the txvlan.c file in the examples directory. An example would be as follows:
linkLayerHanlde = tfUseEthernetTagged();
myPhysInterfaceHandle = tfAddInterface("ETH0", linkLayerHandle, ...);
myInterfaceHandle=tfAddVlanInterface("ETH0","ETH0-1",0x81000001,&errorCode);
Parameters
- vNamePtr
- The callers name for the virtual device (each call to tfAddVlanInterface() must use a unique name). The name length cannot exceed TM_MAX_DEVICE_NAME - 1 (13 bytes).
- ifNamePtr
- The callers name for the physical device (as specified in the first parameter of a previous tfAddInterface() call). .
- vlanId
- a unique VLAN ID associated with this virtual device.
- drvAddErrorPtr
- A pointer to an int that will contain an error (if one occurred).
Returns
- ttUserInterface
- Success.
- NULL
- Failure. See value stored in *drvAddErrorPtr.
Possible values for *drvAddErrorPtr:
- TM_EINVAL
- One of the parameters was invalid, or link layer associated with the physical device is not an Ethernet tagged link layer.
- TM_EALREADY
- Device has already been added.
- TM_ENOBUFS
- Not enough buffers to allocate a device entry.
- TM_ENOSPC
- The maximum number of devices has already been added (default 255). To modify this default, #define TM_MAX_NUM_IFS in your trsystem.h file to be the maximum number of devices you wish to add.