Create a new plugin from scratch by example pt. 3 (LLDP)

Now we are facing the forms/model and the templating! For a short explanation check the plugin enhancing guide.

This is our general.xml in the forms:

And this is the model:

We only use checkboxes, so very easy.

 

Now we do the templating. Normally you have a .conf file where you put your configuration, but LLDPD works just by parameters as arguments. If you want to enable CDP you set -c for example. So we have to edit our lldp file in the templating folder:

Be aware that this should be one line. What does it say? It tries to check if a value is defined and == 1. This is an enabled checkbox, and if it’s enabled then set the value, like -c. Now you can mix around and check in system.log if all the different protocols are loaded:

 

Dec 27 13:44:23 OPNsense lldpd[22637]: could not open either /etc/os-release or /usr/lib/os-release
Dec 27 13:44:23 OPNsense lldpd[22637]: lsb_release information not available
Dec 27 13:44:23 OPNsense lldpd[22894]: unable to create /var/empty/etc directory: Operation not permitted
Dec 27 13:44:23 OPNsense lldpd[22894]: protocol LLDP enabled
Dec 27 13:44:23 OPNsense lldpd[22894]: protocol CDPv1 enabled
Dec 27 13:44:23 OPNsense lldpd[22894]: protocol CDPv2 enabled
Dec 27 13:44:23 OPNsense lldpd[22894]: protocol SONMP enabled
Dec 27 13:44:23 OPNsense lldpd[22894]: protocol EDP enabled
Dec 27 13:44:23 OPNsense lldpd[22894]: protocol FDP disabled

 

In the last part we’ll create a new tab with the output of some commands to see the neighbors!