This document provides a brief description of the DHCP Snooping OpEN APIs. It provides the following services:
- Get whether DHCP snooping is enabled or not.
- Get whether DHCP snooping verifies source MAC addresses.
- Given a VLAN ID, return the endpoints of the next range of VLANs enabled for DHCP snooping.
- Determine whether DHCP snooping is enabled on an interface.
- Determine whether DHCP snooping considers an enabled interface as trusted.
- Determine whether DHCP snooping logs invalid packets on an enabled interface.
- Get the remote DHCP snooping database file name.
- Get the remote DHCP snooping database IP Address.
- Get the DHCP snooping database write delay.
- Enable/Disable/Get the DHCP L2 relay global mode.
- Enable/Disable/Get the DHCP L2 relay interface mode.
- Set True/False or Get the DHCP L2 relay interface trust mode.
- Enable/Disable/Get the DHCP L2 relay mode for VLAN or range of VLANs.
- Enable/Disable/Get the DHCP L2 relay circuit ID mode for VLAN or range of VLANs.
- Configure/Get DHCP L2 relay remote ID for VLAN or range of VLANs.
- Enable/Disable/Get DHCP L2 relay mode for a given subscription on an interface.
- Enable/Disable/Get DHCP L2 relay circuit ID mode for a given subscription on an interface.
- Enable/Disable/Get DHCP L2 relay remote ID for a given subscription on an interface.
- Get DHCP L2 relay interface statistics.
- Clear the DHCP L2 relay interface statistics.
- Configure/Get the configured no-option-82 action on L2 relay trusted interface.
Example C Application dhcp_snooping_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.
dhcp_snooping_example
dhcp_snooping_example.c is a sample application that demonstrates the use of OpEN's DHCP Snooping and L2 relay APIs. dhcp_snooping_example is started from the command line and can be used to exercise the various APIs by specifying arguments on the command line.
Sample Output
- Usage: ./dhcp_snooping_example <test#> <arg1> <arg2> ...
- Note: in following, family is either 1 for AF_INET, or 2 for AF_INET6
- Test 1: Get whether DHCP snooping is enabled not: ./dhcp_snooping_example 1 family
- Test 2: Get whether DHCP snooping verifies source MAC addresses: ./dhcp_snooping_example 2 family
- Test 3: Display VLANs enabled for DHCP snooping: ./dhcp_snooping_example 3 family
- Test 4: Get whether DHCP snooping is enabled on a port: ./dhcp_snooping_example 4 family ifnum
- Test 5: Get whether DHCP snooping considers an interface trusted: ./dhcp_snooping_example 5 family ifnum
- Test 6: Get whether DHCP snooping logs invalid packets on an interface: ./dhcp_snooping_example 6 family ifnum
- Test 7: Get the remote DHCP snooping database file name: ./dhcp_snooping_example 7 family.
- Test 8: Get the remote DHCP snooping database IP Address: ./dhcp_snooping_example 8 family.
- Test 9: Get the DHCP snooping database write delay: ./dhcp_snooping_example 9 family.
- Test 10: Test DHCP snooping OpEN API Sanity: ./dhcp_snooping_example 10
- Test 11: Get DHCP L2 relay global mode: ./dhcp_snooping_example 11
- Test 12: Set DHCP L2 relay global mode: ./dhcp_snooping_example 12 <1 | 0>
- Test 13: Get DHCP L2 relay interface mode: ./dhcp_snooping_example 13 ifnum
- Test 14: Set DHCP L2 relay interface mode: ./dhcp_snooping_example 14 ifnum <1 | 0>
- Test 15: Get DHCP L2 relay interface trust mode: ./dhcp_snooping_example 15 ifnum
- Test 16: Set DHCP L2 relay interface trust mode: ./dhcp_snooping_example 16 ifnum <1 | 0>
- Test 17: Get DHCP L2 relay mode for VLAN: ./dhcp_snooping_example 17 vlanId
- Test 18: Set DHCP L2 relay mode for VLAN: ./dhcp_snooping_example 18 vlanId <1 | 0>
- Test 19: Set DHCP L2 relay mode for range of VLANs: ./dhcp_snooping_example 19 startVlanId endVlanId <1 | 0>
- Test 20: Get DHCP L2 relay circuit ID mode for VLAN: ./dhcp_snooping_example 20 vlanId
- Test 21: Set DHCP L2 relay circuit ID mode for VLAN: ./dhcp_snooping_example 21 vlanId <1 | 0>
- Test 22: Set DHCP L2 relay circuit ID mode for range of VLANs: ./dhcp_snooping_example 22 startVlanId endVlanId <1 | 0>
- Test 23: Get DHCP L2 relay remote ID for VLAN: ./dhcp_snooping_example 23 vlanId
- Test 24: Set DHCP L2 relay remote ID for VLAN: ./dhcp_snooping_example 24 vlanId remoteId
- Test 25: Set DHCP L2 relay remote ID for range of VLANs: ./dhcp_snooping_example 25 startVlanId endVlanId remoteId
- Test 26: Get DHCP L2 relay mode for a given subscription on an interface: ./dhcp_snooping_example 26 ifnum subscriptionName
- Test 27: Set DHCP L2 relay mode for a given subscription on an interface: ./dhcp_snooping_example 27 ifnum subscriptionName <1 | 0>
- Test 28: Get DHCP L2 relay circuit ID mode for a given subscription on an interface: ./dhcp_snooping_example 28 ifnum subscriptionName>
- Test 29: Set DHCP L2 relay circuit ID mode for a given subscription on an interface: ./dhcp_snooping_example 29 ifnum subscriptionName <1 | 0>
- Test 30: Get DHCP L2 relay remote ID for a given subscription on an interface: ./dhcp_snooping_example 30 ifnum subscriptionName
- Test 31: Set DHCP L2 relay remote ID for a given subscription on an interface: ./dhcp_snooping_example 31 ifnum subscriptionName remoteId
- Test 32: Get DHCP L2 relay interface statistics: ./dhcp_snooping_example 32 ifnum
- Test 33: Clear the DHCP L2 relay interface statistics: ./dhcp_snooping_example 33 ifnum
- Test 34: Get the configured no-option-82 action on L2 relay trusted interface: ./dhcp_snooping_example 34 ifnum
- Test 35: Set the configured no-option-82 action on L2 relay trusted interface: ./dhcp_snooping_example 35 ifnum action
- Test 36: Test DHCP L2 relay OpEN API Sanity: ./dhcp_snooping_example 36