* Added alternatives to AddInterface()/RemoveInterface() that take the name

of the interface instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39591 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-11-23 21:01:19 +00:00
parent 6a75869303
commit 2977e7888f
2 changed files with 20 additions and 4 deletions

View File

@ -22,8 +22,10 @@ public:
status_t GetNextInterface(uint32* cookie,
BNetworkInterface& interface) const;
status_t AddInterface(const char* name);
status_t AddInterface(
const BNetworkInterface& interface);
status_t RemoveInterface(const char* name);
status_t RemoveInterface(
const BNetworkInterface& interface);

View File

@ -106,7 +106,7 @@ BNetworkRoster::GetNextInterface(uint32* cookie,
status_t
BNetworkRoster::AddInterface(const BNetworkInterface& interface)
BNetworkRoster::AddInterface(const char* name)
{
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
if (socket < 0)
@ -114,7 +114,7 @@ BNetworkRoster::AddInterface(const BNetworkInterface& interface)
ifaliasreq request;
memset(&request, 0, sizeof(ifaliasreq));
strlcpy(request.ifra_name, interface.Name(), IF_NAMESIZE);
strlcpy(request.ifra_name, name, IF_NAMESIZE);
if (ioctl(socket, SIOCAIFADDR, &request, sizeof(request)) != 0)
return errno;
@ -124,14 +124,21 @@ BNetworkRoster::AddInterface(const BNetworkInterface& interface)
status_t
BNetworkRoster::RemoveInterface(const BNetworkInterface& interface)
BNetworkRoster::AddInterface(const BNetworkInterface& interface)
{
return AddInterface(interface.Name());
}
status_t
BNetworkRoster::RemoveInterface(const char* name)
{
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
if (socket < 0)
return errno;
ifreq request;
strlcpy(request.ifr_name, interface.Name(), IF_NAMESIZE);
strlcpy(request.ifr_name, name, IF_NAMESIZE);
request.ifr_addr.sa_family = AF_UNSPEC;
@ -142,6 +149,13 @@ BNetworkRoster::RemoveInterface(const BNetworkInterface& interface)
}
status_t
BNetworkRoster::RemoveInterface(const BNetworkInterface& interface)
{
return RemoveInterface(interface.Name());
}
status_t
BNetworkRoster::StartWatching(const BMessenger& target, uint32 eventMask)
{