* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -18,14 +18,9 @@
|
||||
typedef struct net_buffer {
|
||||
struct list_link link;
|
||||
|
||||
// TODO: we should think about moving the address fields into the buffer
|
||||
// data itself via associated data or something like this. Or this
|
||||
// structure as a whole, too...
|
||||
|
||||
struct sockaddr* source;
|
||||
struct sockaddr* destination;
|
||||
struct net_interface* interface;
|
||||
int32 type;
|
||||
struct net_interface_address* interface_address;
|
||||
union {
|
||||
struct {
|
||||
uint16 start;
|
||||
@@ -33,6 +28,7 @@ typedef struct net_buffer {
|
||||
} fragment;
|
||||
uint32 sequence;
|
||||
uint32 offset;
|
||||
int32 type;
|
||||
};
|
||||
uint32 flags;
|
||||
uint32 size;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef NET_DATALINK_H
|
||||
@@ -18,84 +18,98 @@
|
||||
|
||||
typedef struct net_datalink_protocol net_datalink_protocol;
|
||||
|
||||
typedef struct net_domain {
|
||||
const char *name;
|
||||
int family;
|
||||
struct list interfaces;
|
||||
|
||||
struct net_protocol_module_info *module;
|
||||
struct net_address_module_info *address_module;
|
||||
typedef struct net_domain {
|
||||
const char* name;
|
||||
int family;
|
||||
|
||||
struct net_protocol_module_info* module;
|
||||
struct net_address_module_info* address_module;
|
||||
} net_domain;
|
||||
|
||||
struct net_interface {
|
||||
struct list_link link;
|
||||
struct net_domain *domain;
|
||||
struct net_device *device;
|
||||
struct net_datalink_protocol *first_protocol;
|
||||
struct net_datalink_protocol_module_info *first_info;
|
||||
typedef struct net_interface_address {
|
||||
struct net_domain* domain;
|
||||
struct net_interface* interface;
|
||||
struct sockaddr* local;
|
||||
struct sockaddr* destination;
|
||||
struct sockaddr* mask;
|
||||
} net_interface_address;
|
||||
|
||||
typedef struct net_interface {
|
||||
struct net_device* device;
|
||||
|
||||
char name[IF_NAMESIZE];
|
||||
struct sockaddr *address;
|
||||
struct sockaddr *destination;
|
||||
struct sockaddr *mask;
|
||||
uint32 index;
|
||||
uint32 flags;
|
||||
uint8 type;
|
||||
uint32 mtu;
|
||||
uint32 metric;
|
||||
};
|
||||
} net_interface;
|
||||
|
||||
struct net_route {
|
||||
struct sockaddr *destination;
|
||||
struct sockaddr *mask;
|
||||
struct sockaddr *gateway;
|
||||
typedef struct net_route {
|
||||
struct sockaddr* destination;
|
||||
struct sockaddr* mask;
|
||||
struct sockaddr* gateway;
|
||||
uint32 flags;
|
||||
uint32 mtu;
|
||||
struct net_interface *interface;
|
||||
};
|
||||
struct net_interface_address* interface_address;
|
||||
} net_route;
|
||||
|
||||
struct net_route_info {
|
||||
typedef struct net_route_info {
|
||||
struct list_link link;
|
||||
struct net_route *route;
|
||||
struct net_route* route;
|
||||
struct sockaddr address;
|
||||
};
|
||||
} net_route_info;
|
||||
|
||||
|
||||
struct net_datalink_module_info {
|
||||
module_info info;
|
||||
|
||||
status_t (*control)(struct net_domain *domain, int32 option, void *value,
|
||||
size_t *_length);
|
||||
status_t (*send_data)(struct net_route *route, struct net_buffer *buffer);
|
||||
status_t (*send_datagram)(struct net_protocol *protocol,
|
||||
struct net_domain *domain, struct net_buffer *buffer);
|
||||
status_t (*control)(net_domain* domain, int32 option, void* value,
|
||||
size_t* _length);
|
||||
status_t (*send_data)(net_route* route, net_buffer* buffer);
|
||||
status_t (*send_datagram)(struct net_protocol* protocol,
|
||||
net_domain* domain, net_buffer* buffer);
|
||||
|
||||
bool (*is_local_address)(struct net_domain *domain,
|
||||
const struct sockaddr *address, net_interface **_interface,
|
||||
uint32 *_matchedType);
|
||||
bool (*is_local_link_address)(struct net_domain *domain, bool unconfigured,
|
||||
const struct sockaddr *address, net_interface **_interface);
|
||||
bool (*is_local_address)(net_domain* domain,
|
||||
const struct sockaddr* address,
|
||||
net_interface_address** _interfaceAddress,
|
||||
uint32* _matchedType);
|
||||
bool (*is_local_link_address)(net_domain* domain,
|
||||
bool unconfigured, const struct sockaddr* address,
|
||||
net_interface_address** _interfaceAddress);
|
||||
|
||||
net_interface *(*get_interface)(struct net_domain *domain, uint32 index);
|
||||
net_interface *(*get_interface_with_address)(struct net_domain *domain,
|
||||
const struct sockaddr *address);
|
||||
net_interface* (*get_interface)(net_domain* domain, uint32 index);
|
||||
net_interface* (*get_interface_with_address)(
|
||||
const struct sockaddr* address);
|
||||
void (*put_interface)(net_interface* interface);
|
||||
|
||||
net_interface_address* (*get_interface_address)(
|
||||
const struct sockaddr* address);
|
||||
bool (*get_next_interface_address)(net_interface* interface,
|
||||
net_interface_address** _address);
|
||||
void (*put_interface_address)(net_interface_address* address);
|
||||
|
||||
status_t (*join_multicast)(net_interface* interface,
|
||||
net_domain* domain, const struct sockaddr* address);
|
||||
status_t (*leave_multicast)(net_interface* interface,
|
||||
net_domain* domain, const struct sockaddr* address);
|
||||
|
||||
// routes
|
||||
status_t (*add_route)(struct net_domain *domain,
|
||||
const struct net_route *route);
|
||||
status_t (*remove_route)(struct net_domain *domain,
|
||||
const struct net_route *route);
|
||||
struct net_route *(*get_route)(struct net_domain *domain,
|
||||
const struct sockaddr *address);
|
||||
status_t (*get_buffer_route)(struct net_domain *domain,
|
||||
struct net_buffer *buffer, struct net_route **_route);
|
||||
void (*put_route)(struct net_domain *domain, struct net_route *route);
|
||||
status_t (*add_route)(net_domain* domain, const net_route* route);
|
||||
status_t (*remove_route)(net_domain* domain, const net_route* route);
|
||||
net_route* (*get_route)(net_domain* domain,
|
||||
const struct sockaddr* address);
|
||||
status_t (*get_buffer_route)(net_domain* domain,
|
||||
struct net_buffer* buffer, net_route** _route);
|
||||
void (*put_route)(net_domain* domain, net_route* route);
|
||||
|
||||
status_t (*register_route_info)(struct net_domain *domain,
|
||||
struct net_route_info *info);
|
||||
status_t (*unregister_route_info)(struct net_domain *domain,
|
||||
struct net_route_info *info);
|
||||
status_t (*update_route_info)(struct net_domain *domain,
|
||||
struct net_route_info *info);
|
||||
status_t (*register_route_info)(net_domain* domain,
|
||||
net_route_info* info);
|
||||
status_t (*unregister_route_info)(net_domain* domain,
|
||||
net_route_info* info);
|
||||
status_t (*update_route_info)(net_domain* domain,
|
||||
net_route_info* info);
|
||||
};
|
||||
|
||||
#define NET_ADDRESS_MODULE_FLAG_BROADCAST_ADDRESS 0x01
|
||||
@@ -104,47 +118,58 @@ struct net_address_module_info {
|
||||
module_info info;
|
||||
uint32 flags;
|
||||
|
||||
status_t (*copy_address)(const sockaddr *from, sockaddr **to,
|
||||
bool replaceWithZeros, const sockaddr *mask);
|
||||
status_t (*copy_address)(const struct sockaddr* from,
|
||||
struct sockaddr** to, bool replaceWithZeros,
|
||||
const struct sockaddr* mask);
|
||||
|
||||
status_t (*mask_address)(const sockaddr *address, const sockaddr *mask,
|
||||
sockaddr *result);
|
||||
status_t (*mask_address)(const struct sockaddr* address,
|
||||
const struct sockaddr* mask, struct sockaddr* result);
|
||||
|
||||
bool (*equal_addresses)(const sockaddr *a, const sockaddr *b);
|
||||
bool (*equal_ports)(const sockaddr *a, const sockaddr *b);
|
||||
bool (*equal_addresses_and_ports)(const sockaddr *a, const sockaddr *b);
|
||||
bool (*equal_masked_addresses)(const sockaddr *a, const sockaddr *b,
|
||||
const sockaddr *mask);
|
||||
bool (*is_empty_address)(const sockaddr *address, bool checkPort);
|
||||
bool (*is_same_family)(const sockaddr *address);
|
||||
bool (*equal_addresses)(const struct sockaddr* a,
|
||||
const struct sockaddr* b);
|
||||
bool (*equal_ports)(const struct sockaddr* a,
|
||||
const struct sockaddr* b);
|
||||
bool (*equal_addresses_and_ports)(const struct sockaddr* a,
|
||||
const struct sockaddr* b);
|
||||
bool (*equal_masked_addresses)(const struct sockaddr* a,
|
||||
const struct sockaddr* b, const struct sockaddr* mask);
|
||||
bool (*is_empty_address)(const struct sockaddr* address,
|
||||
bool checkPort);
|
||||
bool (*is_same_family)(const struct sockaddr* address);
|
||||
|
||||
int32 (*first_mask_bit)(const sockaddr *mask);
|
||||
int32 (*first_mask_bit)(const struct sockaddr* mask);
|
||||
|
||||
bool (*check_mask)(const sockaddr *address);
|
||||
bool (*check_mask)(const struct sockaddr* address);
|
||||
|
||||
status_t (*print_address)(const sockaddr *address, char **buffer,
|
||||
bool printPort);
|
||||
status_t (*print_address_buffer)(const sockaddr *address, char *buffer,
|
||||
size_t bufferSize, bool printPort);
|
||||
status_t (*print_address)(const struct sockaddr* address,
|
||||
char** buffer, bool printPort);
|
||||
status_t (*print_address_buffer)(const struct sockaddr* address,
|
||||
char* buffer, size_t bufferSize, bool printPort);
|
||||
|
||||
uint16 (*get_port)(const sockaddr *address);
|
||||
status_t (*set_port)(sockaddr *address, uint16 port);
|
||||
uint16 (*get_port)(const struct sockaddr* address);
|
||||
status_t (*set_port)(struct sockaddr* address, uint16 port);
|
||||
|
||||
status_t (*set_to)(sockaddr *address, const sockaddr *from);
|
||||
status_t (*set_to_empty_address)(sockaddr *address);
|
||||
status_t (*set_to_defaults)(sockaddr *defaultMask,
|
||||
sockaddr *defaultBroadcast, sockaddr *address,
|
||||
sockaddr *netmask);
|
||||
status_t (*set_to)(struct sockaddr* address,
|
||||
const struct sockaddr* from);
|
||||
status_t (*set_to_empty_address)(struct sockaddr* address);
|
||||
status_t (*set_to_defaults)(struct sockaddr* defaultMask,
|
||||
struct sockaddr* defaultBroadcast,
|
||||
const struct sockaddr* address,
|
||||
const struct sockaddr* netmask);
|
||||
|
||||
status_t (*update_to)(sockaddr *address, const sockaddr *from);
|
||||
status_t (*update_to)(struct sockaddr* address,
|
||||
const struct sockaddr* from);
|
||||
|
||||
uint32 (*hash_address_pair)(const sockaddr *ourAddress,
|
||||
const sockaddr *peerAddress);
|
||||
uint32 (*hash_address)(const struct sockaddr* address,
|
||||
bool includePort);
|
||||
uint32 (*hash_address_pair)(const struct sockaddr* ourAddress,
|
||||
const struct sockaddr* peerAddress);
|
||||
|
||||
status_t (*checksum_address)(struct Checksum *checksum,
|
||||
const sockaddr *address);
|
||||
status_t (*checksum_address)(struct Checksum* checksum,
|
||||
const struct sockaddr* address);
|
||||
|
||||
void (*get_loopback_address)(sockaddr *result);
|
||||
void (*get_loopback_address)(struct sockaddr* result);
|
||||
};
|
||||
|
||||
|
||||
#endif // NET_DATALINK_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef NET_DATALINK_PROTOCOL_H
|
||||
@@ -10,31 +10,37 @@
|
||||
|
||||
|
||||
typedef struct net_datalink_protocol {
|
||||
struct net_datalink_protocol *next;
|
||||
struct net_datalink_protocol_module_info *module;
|
||||
struct net_interface *interface;
|
||||
struct net_datalink_protocol* next;
|
||||
struct net_datalink_protocol_module_info* module;
|
||||
struct net_interface* interface;
|
||||
struct net_domain* domain;
|
||||
} net_datalink_protocol;
|
||||
|
||||
struct net_datalink_protocol_module_info {
|
||||
module_info info;
|
||||
|
||||
status_t (*init_protocol)(struct net_interface *interface,
|
||||
net_datalink_protocol **_protocol);
|
||||
status_t (*uninit_protocol)(net_datalink_protocol *self);
|
||||
status_t (*init_protocol)(net_interface* interface, net_domain* domain,
|
||||
net_datalink_protocol** _protocol);
|
||||
status_t (*uninit_protocol)(net_datalink_protocol* self);
|
||||
|
||||
status_t (*send_data)(net_datalink_protocol *self,
|
||||
net_buffer *buffer);
|
||||
status_t (*send_data)(net_datalink_protocol* self, net_buffer* buffer);
|
||||
|
||||
status_t (*interface_up)(net_datalink_protocol *self);
|
||||
void (*interface_down)(net_datalink_protocol *self);
|
||||
status_t (*interface_up)(net_datalink_protocol* self);
|
||||
void (*interface_down)(net_datalink_protocol* self);
|
||||
|
||||
status_t (*control)(net_datalink_protocol *self,
|
||||
int32 op, void *argument, size_t length);
|
||||
status_t (*change_address)(net_datalink_protocol* self,
|
||||
net_interface_address* address, int32 option,
|
||||
const struct sockaddr* oldAddress,
|
||||
const struct sockaddr* newAddress);
|
||||
|
||||
status_t (*join_multicast)(net_datalink_protocol *self,
|
||||
const sockaddr *address);
|
||||
status_t (*leave_multicast)(net_datalink_protocol *self,
|
||||
const sockaddr *address);
|
||||
status_t (*control)(net_datalink_protocol* self, int32 option,
|
||||
void* argument, size_t length);
|
||||
|
||||
status_t (*join_multicast)(net_datalink_protocol* self,
|
||||
const struct sockaddr* address);
|
||||
status_t (*leave_multicast)(net_datalink_protocol* self,
|
||||
const struct sockaddr* address);
|
||||
};
|
||||
|
||||
|
||||
#endif // NET_DATALINK_PROTOCOL_H
|
||||
|
||||
Reference in New Issue
Block a user