PPI: Add missing TargetDgramWriter doku
[senf.git] / Socket / Protocols / Raw / LLAddressing.cc
index 97316c9..71addad 100644 (file)
@@ -47,6 +47,7 @@ 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 AddressSyntaxException();
     return std::string(name);
@@ -63,6 +64,22 @@ prefix_ void senf::LLSocketAddress::interface(std::string const & iface)
     }
 }
 
+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"