From 9f00eacde785849e13679bb453b467de5cb099aa Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Wed, 14 Jan 2004 21:42:40 +0000 Subject: [PATCH] Fix load_driver_symbols() prototype. Move headers into a dedicated directory. Remove duplicated net_stack_driver.h, using the one in current/headers/private/net. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6079 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../net/new_stack/{ => headers}/net_stack.h | 27 ++-- .../kits/net/new_stack/net_stack_driver.h | 141 ------------------ .../kits/net/new_stack/userland_modules.cpp | 2 +- 3 files changed, 17 insertions(+), 153 deletions(-) rename src/tests/kits/net/new_stack/{ => headers}/net_stack.h (89%) delete mode 100644 src/tests/kits/net/new_stack/net_stack_driver.h diff --git a/src/tests/kits/net/new_stack/net_stack.h b/src/tests/kits/net/new_stack/headers/net_stack.h similarity index 89% rename from src/tests/kits/net/new_stack/net_stack.h rename to src/tests/kits/net/new_stack/headers/net_stack.h index b8823eb82f..8d6796688b 100644 --- a/src/tests/kits/net/new_stack/net_stack.h +++ b/src/tests/kits/net/new_stack/headers/net_stack.h @@ -13,6 +13,9 @@ extern "C" { #endif +// String tokens use here and there by stack components +typedef const void *string_token; + // Networking buffer(s) definition typedef struct net_buffer net_buffer; typedef struct net_buffer_queue net_buffer_queue; @@ -32,11 +35,15 @@ typedef int benaphore; // Networking layer(s) definitions typedef struct net_layer net_layer; typedef struct net_layer_module_info net_layer_module_info; -#define NET_LAYER_MODULES_ROOT "network/layers/" + +#define NET_MODULES_ROOT "network_v2/" struct net_layer_module_info { module_info info; + uint32 api_version; + #define NET_LAYER_API_VERSION (0x1) + status_t (*init)(net_layer *me); status_t (*uninit)(net_layer *me); status_t (*enable)(net_layer *me, bool enable); @@ -48,8 +55,8 @@ struct net_layer_module_info { struct net_layer { struct net_layer *next; char *name; - char *type; // "frame", "ethernet" "ipv4", "ppp", etc. Joker (*) allowed - char *sub_type; // joker (*) allowed here too. + string_token type; // "frame", "ethernet" "ipv4", "ppp", etc. Joker (*) allowed + string_token sub_type; // joker (*) allowed here too. int priority; // negative values reserved for packet sniffing, high value = lesser priority net_layer_module_info *module; void *cookie; @@ -58,9 +65,7 @@ struct net_layer { struct net_layer **layers_below; }; - -// Networking attributes -typedef const void *net_attribute_id; +typedef string_token net_attribute_id; #define NET_ATTRIBUTE_TYPE_MASK 0xFF // Up to 256 basic types #define NET_ATTRIBUTE_FLAGS_MASK 0xFFFFFF00 @@ -86,9 +91,9 @@ struct net_stack_module_info { status_t (*start)(void); status_t (*stop)(void); - // Attributes IDs atomizer - net_attribute_id (*register_attribute_id)(const char *name); - + // String IDs atomizer + string_token (*string_to_token)(const char *name); + const char * (*string_for_token)(string_token token); /* * Socket layer @@ -98,7 +103,7 @@ struct net_stack_module_info { * Net layers handling */ - status_t (*register_layer)(const char *name, const char *type, int priority, + status_t (*register_layer)(const char *name, const char *packets_type, int priority, net_layer_module_info *module, void *cookie, net_layer **layer); status_t (*unregister_layer)(net_layer *layer); net_layer * (*find_layer)(const char *name); @@ -175,7 +180,7 @@ struct net_stack_module_info { }; -#define NET_STACK_MODULE_NAME "network/stack/v1" +#define NET_STACK_MODULE_NAME NET_MODULES_ROOT "stack/v1" #ifdef __cplusplus } diff --git a/src/tests/kits/net/new_stack/net_stack_driver.h b/src/tests/kits/net/new_stack/net_stack_driver.h deleted file mode 100644 index c971637070..0000000000 --- a/src/tests/kits/net/new_stack/net_stack_driver.h +++ /dev/null @@ -1,141 +0,0 @@ -/* net_stack_driver.h - * structures and defines to deal with the network stack pseudo-driver... - */ - -#ifndef NET_STACK_DRIVER_H -#define NET_STACK_DRIVER_H - -#include - -#define NET_STACK_DRIVER_DEV "net/stack" -#define NET_STACK_DRIVER_PATH "/dev/" ## NET_STACK_DRIVER_DEV - -enum { - // Paranoia mode: be far away of B_DEVICE_OP_CODES_END opcodes!!! - // You never know what another device driver ioctl() will do - // if think our NET_STACK_* is in fact his DO_RISKY_BUSINESS opcode, or whatever... - NET_IOCTL_BASE = 0xbe230000, - NET_STACK_IOCTL_BASE = NET_IOCTL_BASE + 0x200 -}; - -enum { - NET_STACK_SOCKET = NET_STACK_IOCTL_BASE, // socket_args * - NET_STACK_BIND, // sockaddr_args * - NET_STACK_RECVFROM, // struct msghdr * - NET_STACK_RECV, // data_xfer_args * - NET_STACK_SENDTO, // struct msghdr * - NET_STACK_SEND, // data_xfer_args * - NET_STACK_LISTEN, // int_args * (value = backlog) - NET_STACK_ACCEPT, // accept_args * - NET_STACK_CONNECT, // sockaddr_args * - NET_STACK_SHUTDOWN, // int_args * (value = how) - NET_STACK_GETSOCKOPT, // sockopt_args * - NET_STACK_SETSOCKOPT, // sockopt_args * - NET_STACK_GETSOCKNAME, // sockaddr_args * - NET_STACK_GETPEERNAME, // sockaddr_args * - - NET_STACK_SYSCTL, // sysctl_args * - NET_STACK_SELECT, // select_args * - NET_STACK_DESELECT, // select_args * - NET_STACK_GET_COOKIE, // void ** - - NET_STACK_STOP, - - NET_STACK_NOTIFY_SOCKET_EVENT, // notify_socket_event_args * (userland stack only) - - NET_STACK_IOCTL_MAX -}; - -struct int_args { // used by NET_STACK_LISTEN/_SHUTDOWN - int value; -}; - -struct sockaddr_args { // used by NET_STACK_CONNECT/_BIND/_GETSOCKNAME/_GETPEERNAME - struct sockaddr *addr; - int addrlen; -}; - -struct sockopt_args { // used by NET_STACK_SETSOCKOPT/_GETSOCKOPT - int level; - int option; - void *optval; - int optlen; -}; - -struct data_xfer_args { // used by NET_STACK_SEND/_RECV - void *data; - size_t datalen; - int flags; - struct sockaddr *addr; // unused in *_SEND and *_RECV cases - int addrlen; // unused in *_SEND and *_RECV cases -}; - -struct socket_args { // used by NET_STACK_SOCKET - int family; - int type; - int proto; -}; - -struct getcookie_args { // used by NET_STACK_GET_COOKIE - void **cookie; -}; - -struct accept_args { // used by NET_STACK_ACCEPT - void *cookie; - struct sockaddr *addr; - int addrlen; -}; - -struct sysctl_args { // used by NET_STACK_SYSCTL - int *name; - uint namelen; - void *oldp; - size_t *oldlenp; - void *newp; - size_t newlen; -}; - -/* - Userland stack driver on_socket_event() callback mecanism implementation: - the driver start a kernel thread waiting on a port for - a NET_STACK_SOCKET_EVENT_MSG message, which come with a socket_event_data block. - - The on_socket_event() mechanism stay in driver (kernelland) because it's - only there we can call kernel's notify_select_event() on BONE systems. - For non-BONE systems, we use our own r5_notify_select_event() - implementation, that could be moved into the userland net_server code, - but it'll have split (again!) the /dev/net/stack driver code... -*/ - -struct notify_socket_event_args { // used by NET_STACK_NOTIFY_SOCKET_EVENT - port_id notify_port; // port waiting for notification, -1 = stop notify - void * cookie; // this cookie value will be pass back in the socket_event_args -}; - -#define NET_STACK_SOCKET_EVENT_NOTIFICATION 'sevn' - -struct socket_event_data { - uint32 event; // B_SELECT_READ, B_SELECT_WRITE or B_SELECT_EXCEPTION - void * cookie; // The cookie as set in notify_socket_event_args for this socket -}; - -/* - R5.0.3 and before select() kernel support is too buggy to be used, so - here are the structures we used to support select() on sockets, and *only* on - sockets! -*/ - -struct select_args { // used by NET_STACK_SELECT and NET_STACK_DESELECT - struct selectsync * sync; // in fact, it's the area_id of a r5_selectsync struct!!! - uint32 ref; -}; - -struct r5_selectsync { - sem_id lock; // lock this r5_selectsync - sem_id wakeup; // sem to release to wakeup select() - struct fd_set rbits; // read event bits field - struct fd_set wbits; // write event bits field - struct fd_set ebits; // exception event bits field -}; - -#endif /* NET_STACK_DRIVER_H */ diff --git a/src/tests/kits/net/new_stack/userland_modules.cpp b/src/tests/kits/net/new_stack/userland_modules.cpp index d811326ea8..52647678c8 100644 --- a/src/tests/kits/net/new_stack/userland_modules.cpp +++ b/src/tests/kits/net/new_stack/userland_modules.cpp @@ -394,7 +394,7 @@ _EXPORT void kprintf(const char *fmt, ...) } -_EXPORT status_t load_driver_symbols(char *driver_name) +_EXPORT status_t load_driver_symbols(const char *driver_name) { // Userland debugger will extract symbols itself... return B_OK;