22 #include <sys/types.h> 23 #include <sys/socket.h> 24 #include <linux/if_packet.h> 25 #include <net/ethernet.h> 38 prefix_ void senf::ppi::IOEvent::v_enable()
44 prefix_ void senf::ppi::IOEvent::v_disable()
50 prefix_ void senf::ppi::IOEvent::cb(
int event)
55 socklen_t len (
sizeof(err));
56 if (::getsockopt(fd_, SOL_SOCKET, SO_ERROR, &err, &len) < 0)
59 sockaddr *addr =
reinterpret_cast<sockaddr*
>(buf);
62 if (::getsockname(fd_, addr, &len) == 0) {
63 if (addr->sa_family == AF_PACKET) {
64 sockaddr_ll *sa =
reinterpret_cast<sockaddr_ll*
>(addr);
65 if (sa->sll_ifindex > 0) {
68 if (::if_indextoname(sa->sll_ifindex, name))
71 msg =
"if_index=" + senf::str(sa->sll_ifindex);
73 msg =
"if_index is 0";
76 msg =
"sa_family=" + senf::str(addr->sa_family);
79 msg =
"getsockname() failed";
82 if (err == ENETDOWN) {
83 SENF_LOG ( (
senf::log::IMPORTANT) (
"ENETDOWN on fd " << fd_ <<
" (" << msg <<
") received. Disabling event. This might be due to a race condition.") );
87 throw ErrorException(fd_, err, msg);
91 throw HangupException();
92 SENF_ASSERT(
false,
"Internal failure: IOEvent::cb() called with invalid flag??");
94 IOEventInfo info = {
event };
void callback(EventArg event, ClockService::clock_type time)
Forward event to user callback.
FdEvent & events(int events)
#define SENF_ASSERT(x, comment)
unspecified_keyword_type name
bool enabled() const
Check, whether the event is currently enabled.