Fix compilation problems and issue #20
- Netlink is disabled per default (compile with WITH_ND_NETLINK) - Automatic loading of routes is only done if at least one rule uses the "auto" setting.
This commit is contained in:
parent
ce3815d954
commit
8a8f7b065c
12
Makefile
12
Makefile
@ -11,13 +11,17 @@ MANDIR ?= ${DESTDIR}${PREFIX}/share/man
|
|||||||
SBINDIR ?= ${DESTDIR}${PREFIX}/sbin
|
SBINDIR ?= ${DESTDIR}${PREFIX}/sbin
|
||||||
PKG_CONFIG ?= pkg-config
|
PKG_CONFIG ?= pkg-config
|
||||||
|
|
||||||
LIBS = `${PKG_CONFIG} --libs glib-2.0 libnl-3.0 libnl-route-3.0` -pthread
|
|
||||||
CPPFLAGS = `${PKG_CONFIG} --cflags glib-2.0 libnl-3.0 libnl-route-3.0`
|
|
||||||
|
|
||||||
OBJS = src/logger.o src/ndppd.o src/iface.o src/proxy.o src/address.o \
|
OBJS = src/logger.o src/ndppd.o src/iface.o src/proxy.o src/address.o \
|
||||||
src/rule.o src/session.o src/conf.o src/route.o src/nd-netlink.o
|
src/rule.o src/session.o src/conf.o src/route.o
|
||||||
|
|
||||||
all: ndppd ndppd.1.gz ndppd.conf.5.gz nd-proxy
|
ifdef WITH_ND_NETLINK
|
||||||
|
LIBS = `${PKG_CONFIG} --libs glib-2.0 libnl-3.0 libnl-route-3.0` -pthread
|
||||||
|
CPPFLAGS = `${PKG_CONFIG} --cflags glib-2.0 libnl-3.0 libnl-route-3.0`
|
||||||
|
OBJ = ${OBJ} src/nd-netlink.o
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: ndppd ndppd.1.gz ndppd.conf.5.gz
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
mkdir -p ${SBINDIR} ${MANDIR} ${MANDIR}/man1 ${MANDIR}/man5
|
mkdir -p ${SBINDIR} ${MANDIR} ${MANDIR}/man1 ${MANDIR}/man5
|
||||||
|
@ -286,7 +286,9 @@ int main(int argc, char* argv[], char* env[])
|
|||||||
|
|
||||||
gettimeofday(&t1, 0);
|
gettimeofday(&t1, 0);
|
||||||
|
|
||||||
|
#ifdef WITH_ND_NETLINK
|
||||||
netlink_setup();
|
netlink_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
if (iface::poll_all() < 0) {
|
if (iface::poll_all() < 0) {
|
||||||
@ -306,11 +308,16 @@ int main(int argc, char* argv[], char* env[])
|
|||||||
t1.tv_sec = t2.tv_sec;
|
t1.tv_sec = t2.tv_sec;
|
||||||
t1.tv_usec = t2.tv_usec;
|
t1.tv_usec = t2.tv_usec;
|
||||||
|
|
||||||
route::update(elapsed_time);
|
if (rule::any_auto())
|
||||||
|
route::update(elapsed_time);
|
||||||
|
|
||||||
session::update_all(elapsed_time);
|
session::update_all(elapsed_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_ND_NETLINK
|
||||||
netlink_teardown();
|
netlink_teardown();
|
||||||
|
#endif
|
||||||
|
|
||||||
logger::notice() << "Bye";
|
logger::notice() << "Bye";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -126,11 +126,13 @@ void proxy::handle_solicit(const address& saddr, const address& daddr,
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
se->add_iface((*it)->ifa());
|
se->add_iface((*it)->ifa());
|
||||||
|
#ifdef WITH_ND_NETLINK
|
||||||
if (if_addr_find((*it)->ifa()->name(), &taddr.const_addr())) {
|
if (if_addr_find((*it)->ifa()->name(), &taddr.const_addr())) {
|
||||||
logger::debug() << "Sending NA out " << (*it)->ifa()->name();
|
logger::debug() << "Sending NA out " << (*it)->ifa()->name();
|
||||||
se->add_iface(_ifa);
|
se->add_iface(_ifa);
|
||||||
se->handle_advert();
|
se->handle_advert();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/rule.cc
12
src/rule.cc
@ -27,6 +27,8 @@ NDPPD_NS_BEGIN
|
|||||||
|
|
||||||
std::vector<interface> interfaces;
|
std::vector<interface> interfaces;
|
||||||
|
|
||||||
|
bool rule::_any_aut = false;
|
||||||
|
|
||||||
rule::rule()
|
rule::rule()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -42,9 +44,13 @@ ptr<rule> rule::create(const ptr<proxy>& pr, const address& addr, const ptr<ifac
|
|||||||
unsigned int ifindex;
|
unsigned int ifindex;
|
||||||
|
|
||||||
ifindex = if_nametoindex(pr->ifa()->name().c_str());
|
ifindex = if_nametoindex(pr->ifa()->name().c_str());
|
||||||
|
#ifdef WITH_ND_NETLINK
|
||||||
if_add_to_list(ifindex, pr->ifa());
|
if_add_to_list(ifindex, pr->ifa());
|
||||||
|
#endif
|
||||||
ifindex = if_nametoindex(ifa->name().c_str());
|
ifindex = if_nametoindex(ifa->name().c_str());
|
||||||
|
#ifdef WITH_ND_NETLINK
|
||||||
if_add_to_list(ifindex, ifa);
|
if_add_to_list(ifindex, ifa);
|
||||||
|
#endif
|
||||||
|
|
||||||
logger::debug() << "rule::create() if=" << pr->ifa()->name() << ", addr=" << addr;
|
logger::debug() << "rule::create() if=" << pr->ifa()->name() << ", addr=" << addr;
|
||||||
|
|
||||||
@ -58,6 +64,7 @@ ptr<rule> rule::create(const ptr<proxy>& pr, const address& addr, bool aut)
|
|||||||
ru->_pr = pr;
|
ru->_pr = pr;
|
||||||
ru->_addr = addr;
|
ru->_addr = addr;
|
||||||
ru->_aut = aut;
|
ru->_aut = aut;
|
||||||
|
_any_aut = _any_aut || aut;
|
||||||
|
|
||||||
logger::debug()
|
logger::debug()
|
||||||
<< "rule::create() if=" << pr->ifa()->name().c_str() << ", addr=" << addr
|
<< "rule::create() if=" << pr->ifa()->name().c_str() << ", addr=" << addr
|
||||||
@ -81,6 +88,11 @@ bool rule::is_auto() const
|
|||||||
return _aut;
|
return _aut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rule::any_auto()
|
||||||
|
{
|
||||||
|
return _any_aut;
|
||||||
|
}
|
||||||
|
|
||||||
bool rule::check(const address& addr) const
|
bool rule::check(const address& addr) const
|
||||||
{
|
{
|
||||||
return _addr == addr;
|
return _addr == addr;
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
|
|
||||||
bool check(const address& addr) const;
|
bool check(const address& addr) const;
|
||||||
|
|
||||||
|
static bool any_auto();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
weak_ptr<rule> _ptr;
|
weak_ptr<rule> _ptr;
|
||||||
|
|
||||||
@ -54,6 +56,8 @@ private:
|
|||||||
|
|
||||||
bool _aut;
|
bool _aut;
|
||||||
|
|
||||||
|
static bool _any_aut;
|
||||||
|
|
||||||
rule();
|
rule();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user