X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FRaw%2FLLAddressing.cc;h=71addad08a07eba5e41b91c346743fe5f4e33ea5;hb=81f84badf27b66dbadec9890646ca1193e998505;hp=13038c38798f1c7e77c487b70980ff8d79c9f37a;hpb=cd019de7e5d80122a302577c1907e2a952249260;p=senf.git diff --git a/Socket/Protocols/Raw/LLAddressing.cc b/Socket/Protocols/Raw/LLAddressing.cc index 13038c3..71addad 100644 --- a/Socket/Protocols/Raw/LLAddressing.cc +++ b/Socket/Protocols/Raw/LLAddressing.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 // it under the terms of the GNU General Public License as published by @@ -34,7 +34,8 @@ #include #include -#include "Utils/Exception.hh" +#include "../../../Utils/Exception.hh" +#include "../AddressExceptions.hh" //#include "LLAddressing.mpp" #define prefix_ @@ -46,22 +47,39 @@ 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); } -prefix_ void senf::LLSocketAddress::interface(std::string iface) +prefix_ void senf::LLSocketAddress::interface(std::string const & iface) { if (iface.empty()) addr_.sll_ifindex = 0; 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"