xref: /haiku/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp (revision 67bce78b48ed6d01b5a8eef89f5694c372b7e0a1)
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 <KPPPLCPExtension.h>
9 
10 #include <PPPControl.h>
11 
12 
13 KPPPLCPExtension::KPPPLCPExtension(const char *name, uint8 code, KPPPInterface& interface,
14 		driver_parameter *settings)
15 	: fInterface(interface),
16 	fSettings(settings),
17 	fCode(code),
18 	fEnabled(true)
19 {
20 	if(name)
21 		fName = strdup(name);
22 	else
23 		fName = NULL;
24 }
25 
26 
27 KPPPLCPExtension::~KPPPLCPExtension()
28 {
29 	free(fName);
30 
31 	Interface().LCP().RemoveLCPExtension(this);
32 }
33 
34 
35 status_t
36 KPPPLCPExtension::InitCheck() const
37 {
38 	return fInitStatus;
39 }
40 
41 
42 status_t
43 KPPPLCPExtension::Control(uint32 op, void *data, size_t length)
44 {
45 	switch(op) {
46 		case PPPC_GET_SIMPLE_HANDLER_INFO: {
47 			if(length < sizeof(ppp_simple_handler_info_t) || !data)
48 				return B_ERROR;
49 
50 			ppp_simple_handler_info *info = (ppp_simple_handler_info*) data;
51 			memset(info, 0, sizeof(ppp_simple_handler_info_t));
52 			if(Name())
53 				strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT);
54 			info->isEnabled = IsEnabled();
55 		} break;
56 
57 		case PPPC_ENABLE:
58 			if(length < sizeof(uint32) || !data)
59 				return B_ERROR;
60 
61 			SetEnabled(*((uint32*)data));
62 		break;
63 
64 		default:
65 			return B_BAD_VALUE;
66 	}
67 
68 	return B_OK;
69 }
70 
71 
72 status_t
73 KPPPLCPExtension::StackControl(uint32 op, void *data)
74 {
75 	switch(op) {
76 		default:
77 			return B_BAD_VALUE;
78 	}
79 
80 	return B_OK;
81 }
82 
83 
84 void
85 KPPPLCPExtension::ProfileChanged()
86 {
87 	// do nothing by default
88 }
89 
90 
91 void
92 KPPPLCPExtension::Reset()
93 {
94 	// do nothing by default
95 }
96 
97 
98 void
99 KPPPLCPExtension::Pulse()
100 {
101 	// do nothing by default
102 }
103