1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 // 5 // Copyright (c) 2003 Waldemar Kornewald, Waldemar.Kornewald@web.de 6 //--------------------------------------------------------------------- 7 8 #include <KPPPOptionHandler.h> 9 10 #include <PPPControl.h> 11 12 13 PPPOptionHandler::PPPOptionHandler(const char *name, uint8 type, 14 PPPInterface& interface, driver_parameter *settings) 15 : fType(type), 16 fInterface(interface), 17 fSettings(settings), 18 fEnabled(true) 19 { 20 if(name) 21 fName = strdup(name); 22 else 23 fName = strdup("Unknown"); 24 } 25 26 27 PPPOptionHandler::~PPPOptionHandler() 28 { 29 free(fName); 30 31 Interface().LCP().RemoveOptionHandler(this); 32 } 33 34 35 status_t 36 PPPOptionHandler::InitCheck() const 37 { 38 return fInitStatus; 39 } 40 41 42 status_t 43 PPPOptionHandler::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 strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT); 53 info->settings = Settings(); 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 PPPOptionHandler::StackControl(uint32 op, void *data) 74 { 75 switch(op) { 76 default: 77 return B_BAD_VALUE; 78 } 79 80 return B_OK; 81 } 82