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 PAP_MODULE_NAME		NETWORK_MODULES_ROOT "ppp/pap"
18
19struct core_module_info *core = NULL;
20status_t std_ops(int32 op, ...);
21
22
23static
24bool
25add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface,
26	driver_parameter *settings, ppp_module_key_type type)
27{
28	if(type != PPP_AUTHENTICATOR_KEY_TYPE)
29		return B_ERROR;
30
31	PAP *pap;
32	bool success;
33	if(subInterface) {
34		pap = new PAP(*subInterface, settings);
35		success = subInterface->AddProtocol(pap);
36	} else {
37		pap = new PAP(mainInterface, settings);
38		success = mainInterface.AddProtocol(pap);
39	}
40
41	TRACE("PAP: add_to(): %s\n",
42		success && pap && pap->InitCheck() == B_OK ? "OK" : "ERROR");
43
44	return success && pap && pap->InitCheck() == B_OK;
45}
46
47
48static ppp_module_info pap_module = {
49	{
50		PAP_MODULE_NAME,
51		0,
52		std_ops
53	},
54	NULL,
55	add_to
56};
57
58
59_EXPORT
60status_t
61std_ops(int32 op, ...)
62{
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;
68
69		case B_MODULE_UNINIT:
70			put_module(NET_CORE_MODULE_NAME);
71		break;
72
73		default:
74			return B_ERROR;
75	}
76
77	return B_OK;
78}
79
80
81_EXPORT
82module_info *modules[] = {
83	(module_info*) &pap_module,
84	NULL
85};
86