From f378b1b9c87b7ab4a1d7809a485bcb993d22430d Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Thu, 23 Oct 2003 17:53:29 +0000 Subject: [PATCH] BUG fix. Small changes for PPP. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5118 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/core/core.c | 62 ++++--------------------- src/add-ons/kernel/network/core/if.c | 16 +++++-- src/add-ons/kernel/network/core/radix.c | 3 +- 3 files changed, 24 insertions(+), 57 deletions(-) diff --git a/src/add-ons/kernel/network/core/core.c b/src/add-ons/kernel/network/core/core.c index c13a8c1e60..6ea61ec857 100644 --- a/src/add-ons/kernel/network/core/core.c +++ b/src/add-ons/kernel/network/core/core.c @@ -60,9 +60,8 @@ status_t std_ops(int32 op, ...); static int start_stack(void); static int stop_stack(void); -static int32 count_net_modules(void); -static const char *get_net_module_name(int32 index); -static status_t control_net_module(int32 index, uint32 op, void *data, size_t length); +static status_t control_net_module(const char *name, uint32 op, void *data, + size_t length); static void add_protosw(struct protosw *[], int layer); static struct net_module *module_list = NULL; @@ -93,11 +92,7 @@ struct core_module_info core_info = { start_stack, stop_stack, - - count_net_modules, - get_net_module_name, control_net_module, - add_domain, remove_domain, add_protocol, @@ -217,57 +212,20 @@ struct core_module_info core_info = { }; -static -struct net_module* -net_module_at(int32 index) -{ - int32 currentIndex; - struct net_module *current = module_list; - - currentIndex = 0; - for(; current && currentIndex != index; current = current->next) - ++currentIndex; - - return current; -} - - -static -int32 -count_net_modules(void) -{ - int32 count; - struct net_module *current = module_list; - - count = 0; - for(; current; current = current->next) - ++count; - - return count; -} - - -static -const char* -get_net_module_name(int32 index) -{ - struct net_module *module = net_module_at(index); - - if(!module) - return NULL; - - return module->name; -} - - static status_t -control_net_module(int32 index, uint32 op, void *data, size_t length) +control_net_module(const char *name, uint32 op, void *data, size_t length) { - struct net_module *module = net_module_at(index); + struct net_module *module = module_list; + + for(; module; module = module->next) { + if(module->name && !strcmp(module->name, name)) + break; + } if(!module || !module->ptr->control) return B_ERROR; + // no module found return module->ptr->control(op, data, length); } diff --git a/src/add-ons/kernel/network/core/if.c b/src/add-ons/kernel/network/core/if.c index 69d4658f86..014b80e3f1 100644 --- a/src/add-ons/kernel/network/core/if.c +++ b/src/add-ons/kernel/network/core/if.c @@ -62,9 +62,13 @@ ifioctl(struct socket *so, ulong cmd, caddr_t data) struct ifnet *ifp; struct ifreq *ifr; +#if DEBUG + printf("ifioctl(0x%lX)\n", cmd); +#endif + if (cmd == SIOCGIFCONF) return (ifconf(cmd, data)); - + ifr = (struct ifreq*) data; ifp = ifunit(ifr->ifr_name); if (ifp == NULL) @@ -92,6 +96,9 @@ ifioctl(struct socket *so, ulong cmd, caddr_t data) ifp->if_metric = ifr->ifr_metric; break; default: +#if DEBUG + printf("ifioctl: Unknown cmd!\n"); +#endif if (so->so_proto == NULL) return EOPNOTSUPP; return (*so->so_proto->pr_userreq)(so, PRU_CONTROL, @@ -99,16 +106,19 @@ ifioctl(struct socket *so, ulong cmd, caddr_t data) } +#if DEBUG + printf("ifioctl: done\n"); +#endif return 0; } - + struct ifnet * ifunit(char *name) { struct ifnet *d = devices; - + for (d=devices;d;d = d->if_next) if (strcmp(d->if_name, name) == 0) return d; diff --git a/src/add-ons/kernel/network/core/radix.c b/src/add-ons/kernel/network/core/radix.c index 92e4e276fd..3cd6e61bea 100644 --- a/src/add-ons/kernel/network/core/radix.c +++ b/src/add-ons/kernel/network/core/radix.c @@ -410,8 +410,7 @@ on1: x = x->rn_right; else x = x->rn_left; - } while (b > abs(x->rn_bit)); - /* x->rn_bit < b && x->rn_bit >= 0 */ + } while (b > x->rn_bit && x->rn_bit >= 0); #ifdef RN_DEBUG if (rn_debug) log(LOG_DEBUG, "rn_insert: Going In:\n"), traverse(p);