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.
- Get the rate limit value of incoming DHCP packets on untrusted interfaces.
- Set the rate limit value of incoming DHCP packets on untrusted interfaces.
- Get the burst interval value of incoming DHCP packets on untrusted interfaces.
- Set the burst interval value of incoming DHCP packets on untrusted interfaces.
- Get the number of DHCP snooping static bindings.
- List DHCP snooping binding entries.
- Get remote IP Address to store and restore the DHCP SNOOPING database.
- Set remote IP Address to store and restore the DHCP SNOOPING database.
- Get remote file name to store and restore the DHCP SNOOPING database.
- Set remote file name to store and restore the DHCP SNOOPING database.
- Set write delay interval to store the DHCP SNOOPING database.
- Get DHCP snooping statistics for passed counter Id.
- Clear DHCP snooping bindings.
- Sets the DHCP Snooping admin mode.
- Set API for whether DHCP snooping verifies source MAC addresses.
- Get API for whether DHCP snooping is enabled or disabled on a VLAN.
- Set API to enable or disable DHCP snooping on a VLAN.
- Set API for whether DHCP snooping considers a port trusted.
- Set API for whether DHCP snooping logs invalid packets.
- Displays IPv6 snooping binding entries.
- Add a static entry to the DHCP snooping bindings database.
- Remove a static entry from the DHCP snooping bindings database.
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: Get the rate limit value of incoming DHCP packets on untrusted interfaces: ./dhcp_snooping_example 36 <family> <ifNum>
- Test 37: Set the rate limit value of incoming DHCP packets on untrusted interfaces: ./dhcp_snooping_example 37 <family> <ifNum> <rate>
- Test 38: Get the burst interval value of incoming DHCP packets on untrusted interfaces: ./dhcp_snooping_example 38 <family> <ifNum>
- Test 39: Set the burst interval value of incoming DHCP packets on untrusted interfaces: ./dhcp_snooping_example 39 <family> <ifNum> <interval>
- Test 40: Get the number of DHCP snooping static bindings: ./dhcp_snooping_example 40 <family>
- Test 41: List DHCP snooping binding entries.: ./dhcp_snooping_example 41
- Test 42: Get remote IP Address to store and restore the DHCP SNOOPING database: ./dhcp_snooping_example 42 <family>
- Test 43: Set remote IP Address to store and restore the DHCP SNOOPING database: ./dhcp_snooping_example 43 <family> <ipAddr>
- Test 44: Get remote file name to store and restore the DHCP SNOOPING database: ./dhcp_snooping_example 44 <family>
- Test 45: Set remote file name to store and restore the DHCP SNOOPING database: ./dhcp_snooping_example 45 <family> <fileName>
- Test 46: Set write delay interval to store the DHCP SNOOPING database: ./dhcp_snooping_example 46 <family> <interval>
- Test 47: Get DHCP snooping statistics for passed counter Id: ./dhcp_snooping_example 47 <family> <ifNum> <counterId>
- Test 48: Clear DHCP snooping bindings: ./dhcp_snooping_example 48 <family> <ifNum> <clearStaticFlag>
- Test 49: Sets the DHCP Snooping admin mode: s 49 <family> <mode>
- Test 50: Set API for whether DHCP snooping verifies source MAC addresses: s 50 <family> <status>
- Test 51: Get API for whether DHCP snooping is enabled or disabled on a VLAN: s 51 <family> <vlanId>
- Test 52: Set API to enable or disable DHCP snooping on a VLAN: s 52 <family> <vlanStart> <vlanEnd> <mode>
- Test 53: Set API for whether DHCP snooping considers a port trusted: s 53 <family> <ifNum> <trustMode>
- Test 54: Set API for whether DHCP snooping logs invalid packets: s 54 <family> <ifNum> <logMode>
- Test 55: Displays IPv6 snooping binding entries.: s 55
- Test 56: Add a static entry to the DHCP snooping bindings database: s 56 <family> <macAddr> <ipAddr> <vlanId> <ifNum>
- Test 57: Remove a static entry from the DHCP snooping bindings database: s 57 <family> <macAddr>
- Test 58: Run API sanity checks: ./dhcp_snooping_example 58