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