* Added Haiku specific socket ioctls to configure the interface aliases:
SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_REMOVE, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET, and SIOC_IF_ALIAS_COUNT. * Implemented all of those new ioctls, though they are yet untested. * Added ifreq::ifr_data, and removed the hack in the FreeBSD compat if.h header. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5b2bb28ea1
commit
9d771afb39
@ -31,7 +31,7 @@ struct ifreq_stats {
|
||||
};
|
||||
|
||||
struct ifreq {
|
||||
char ifr_name[IF_NAMESIZE];
|
||||
char ifr_name[IF_NAMESIZE];
|
||||
union {
|
||||
struct sockaddr ifr_addr;
|
||||
struct sockaddr ifr_dstaddr;
|
||||
@ -39,21 +39,27 @@ struct ifreq {
|
||||
struct sockaddr ifr_mask;
|
||||
struct ifreq_stats ifr_stats;
|
||||
struct route_entry ifr_route;
|
||||
int ifr_flags;
|
||||
int ifr_index;
|
||||
int ifr_metric;
|
||||
int ifr_mtu;
|
||||
int ifr_media;
|
||||
int ifr_type;
|
||||
int ifr_reqcap;
|
||||
int ifr_flags;
|
||||
int ifr_index;
|
||||
int ifr_metric;
|
||||
int ifr_mtu;
|
||||
int ifr_media;
|
||||
int ifr_type;
|
||||
int ifr_reqcap;
|
||||
int ifr_count;
|
||||
uint8_t* ifr_data;
|
||||
};
|
||||
};
|
||||
|
||||
/* used with SIOCAIFADDR */
|
||||
/* used with SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET */
|
||||
struct ifaliasreq {
|
||||
char ifra_name[IF_NAMESIZE];
|
||||
char ifra_name[IF_NAMESIZE];
|
||||
int ifra_index;
|
||||
struct sockaddr_storage ifra_addr;
|
||||
struct sockaddr_storage ifra_broadaddr;
|
||||
union {
|
||||
struct sockaddr_storage ifra_broadaddr;
|
||||
struct sockaddr_storage ifra_destination;
|
||||
};
|
||||
struct sockaddr_storage ifra_mask;
|
||||
};
|
||||
|
||||
@ -72,12 +78,13 @@ struct ifaliasreq {
|
||||
#define IFF_CONFIGURING 0x4000 /* auto configuration in progress */
|
||||
#define IFF_MULTICAST 0x8000 /* supports multicast */
|
||||
|
||||
/* used with SIOCGIFCOUNT, and SIOCGIFCONF */
|
||||
struct ifconf {
|
||||
int ifc_len; /* size of buffer */
|
||||
int ifc_len; /* size of buffer */
|
||||
union {
|
||||
void *ifc_buf;
|
||||
struct ifreq *ifc_req;
|
||||
int ifc_value;
|
||||
void* ifc_buf;
|
||||
struct ifreq* ifc_req;
|
||||
int ifc_value;
|
||||
};
|
||||
};
|
||||
|
||||
@ -88,8 +95,8 @@ struct ifconf {
|
||||
/* POSIX definitions follow */
|
||||
|
||||
struct if_nameindex {
|
||||
unsigned if_index; /* positive interface index */
|
||||
char *if_name; /* interface name, ie. "loopback" */
|
||||
unsigned if_index; /* positive interface index */
|
||||
char* if_name; /* interface name, ie. "loopback" */
|
||||
};
|
||||
|
||||
|
||||
@ -97,13 +104,14 @@ struct if_nameindex {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned if_nametoindex(const char *name);
|
||||
char *if_indextoname(unsigned index, char *nameBuffer);
|
||||
struct if_nameindex *if_nameindex(void);
|
||||
void if_freenameindex(struct if_nameindex *interfaceArray);
|
||||
unsigned if_nametoindex(const char* name);
|
||||
char* if_indextoname(unsigned index, char* nameBuffer);
|
||||
struct if_nameindex* if_nameindex(void);
|
||||
void if_freenameindex(struct if_nameindex* interfaceArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _NET_IF_H */
|
||||
|
@ -6,59 +6,73 @@
|
||||
#define _SYS_SOCKIO_H
|
||||
|
||||
|
||||
#define SIOCADDRT 8900 /* add route */
|
||||
#define SIOCDELRT 8901 /* delete route */
|
||||
#define SIOCSIFADDR 8902 /* set interface address */
|
||||
#define SIOCGIFADDR 8903 /* get interface address */
|
||||
#define SIOCSIFDSTADDR 8904 /* set point-to-point address */
|
||||
#define SIOCGIFDSTADDR 8905 /* get point-to-point address */
|
||||
#define SIOCSIFFLAGS 8906 /* set interface flags */
|
||||
#define SIOCGIFFLAGS 8907 /* get interface flags */
|
||||
#define SIOCGIFBRDADDR 8908 /* get broadcast address */
|
||||
#define SIOCSIFBRDADDR 8909 /* set broadcast address */
|
||||
#define SIOCGIFCOUNT 8910 /* count interfaces */
|
||||
#define SIOCGIFCONF 8911 /* get interface list */
|
||||
#define SIOCGIFINDEX 8912 /* interface name -> index */
|
||||
#define SIOCGIFNAME 8913 /* interface index -> name */
|
||||
#define SIOCGIFNETMASK 8914 /* get net address mask */
|
||||
#define SIOCSIFNETMASK 8915 /* set net address mask */
|
||||
#define SIOCGIFMETRIC 8916 /* get interface metric */
|
||||
#define SIOCSIFMETRIC 8917 /* set interface metric */
|
||||
#define SIOCDIFADDR 8918 /* delete interface address */
|
||||
#define SIOCAIFADDR 8919 /* configure interface alias */
|
||||
#define SIOCADDMULTI 8920 /* add multicast address */
|
||||
#define SIOCDELMULTI 8921 /* delete multicast address */
|
||||
#define SIOCGIFMTU 8922 /* get interface MTU */
|
||||
#define SIOCSIFMTU 8923 /* set interface MTU */
|
||||
#define SIOCSIFMEDIA 8924 /* set net media */
|
||||
#define SIOCGIFMEDIA 8925 /* get net media */
|
||||
/*! Socket I/O control codes, usually via struct ifreq */
|
||||
|
||||
#define SIOCGRTSIZE 8926 /* get route table size */
|
||||
#define SIOCGRTTABLE 8927 /* get route table */
|
||||
#define SIOCGETRT 8928 /* get route information for destination */
|
||||
|
||||
#define SIOCGIFSTATS 8929 /* get interface stats */
|
||||
#define SIOCGIFTYPE 8931 /* get interface type */
|
||||
#define SIOCADDRT 8900 /* add route */
|
||||
#define SIOCDELRT 8901 /* delete route */
|
||||
#define SIOCSIFADDR 8902 /* set interface address */
|
||||
#define SIOCGIFADDR 8903 /* get interface address */
|
||||
#define SIOCSIFDSTADDR 8904 /* set point-to-point address */
|
||||
#define SIOCGIFDSTADDR 8905 /* get point-to-point address */
|
||||
#define SIOCSIFFLAGS 8906 /* set interface flags */
|
||||
#define SIOCGIFFLAGS 8907 /* get interface flags */
|
||||
#define SIOCGIFBRDADDR 8908 /* get broadcast address */
|
||||
#define SIOCSIFBRDADDR 8909 /* set broadcast address */
|
||||
#define SIOCGIFCOUNT 8910 /* count interfaces */
|
||||
#define SIOCGIFCONF 8911 /* get interface list */
|
||||
#define SIOCGIFINDEX 8912 /* interface name -> index */
|
||||
#define SIOCGIFNAME 8913 /* interface index -> name */
|
||||
#define SIOCGIFNETMASK 8914 /* get net address mask */
|
||||
#define SIOCSIFNETMASK 8915 /* set net address mask */
|
||||
#define SIOCGIFMETRIC 8916 /* get interface metric */
|
||||
#define SIOCSIFMETRIC 8917 /* set interface metric */
|
||||
#define SIOCDIFADDR 8918 /* delete interface address */
|
||||
#define SIOCAIFADDR 8919
|
||||
/* configure interface alias, ifaliasreq */
|
||||
#define SIOCADDMULTI 8920 /* add multicast address */
|
||||
#define SIOCDELMULTI 8921 /* delete multicast address */
|
||||
#define SIOCGIFMTU 8922 /* get interface MTU */
|
||||
#define SIOCSIFMTU 8923 /* set interface MTU */
|
||||
#define SIOCSIFMEDIA 8924 /* set net media */
|
||||
#define SIOCGIFMEDIA 8925 /* get net media */
|
||||
|
||||
#define SIOCSPACKETCAP 8932 /* Start capturing packets on an interface */
|
||||
#define SIOCCPACKETCAP 8933 /* Stop capturing packets on an interface */
|
||||
#define SIOCGRTSIZE 8926 /* get route table size */
|
||||
#define SIOCGRTTABLE 8927 /* get route table */
|
||||
#define SIOCGETRT 8928
|
||||
/* get route information for destination */
|
||||
|
||||
#define SIOCSHIWAT 8934 /* set high watermark */
|
||||
#define SIOCGHIWAT 8935 /* get high watermark */
|
||||
#define SIOCSLOWAT 8936 /* set low watermark */
|
||||
#define SIOCGLOWAT 8937 /* get low watermark */
|
||||
#define SIOCATMARK 8938 /* at out-of-band mark? */
|
||||
#define SIOCSPGRP 8939 /* set process group */
|
||||
#define SIOCGPGRP 8940 /* get process group */
|
||||
#define SIOCGIFSTATS 8929 /* get interface stats */
|
||||
#define SIOCGIFTYPE 8931 /* get interface type */
|
||||
|
||||
#define SIOCGPRIVATE_0 8941 /* device private 0 */
|
||||
#define SIOCGPRIVATE_1 8942 /* device private 1 */
|
||||
#define SIOCSDRVSPEC 8943 /* set driver-specific parameters */
|
||||
#define SIOCGDRVSPEC 8944 /* get driver-specific parameters */
|
||||
#define SIOCSPACKETCAP 8932
|
||||
/* Start capturing packets on an interface */
|
||||
#define SIOCCPACKETCAP 8933
|
||||
/* Stop capturing packets on an interface */
|
||||
|
||||
#define SIOCSIFGENERIC 8945 /* generic IF set op */
|
||||
#define SIOCGIFGENERIC 8946 /* generic IF get op */
|
||||
#define SIOCSHIWAT 8934 /* set high watermark */
|
||||
#define SIOCGHIWAT 8935 /* get high watermark */
|
||||
#define SIOCSLOWAT 8936 /* set low watermark */
|
||||
#define SIOCGLOWAT 8937 /* get low watermark */
|
||||
#define SIOCATMARK 8938 /* at out-of-band mark? */
|
||||
#define SIOCSPGRP 8939 /* set process group */
|
||||
#define SIOCGPGRP 8940 /* get process group */
|
||||
|
||||
#define SIOCGPRIVATE_0 8941 /* device private 0 */
|
||||
#define SIOCGPRIVATE_1 8942 /* device private 1 */
|
||||
#define SIOCSDRVSPEC 8943 /* set driver-specific parameters */
|
||||
#define SIOCGDRVSPEC 8944 /* get driver-specific parameters */
|
||||
|
||||
#define SIOCSIFGENERIC 8945 /* generic IF set op */
|
||||
#define SIOCGIFGENERIC 8946 /* generic IF get op */
|
||||
|
||||
#define SIOC_IF_ALIAS_REMOVE 8918 /* synonym for SIOCDIFADDR */
|
||||
#define SIOC_IF_ALIAS_ADD 8919 /* synonym for SIOCAIFADDR */
|
||||
#define SIOC_IF_ALIAS_SET 8947 /* set interface alias, ifaliasreq */
|
||||
#define SIOC_IF_ALIAS_GET 8948 /* get interface alias, ifaliasreq */
|
||||
#define SIOC_IF_ALIAS_COUNT 8959 /* count interface aliases */
|
||||
|
||||
#define SIOCEND 9000 /* SIOCEND >= highest SIOC* */
|
||||
|
||||
#define SIOCEND 9000 /* SIOCEND >= highest SIOC* */
|
||||
|
||||
#endif /* _SYS_SOCKIO_H */
|
||||
|
@ -159,6 +159,23 @@ get_interface_name_or_index(net_domain* domain, int32 option, void* value,
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
fill_address(const sockaddr* from, sockaddr* to, size_t maxLength)
|
||||
{
|
||||
if (from != NULL) {
|
||||
// Copy address over
|
||||
return user_memcpy(to, from, min_c(from->sa_len, maxLength));
|
||||
}
|
||||
|
||||
// Fill in empty address
|
||||
sockaddr empty;
|
||||
empty.sa_len = 2;
|
||||
empty.sa_family = AF_UNSPEC;
|
||||
|
||||
return user_memcpy(to, &empty, min_c(2, maxLength));
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - datalink module
|
||||
|
||||
|
||||
@ -180,7 +197,7 @@ datalink_control(net_domain* _domain, int32 option, void* value,
|
||||
case SIOCGIFNAME:
|
||||
return get_interface_name_or_index(domain, option, value, _length);
|
||||
|
||||
case SIOCAIFADDR:
|
||||
case SIOCAIFADDR: /* same as SIOC_IF_ALIAS_ADD */
|
||||
{
|
||||
// add new interface address
|
||||
if (*_length < sizeof(struct ifaliasreq))
|
||||
@ -203,7 +220,7 @@ datalink_control(net_domain* _domain, int32 option, void* value,
|
||||
net_device_interface* deviceInterface
|
||||
= get_device_interface(request.ifra_name);
|
||||
if (deviceInterface == NULL)
|
||||
return ENODEV;
|
||||
return B_DEVICE_NOT_FOUND;
|
||||
|
||||
status_t status = add_interface(request.ifra_name, domain, request,
|
||||
deviceInterface);
|
||||
@ -212,7 +229,7 @@ datalink_control(net_domain* _domain, int32 option, void* value,
|
||||
return status;
|
||||
}
|
||||
|
||||
case SIOCDIFADDR:
|
||||
case SIOCDIFADDR: /* same as SIOC_IF_ALIAS_REMOVE */
|
||||
{
|
||||
// remove interface (address)
|
||||
struct ifreq request;
|
||||
@ -727,18 +744,48 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
|
||||
|
||||
size_t maxLength = length - offsetof(ifreq, ifr_addr);
|
||||
|
||||
sockaddr* address = *interfaceAddress->AddressFor(option);
|
||||
if (address != NULL) {
|
||||
// Copy address over
|
||||
return user_memcpy(&((struct ifreq*)argument)->ifr_addr,
|
||||
address, min_c(address->sa_len, maxLength));
|
||||
return fill_address(*interfaceAddress->AddressFor(option),
|
||||
&((struct ifreq*)argument)->ifr_addr, maxLength);
|
||||
}
|
||||
|
||||
case SIOC_IF_ALIAS_COUNT:
|
||||
{
|
||||
ifreq request;
|
||||
request.ifr_count = interface->CountAddresses();
|
||||
|
||||
return user_memcpy(&((struct ifreq*)argument)->ifr_count,
|
||||
&request.ifr_count, sizeof(request.ifr_count));
|
||||
}
|
||||
|
||||
case SIOC_IF_ALIAS_GET:
|
||||
{
|
||||
ifaliasreq request;
|
||||
if (user_memcpy(&request, argument, sizeof(ifaliasreq)) != B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
InterfaceAddress* address
|
||||
= interface->AddressAt(request.ifra_index);
|
||||
if (address == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
status_t status = fill_address(address->local,
|
||||
(sockaddr*)&((struct ifaliasreq*)argument)->ifra_addr,
|
||||
sizeof(sockaddr_storage));
|
||||
if (status == B_OK) {
|
||||
status = fill_address(address->mask,
|
||||
(sockaddr*)&((struct ifaliasreq*)argument)->ifra_mask,
|
||||
sizeof(sockaddr_storage));
|
||||
}
|
||||
if (status == B_OK) {
|
||||
status = fill_address(address->destination,
|
||||
(sockaddr*)&((struct ifaliasreq*)argument)
|
||||
->ifra_destination,
|
||||
sizeof(sockaddr_storage));
|
||||
}
|
||||
|
||||
// Fill in empty address
|
||||
request.ifr_addr.sa_len = 2;
|
||||
request.ifr_addr.sa_family = AF_UNSPEC;
|
||||
return user_memcpy(&((struct ifreq*)argument)->ifr_addr,
|
||||
&request.ifr_addr, min_c(2, maxLength));
|
||||
address->ReleaseReference();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
case SIOCGIFFLAGS:
|
||||
|
@ -18,9 +18,7 @@
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <lock.h>
|
||||
#include <net_device.h>
|
||||
#include <util/AutoLock.h>
|
||||
|
||||
#include "device_interfaces.h"
|
||||
#include "domains.h"
|
||||
@ -516,6 +514,40 @@ Interface::GetNextAddress(InterfaceAddress** _address)
|
||||
}
|
||||
|
||||
|
||||
InterfaceAddress*
|
||||
Interface::AddressAt(size_t index)
|
||||
{
|
||||
RecursiveLocker locker(fLock);
|
||||
|
||||
AddressList::Iterator iterator = fAddresses.GetIterator();
|
||||
size_t i = 0;
|
||||
|
||||
while (InterfaceAddress* address = iterator.Next()) {
|
||||
if (i++ == index) {
|
||||
address->AcquireReference();
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
Interface::CountAddresses()
|
||||
{
|
||||
RecursiveLocker locker(fLock);
|
||||
return fAddresses.Count();
|
||||
}
|
||||
|
||||
|
||||
/*! This is called in order to call the correct methods of the datalink
|
||||
protocols, ie. it will translate address changes to
|
||||
net_datalink_protocol::change_address(), and IFF_UP changes to
|
||||
net_datalink_protocol::interface_up(), and interface_down().
|
||||
|
||||
Everything else is passed unchanged to net_datalink_protocol::control().
|
||||
*/
|
||||
status_t
|
||||
Interface::Control(net_domain* domain, int32 option, ifreq& request,
|
||||
ifreq* userRequest, size_t length)
|
||||
@ -549,6 +581,51 @@ Interface::Control(net_domain* domain, int32 option, ifreq& request,
|
||||
return status;
|
||||
}
|
||||
|
||||
case SIOC_IF_ALIAS_SET:
|
||||
{
|
||||
RecursiveLocker locker(fLock);
|
||||
|
||||
ifaliasreq aliasRequest;
|
||||
if (user_memcpy(&aliasRequest, userRequest, sizeof(ifaliasreq))
|
||||
!= B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
InterfaceAddress* address = AddressAt(aliasRequest.ifra_index);
|
||||
if (address == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
status_t status = B_OK;
|
||||
address->AcquireReference();
|
||||
// _ChangeAddress() currently unlocks, so we need another
|
||||
// reference to make sure "address" is not going away.
|
||||
|
||||
if (!domain->address_module->equal_addresses(
|
||||
(sockaddr*)&aliasRequest.ifra_addr, address->local)) {
|
||||
status = _ChangeAddress(locker, address, SIOCSIFADDR,
|
||||
address->local, (sockaddr*)&aliasRequest.ifra_addr);
|
||||
}
|
||||
|
||||
if (status == B_OK && !domain->address_module->equal_addresses(
|
||||
(sockaddr*)&aliasRequest.ifra_mask, address->mask)) {
|
||||
status = _ChangeAddress(locker, address, SIOCSIFNETMASK,
|
||||
address->mask, (sockaddr*)&aliasRequest.ifra_mask);
|
||||
}
|
||||
|
||||
if (status == B_OK && !domain->address_module->equal_addresses(
|
||||
(sockaddr*)&aliasRequest.ifra_destination,
|
||||
address->destination)) {
|
||||
status = _ChangeAddress(locker, address,
|
||||
(domain->address_module->flags
|
||||
& NET_ADDRESS_MODULE_FLAG_BROADCAST_ADDRESS) != 0
|
||||
? SIOCSIFBRDADDR : SIOCSIFDSTADDR,
|
||||
address->destination,
|
||||
(sockaddr*)&aliasRequest.ifra_destination);
|
||||
}
|
||||
|
||||
address->ReleaseReference();
|
||||
return status;
|
||||
}
|
||||
|
||||
case SIOCSIFADDR:
|
||||
case SIOCSIFNETMASK:
|
||||
case SIOCSIFBRDADDR:
|
||||
@ -558,7 +635,6 @@ Interface::Control(net_domain* domain, int32 option, ifreq& request,
|
||||
RecursiveLocker locker(fLock);
|
||||
|
||||
InterfaceAddress* address = NULL;
|
||||
sockaddr_storage oldAddress;
|
||||
sockaddr_storage newAddress;
|
||||
|
||||
size_t size = max_c(request.ifr_addr.sa_len, sizeof(sockaddr));
|
||||
@ -586,24 +662,9 @@ Interface::Control(net_domain* domain, int32 option, ifreq& request,
|
||||
if (address == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (*address->AddressFor(option) != NULL)
|
||||
memcpy(&oldAddress, *address->AddressFor(option), size);
|
||||
else
|
||||
oldAddress.ss_family = AF_UNSPEC;
|
||||
|
||||
// TODO: mark this address busy or call while holding the lock!
|
||||
address->AcquireReference();
|
||||
locker.Unlock();
|
||||
|
||||
domain_datalink* datalink = DomainDatalink(domain->family);
|
||||
status_t status = datalink->first_protocol->module->change_address(
|
||||
datalink->first_protocol, address, option,
|
||||
oldAddress.ss_family != AF_UNSPEC
|
||||
? (sockaddr*)&oldAddress : NULL,
|
||||
return _ChangeAddress(locker, address, option,
|
||||
*address->AddressFor(option),
|
||||
option != SIOCDIFADDR ? (sockaddr*)&newAddress : NULL);
|
||||
|
||||
address->ReleaseReference();
|
||||
return status;
|
||||
}
|
||||
|
||||
default:
|
||||
@ -787,6 +848,33 @@ Interface::_FirstForFamily(int family)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Interface::_ChangeAddress(RecursiveLocker& locker, InterfaceAddress* address,
|
||||
int32 option, const sockaddr* originalAddress, const sockaddr* newAddress)
|
||||
{
|
||||
// Copy old address over
|
||||
sockaddr_storage oldAddress;
|
||||
if (address->domain->address_module->set_to((sockaddr*)&oldAddress,
|
||||
originalAddress) != B_OK)
|
||||
oldAddress.ss_family = AF_UNSPEC;
|
||||
|
||||
// TODO: mark this address busy or call while holding the lock!
|
||||
address->AcquireReference();
|
||||
locker.Unlock();
|
||||
|
||||
domain_datalink* datalink = DomainDatalink(address->domain);
|
||||
status_t status = datalink->first_protocol->module->change_address(
|
||||
datalink->first_protocol, address, option,
|
||||
oldAddress.ss_family != AF_UNSPEC ? (sockaddr*)&oldAddress : NULL,
|
||||
newAddress != NULL && newAddress->sa_family != AF_UNSPEC
|
||||
? newAddress : NULL);
|
||||
|
||||
locker.Lock();
|
||||
address->ReleaseReference();
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
#include <util/AutoLock.h>
|
||||
#include <util/DoublyLinkedList.h>
|
||||
#include <util/OpenHashTable.h>
|
||||
|
||||
@ -118,6 +119,8 @@ public:
|
||||
status_t AddAddress(InterfaceAddress* address);
|
||||
void RemoveAddress(InterfaceAddress* address);
|
||||
bool GetNextAddress(InterfaceAddress** _address);
|
||||
InterfaceAddress* AddressAt(size_t index);
|
||||
size_t CountAddresses();
|
||||
|
||||
status_t Control(net_domain* domain, int32 option,
|
||||
ifreq& request, ifreq* userRequest,
|
||||
@ -141,7 +144,10 @@ private:
|
||||
status_t _SetUp();
|
||||
void _SetDown();
|
||||
InterfaceAddress* _FirstForFamily(int family);
|
||||
status_t _AddDomainDatalink(net_domain* domain);
|
||||
status_t _ChangeAddress(RecursiveLocker& locker,
|
||||
InterfaceAddress* address, int32 option,
|
||||
const sockaddr* oldAddress,
|
||||
const sockaddr* newAddress);
|
||||
|
||||
private:
|
||||
recursive_lock fLock;
|
||||
|
@ -6,43 +6,39 @@
|
||||
#define _FBSD_COMPAT_NET_IF_H_
|
||||
|
||||
|
||||
// Rename the ifreq structure provided by posix/net/if.h
|
||||
// so that we can add FreeBSD based ifreq parts.
|
||||
#define ifreq ifreq_haiku_unused
|
||||
#include <posix/net/if.h>
|
||||
#undef ifreq
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
#define IF_Kbps(x) ((x) * 1000)
|
||||
#define IF_Mbps(x) (IF_Kbps((x) * 1000))
|
||||
#define IF_Gbps(x) (IF_Mbps((x) * 1000))
|
||||
#define IF_Kbps(x) ((x) * 1000)
|
||||
#define IF_Mbps(x) (IF_Kbps((x) * 1000))
|
||||
#define IF_Gbps(x) (IF_Mbps((x) * 1000))
|
||||
|
||||
/* Capabilities that interfaces can advertise. */
|
||||
#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
|
||||
#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
|
||||
#define IFCAP_NETCONS 0x00004 /* can be a network console */
|
||||
#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */
|
||||
#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */
|
||||
#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */
|
||||
#define IFCAP_NETCONS 0x00004 /* can be a network console */
|
||||
#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */
|
||||
#define IFCAP_VLAN_HWTAGGING 0x00010 /* hardware VLAN tag support */
|
||||
#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */
|
||||
#define IFCAP_POLLING 0x00040 /* driver supports polling */
|
||||
#define IFCAP_VLAN_HWCSUM 0x00080
|
||||
#define IFCAP_TSO4 0x00100 /* supports TCP segmentation offload */
|
||||
#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */
|
||||
#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */
|
||||
#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */
|
||||
#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */
|
||||
#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */
|
||||
#define IFCAP_POLLING_NOCOUNT 0x20000
|
||||
#define IFCAP_VLAN_HWTSO 0x40000
|
||||
#define IFCAP_LINKSTATE 0x80000
|
||||
#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */
|
||||
#define IFCAP_POLLING 0x00040 /* driver supports polling */
|
||||
#define IFCAP_VLAN_HWCSUM 0x00080
|
||||
#define IFCAP_TSO4 0x00100 /* supports TCP segmentation offload */
|
||||
#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */
|
||||
#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */
|
||||
#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */
|
||||
#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */
|
||||
#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */
|
||||
#define IFCAP_POLLING_NOCOUNT 0x20000
|
||||
#define IFCAP_VLAN_HWTSO 0x40000
|
||||
#define IFCAP_LINKSTATE 0x80000
|
||||
|
||||
#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
|
||||
#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
|
||||
#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
|
||||
#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
|
||||
#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6)
|
||||
#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
|
||||
|
||||
|
||||
#define IFF_DRV_RUNNING 0x00010000
|
||||
@ -60,36 +56,14 @@
|
||||
#define IFQ_MAXLEN 50
|
||||
|
||||
|
||||
struct ifreq {
|
||||
char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
union {
|
||||
struct sockaddr ifr_addr;
|
||||
struct sockaddr ifr_dstaddr;
|
||||
struct sockaddr ifr_broadaddr;
|
||||
struct sockaddr ifr_mask;
|
||||
struct ifreq_stats ifr_stats;
|
||||
struct route_entry ifr_route;
|
||||
int ifr_flags;
|
||||
int ifr_index;
|
||||
int ifr_metric;
|
||||
int ifr_mtu;
|
||||
int ifr_media;
|
||||
int ifr_type;
|
||||
int ifr_reqcap;
|
||||
|
||||
// FreeBSD specific Part
|
||||
caddr_t ifr_data;
|
||||
};
|
||||
};
|
||||
|
||||
struct ifmediareq {
|
||||
char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
int ifm_current; /* current media options */
|
||||
int ifm_mask; /* don't care mask */
|
||||
int ifm_status; /* media status */
|
||||
int ifm_active; /* active options */
|
||||
int ifm_count; /* # entries in ifm_ulist array */
|
||||
int *ifm_ulist; /* media words */
|
||||
int ifm_current; /* current media options */
|
||||
int ifm_mask; /* don't care mask */
|
||||
int ifm_status; /* media status */
|
||||
int ifm_active; /* active options */
|
||||
int ifm_count; /* # entries in ifm_ulist array */
|
||||
int* ifm_ulist; /* media words */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -98,16 +72,16 @@ struct ifmediareq {
|
||||
*/
|
||||
struct if_data {
|
||||
/* generic interface information */
|
||||
u_char ifi_type; /* ethernet, tokenring, etc */
|
||||
u_char ifi_type; /* ethernet, tokenring, etc */
|
||||
u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */
|
||||
u_char ifi_addrlen; /* media address length */
|
||||
u_char ifi_hdrlen; /* media header length */
|
||||
u_char ifi_hdrlen; /* media header length */
|
||||
u_char ifi_link_state; /* current link state */
|
||||
u_char ifi_recvquota; /* polling quota for receive intrs */
|
||||
u_char ifi_xmitquota; /* polling quota for xmit intrs */
|
||||
u_char ifi_datalen; /* length of this data struct */
|
||||
u_long ifi_mtu; /* maximum transmission unit */
|
||||
u_long ifi_metric; /* routing metric (external only) */
|
||||
u_long ifi_mtu; /* maximum transmission unit */
|
||||
u_long ifi_metric; /* routing metric (external only) */
|
||||
u_long ifi_baudrate; /* linespeed */
|
||||
/* volatile statistics */
|
||||
u_long ifi_ipackets; /* packets received on interface */
|
||||
@ -115,14 +89,14 @@ struct if_data {
|
||||
u_long ifi_opackets; /* packets sent on interface */
|
||||
u_long ifi_oerrors; /* output errors on interface */
|
||||
u_long ifi_collisions; /* collisions on csma interfaces */
|
||||
u_long ifi_ibytes; /* total number of octets received */
|
||||
u_long ifi_obytes; /* total number of octets sent */
|
||||
u_long ifi_ibytes; /* total number of octets received */
|
||||
u_long ifi_obytes; /* total number of octets sent */
|
||||
u_long ifi_imcasts; /* packets received via multicast */
|
||||
u_long ifi_omcasts; /* packets sent via multicast */
|
||||
u_long ifi_iqdrops; /* dropped on input, this interface */
|
||||
u_long ifi_noproto; /* destined for unsupported protocol */
|
||||
u_long ifi_hwassist; /* HW offload capabilities */
|
||||
time_t ifi_epoch; /* uptime at attach or stat reset */
|
||||
time_t ifi_epoch; /* uptime at attach or stat reset */
|
||||
#ifdef __alpha__
|
||||
u_int ifi_timepad; /* time_t is int, not long on alpha */
|
||||
#endif
|
||||
@ -130,15 +104,16 @@ struct if_data {
|
||||
};
|
||||
|
||||
struct ifdrv {
|
||||
char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
unsigned long ifd_cmd;
|
||||
size_t ifd_len;
|
||||
void *ifd_data;
|
||||
char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
unsigned long ifd_cmd;
|
||||
size_t ifd_len;
|
||||
void* ifd_data;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* XXX - this should go away soon. */
|
||||
#include <net/if_var.h>
|
||||
/* TODO: this should go away soon. */
|
||||
# include <net/if_var.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FBSD_COMPAT_NET_IF_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user