From 7f015ac67100cf48fc2e9528c024dd326ee43fac Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Thu, 23 Oct 2003 17:50:45 +0000 Subject: [PATCH] Forgot to commit changes for control() support and some fixes. Also added header for PPPoE support in ethernet module. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5115 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/net/core_module.h | 2 ++ headers/private/net/ethernet_module.h | 22 ++++++++++++++++++++++ headers/private/net/net_module.h | 1 + headers/private/net/net_stack_driver.h | 9 +++++++++ headers/private/net/sys/socketvar.h | 12 ++++++------ 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 headers/private/net/ethernet_module.h diff --git a/headers/private/net/core_module.h b/headers/private/net/core_module.h index 40e3f79f3b..90f1f655b0 100644 --- a/headers/private/net/core_module.h +++ b/headers/private/net/core_module.h @@ -18,6 +18,8 @@ struct core_module_info { int (*start)(void); int (*stop)(void); + status_t (*control_net_module)(const char *name, uint32 op, void *data, + size_t length); void (*add_domain)(struct domain *, int); void (*remove_domain)(int); void (*add_protocol)(struct protosw *, int); diff --git a/headers/private/net/ethernet_module.h b/headers/private/net/ethernet_module.h new file mode 100644 index 0000000000..3628928da3 --- /dev/null +++ b/headers/private/net/ethernet_module.h @@ -0,0 +1,22 @@ +/* + ethernet_module.h +*/ + +#ifndef ETHERNET_MODULE_H +#define ETHERNET_MODULE_H + +#include "net_module.h" + +#include +#define NET_ETHERNET_MODULE_NAME "network/interfaces/ethernet" + +typedef void (*ethernet_receiver_func)(struct mbuf *buf); + +struct ethernet_module_info { + struct kernel_net_module_info info; + + void (*set_pppoe_receiver)(ethernet_receiver_func func); + void (*unset_pppoe_receiver)(void); +}; + +#endif /* ETHERNET_MODULE_H */ diff --git a/headers/private/net/net_module.h b/headers/private/net/net_module.h index 71c9b5aed3..c201a7ee64 100644 --- a/headers/private/net/net_module.h +++ b/headers/private/net/net_module.h @@ -21,6 +21,7 @@ struct kernel_net_module_info { module_info info; int (*start)(void *); int (*stop)(void); + status_t (*control)(uint32 op, void *data, size_t length); }; struct net_module { diff --git a/headers/private/net/net_stack_driver.h b/headers/private/net/net_stack_driver.h index 410fd599a2..8cdd0e7cda 100644 --- a/headers/private/net/net_stack_driver.h +++ b/headers/private/net/net_stack_driver.h @@ -44,6 +44,8 @@ enum { NET_STACK_NOTIFY_SOCKET_EVENT, // notify_socket_event_args * (userland stack only) + NET_STACK_CONTROL_NET_MODULE, + NET_STACK_IOCTL_MAX }; @@ -88,6 +90,13 @@ struct sysctl_args { // used by NET_STACK_SYSCTL size_t newlen; }; +struct control_net_module_args { // used by NET_STACK_CONTROL_NET_MODULE + char *name; + uint32 op; + void *data; + size_t length; +}; + /* Userland stack driver on_socket_event() callback mecanism implementation: the driver start a kernel thread waiting on a port for diff --git a/headers/private/net/sys/socketvar.h b/headers/private/net/sys/socketvar.h index 917eb5d7ce..976c524310 100644 --- a/headers/private/net/sys/socketvar.h +++ b/headers/private/net/sys/socketvar.h @@ -11,10 +11,10 @@ struct mbuf; struct sockbuf { - uint32 sb_cc; /* actual chars in buffer */ - uint32 sb_hiwat; /* max actual char count (high water mark) */ - uint32 sb_mbcnt; /* chars of mbufs used */ - uint32 sb_mbmax; /* max chars of mbufs to use */ + int32 sb_cc; /* actual chars in buffer */ + int32 sb_hiwat; /* max actual char count (high water mark) */ + int32 sb_mbcnt; /* chars of mbufs used */ + int32 sb_mbmax; /* max chars of mbufs to use */ int32 sb_lowat; /* low water mark */ struct mbuf *sb_mb; /* the mbuf chain */ int16 sb_flags; /* flags, see below */ @@ -101,8 +101,8 @@ struct socket { } #define sbspace(sb) \ - ((uint32) min((int)((sb)->sb_hiwat - (sb)->sb_cc), \ - (int)((sb)->sb_mbmax - (sb)->sb_mbcnt))) + (abs(min((int)((sb)->sb_hiwat - (sb)->sb_cc), \ + (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))) /* do we have to send all at once on a socket? */ #define sosendallatonce(so) \