BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / network / ppp / modem / modem.cpp
blob542a0b54acd53039248fc150ef0bfac41692e3bf
1 /*
2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
3 * Distributed under the terms of the MIT License.
4 */
6 #include <KernelExport.h>
7 #include <driver_settings.h>
8 #include <core_funcs.h>
9 #include <net_module.h>
11 #include <KPPPInterface.h>
12 #include <KPPPModule.h>
14 #include "ModemDevice.h"
17 #define MODEM_MODULE_NAME NETWORK_MODULES_ROOT "ppp/modem"
19 struct core_module_info *core = NULL;
20 status_t std_ops(int32 op, ...);
23 static
24 bool
25 add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface,
26 driver_parameter *settings, ppp_module_key_type type)
28 if(mainInterface.Mode() != PPP_CLIENT_MODE || type != PPP_DEVICE_KEY_TYPE)
29 return B_ERROR;
31 ModemDevice *device;
32 bool success;
33 if(subInterface) {
34 device = new ModemDevice(*subInterface, settings);
35 success = subInterface->SetDevice(device);
36 } else {
37 device = new ModemDevice(mainInterface, settings);
38 success = mainInterface.SetDevice(device);
41 TRACE("Modem: add_to(): %s\n",
42 success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
44 return success && device && device->InitCheck() == B_OK;
48 static ppp_module_info modem_module = {
50 MODEM_MODULE_NAME,
52 std_ops
54 NULL,
55 add_to
59 _EXPORT
60 status_t
61 std_ops(int32 op, ...)
63 switch(op) {
64 case B_MODULE_INIT:
65 if(get_module(NET_CORE_MODULE_NAME, (module_info**)&core) != B_OK)
66 return B_ERROR;
67 return B_OK;
69 case B_MODULE_UNINIT:
70 put_module(NET_CORE_MODULE_NAME);
71 break;
73 default:
74 return B_ERROR;
77 return B_OK;
81 _EXPORT
82 module_info *modules[] = {
83 (module_info*) &modem_module,
84 NULL