[Kea-users] Getting the interface name in hooks
Gokulakrishnan Gopalakrishnan
ggopalakrishnan at salesforce.com
Thu Aug 24 13:57:05 UTC 2017
Thanks. Replacing with getStagingCfg() worked well.
On Wed, Aug 23, 2017 at 11:32 PM, Marcin Siodelski <marcin at isc.org> wrote:
> That's because the load() function is called as a result of parsing
> server configuration when your hook library is loaded. At this point
> there is no committed server configuration yet (because server
> configuration is being parsed). What you could try is:
>
> ConstCfgIfacePtr cfg = CfgMgr::instance().getStagingCfg()->getCfgIface();
>
> instead of
>
> ConstCfgIfacePtr cfg = CfgMgr::instance().getCurrentCfg()->getCfgIface();
>
> because "staging" configuration should already contain the information
> about interfaces (the interfaces parser is launched before the hooks
> libs parser).
>
> Give it a try.
>
> Marcin
>
> On 23.08.2017 19:57, Gokulakrishnan Gopalakrishnan wrote:
> > Marcin,
> > When I placed the code in "load(LibraryHandle&), I'm getting empty
> > interface list, whereas if I keep the code in another hook like
> > pkt4_send, I'm getting the proper list of interfaces.
> > Actually, I'd be needing this info while initializing the Kea Process
> > itself. Can we get it somehow?
> >
> > On Wed, Aug 23, 2017 at 8:02 PM, Gokulakrishnan Gopalakrishnan
> > <ggopalakrishnan at salesforce.com <mailto:ggopalakrishnan at salesforce.com>>
> > wrote:
> >
> > Thanks Marcin. It worked
> >
> > On Wed, Aug 23, 2017 at 4:28 PM, Marcin Siodelski <marcin at isc.org
> > <mailto:marcin at isc.org>> wrote:
> >
> > You'd rather need to link with this:
> >
> > libdhcp_user_chk_la_LIBADD +=
> > $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
> > <http://libkea-dhcpsrv.la>
> >
> > In most cases you'd also need to link with libkea-dhcpsrv.la
> > <http://libkea-dhcpsrv.la>
> > dependencies which you can find it its Makefile.am.
> >
> > As for the automake error it seems to me that you're missing
> > automake-1.14. Perhaps you have some different version?
> > automake-1.15?
> >
> > Maybe go to Kea root directory and run autoreconf --install &&
> > ./configure ... && make
> >
> > again.
> >
> > Marcin
> >
> > On 23.08.2017 12:41, Gokulakrishnan Gopalakrishnan wrote:
> > > Thanks Marcin, I just did what you mentioned in the code and
> > > printed *iface_configuation->str()* and it prints an empty
> array
> > > interface. Probably because I didn't link the hook user_chk
> > > with *libkea-dhcpsrv*.
> > > I tried linking* **libkea-dhcpsrv *by adding
> > >
> > > libdhcp_user_chk_la_LIBADD +=
> > $(top_builddir)/src/lib/hooks/libkea-dhcpsrv.la
> > <http://libkea-dhcpsrv.la> <http://libkea-dhcpsrv.la>
> > >
> > > in src/hooks/dhcp/user_chk/Makefile.am <http://efile.am> and
> > did a make.
> > >
> > > I'm getting automake-1.14: command not found. Every time
> editing
> > > Makefile.am, I'm getting this error. Am I doing the linking
> > correctly?
> > > Am I missing something here? Please correct me if I'm wrong
> > >
> > >
> > >
> > >
> > > On Wed, Aug 23, 2017 at 3:09 PM, Marcin Siodelski
> > <marcin at isc.org <mailto:marcin at isc.org>
> > > <mailto:marcin at isc.org <mailto:marcin at isc.org>>> wrote:
> > >
> > > On 23.08.2017 11:24, Gokulakrishnan Gopalakrishnan wrote:
> > > > "interfaces-config": {
> > > >
> > > > "interfaces": [ "eth0" ]
> > > >
> > > > }
> > > >
> > > > Can we get the list of interface name in hooks code? In
> > the example
> > > > mentioned above, can we get the value "eth0" in hooks
> > code in
> > > > <int load(LibraryHandle&)> function?
> > > >
> > > >
> > >
> > > To retrieve server configuration information you'd need to
> > link your
> > > hook library with libkea-dhcpsrv and do something like
> this:
> > >
> > > #include <dhcpsrv/cfg_iface.h>
> > >
> > > ConstCfgIfacePtr cfg =
> > > CfgMgr::instance().getCurrentCfg()->getCfgIface();
> > > ElementPtr iface_configuation = cfg->toElement();
> > >
> > > The iface_configuration will now hold the conifguration
> > structure you're
> > > looking for.
> > >
> > > Marcin Siodelski
> > > ISC
> > >
> > >
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/kea-users/attachments/20170824/8034a7dd/attachment.htm>
More information about the Kea-users
mailing list