1 //----------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 // 5 // Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de 6 //----------------------------------------------------------------------- 7 8 #include <KernelExport.h> 9 #include <driver_settings.h> 10 #include <core_funcs.h> 11 #include <net_module.h> 12 13 #include <KPPPInterface.h> 14 #include <KPPPModule.h> 15 #include <LockerHelper.h> 16 17 #include "ModemDevice.h" 18 19 20 #define MODEM_MODULE_NAME NETWORK_MODULES_ROOT "ppp/modem" 21 22 struct core_module_info *core = NULL; 23 status_t std_ops(int32 op, ...); 24 25 26 static 27 bool 28 add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface, 29 driver_parameter *settings, ppp_module_key_type type) 30 { 31 if(mainInterface.Mode() != PPP_CLIENT_MODE || type != PPP_DEVICE_KEY_TYPE) 32 return B_ERROR; 33 34 ModemDevice *device; 35 bool success; 36 if(subInterface) { 37 device = new ModemDevice(*subInterface, settings); 38 success = subInterface->SetDevice(device); 39 } else { 40 device = new ModemDevice(mainInterface, settings); 41 success = mainInterface.SetDevice(device); 42 } 43 44 #if DEBUG 45 dprintf("Modem: add_to(): %s\n", 46 success && device && device->InitCheck() == B_OK ? "OK" : "ERROR"); 47 #endif 48 49 return success && device && device->InitCheck() == B_OK; 50 } 51 52 53 static ppp_module_info modem_module = { 54 { 55 MODEM_MODULE_NAME, 56 0, 57 std_ops 58 }, 59 NULL, 60 add_to 61 }; 62 63 64 _EXPORT 65 status_t 66 std_ops(int32 op, ...) 67 { 68 switch(op) { 69 case B_MODULE_INIT: 70 if(get_module(NET_CORE_MODULE_NAME, (module_info**)&core) != B_OK) 71 return B_ERROR; 72 return B_OK; 73 74 case B_MODULE_UNINIT: 75 put_module(NET_CORE_MODULE_NAME); 76 break; 77 78 default: 79 return B_ERROR; 80 } 81 82 return B_OK; 83 } 84 85 86 _EXPORT 87 module_info *modules[] = { 88 (module_info*) &modem_module, 89 NULL 90 }; 91