X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FRaw%2FLLAddressing.cc;h=71addad08a07eba5e41b91c346743fe5f4e33ea5;hb=81f84badf27b66dbadec9890646ca1193e998505;hp=63b671c94333a942365f33ffecb62b5d0d1df425;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Socket/Protocols/Raw/LLAddressing.cc b/Socket/Protocols/Raw/LLAddressing.cc index 63b671c..71addad 100644 --- a/Socket/Protocols/Raw/LLAddressing.cc +++ b/Socket/Protocols/Raw/LLAddressing.cc @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -35,6 +35,7 @@ #include #include "../../../Utils/Exception.hh" +#include "../AddressExceptions.hh" //#include "LLAddressing.mpp" #define prefix_ @@ -46,8 +47,9 @@ prefix_ std::string senf::LLSocketAddress::interface() if (addr_.sll_ifindex == 0) return std::string(); char name[IFNAMSIZ]; + ::bzero(name, IFNAMSIZ); if (! ::if_indextoname(addr_.sll_ifindex, name)) - throw InvalidLLSocketAddressException(); + throw AddressSyntaxException(); return std::string(name); } @@ -58,10 +60,26 @@ prefix_ void senf::LLSocketAddress::interface(std::string const & iface) else { addr_.sll_ifindex = if_nametoindex(iface.c_str()); if (addr_.sll_ifindex == 0) - throw InvalidLLSocketAddressException(); + throw AddressSyntaxException(); } } +prefix_ std::ostream & senf::operator<<(std::ostream & os, LLSocketAddress const & llAddr) +{ + os << "[" << llAddr.address() + << '%' << llAddr.interface() + << ' ' << llAddr.protocol() + << ' ' << llAddr.arptype() + << ( llAddr.pkttype() == senf::LLSocketAddress::Host ? " Host" : + llAddr.pkttype() == senf::LLSocketAddress::Broadcast ? " Broadcast" : + llAddr.pkttype() == senf::LLSocketAddress::Multicast ? " Multicast" : + llAddr.pkttype() == senf::LLSocketAddress::OtherHost ? " OtherHost" : + llAddr.pkttype() == senf::LLSocketAddress::Outgoing ? " Outgoing" : + llAddr.pkttype() == senf::LLSocketAddress::Broadcast ? "Broadcast" : "" ) + << "]"; + return os; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "LLAddressing.mpp"