1/* 2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net> 3 * Distributed under the terms of the MIT License. 4 */ 5 6#include <KernelExport.h> 7#include <driver_settings.h> 8#include <core_funcs.h> 9#include <net_module.h> 10 11#include <KPPPInterface.h> 12#include <KPPPModule.h> 13 14#include "Protocol.h" 15 16 17#define IPCP_MODULE_NAME NETWORK_MODULES_ROOT "ppp/ipcp" 18 19struct protosw *gProto[IPPROTO_MAX]; 20struct core_module_info *core = NULL; 21status_t std_ops(int32 op, ...); 22 23 24// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 25// TODO: Remove isascii() (needed for inet_aton()) when our kernel is finished! 26// isascii() is not defined in the R5 kernel, thus we must define it here: 27extern "C" 28int 29isascii(char c) 30{ 31 return c & ~0x7f == 0; // If c is a 7 bit value. 32} 33// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 34 35 36static 37bool 38add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface, 39 driver_parameter *settings, ppp_module_key_type type) 40{ 41 if(type != PPP_PROTOCOL_KEY_TYPE) 42 return B_ERROR; 43 44 IPCP *ipcp; 45 bool success; 46 if(subInterface) { 47 ipcp = new IPCP(*subInterface, settings); 48 success = subInterface->AddProtocol(ipcp); 49 } else { 50 ipcp = new IPCP(mainInterface, settings); 51 success = mainInterface.AddProtocol(ipcp); 52 } 53 54 TRACE("IPCP: add_to(): %s\n", 55 success && ipcp && ipcp->InitCheck() == B_OK ? "OK" : "ERROR"); 56 57 return success && ipcp && ipcp->InitCheck() == B_OK; 58} 59 60 61static ppp_module_info ipcp_module = { 62 { 63 IPCP_MODULE_NAME, 64 0, 65 std_ops 66 }, 67 NULL, 68 add_to 69}; 70 71 72_EXPORT 73status_t 74std_ops(int32 op, ...) 75{ 76 switch(op) { 77 case B_MODULE_INIT: 78 if(get_module(NET_CORE_MODULE_NAME, (module_info**) &core) != B_OK) 79 return B_ERROR; 80 memset(gProto, 0, sizeof(struct protosw*) * IPPROTO_MAX); 81 add_protosw(gProto, NET_LAYER1); 82 return B_OK; 83 84 case B_MODULE_UNINIT: 85 put_module(NET_CORE_MODULE_NAME); 86 break; 87 88 default: 89 return B_ERROR; 90 } 91 92 return B_OK; 93} 94 95 96_EXPORT 97module_info *modules[] = { 98 (module_info*) &ipcp_module, 99 NULL 100}; 101