diff --git a/src/tests/kits/net/ppp/headers/KPPPDefs.h b/src/tests/kits/net/ppp/headers/KPPPDefs.h index 15e10bb997..3057421c67 100644 --- a/src/tests/kits/net/ppp/headers/KPPPDefs.h +++ b/src/tests/kits/net/ppp/headers/KPPPDefs.h @@ -8,7 +8,7 @@ #ifndef _K_PPP_DEFS__H #define _K_PPP_DEFS__H -#include +#include typedef uint32 interface_id; @@ -16,52 +16,6 @@ typedef uint32 interface_id; // various constants #define PPP_PULSE_RATE 500000 -// settings keys -#define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY "DisonnectAfterIdleSince" -#define PPP_MODE_KEY "Mode" -#define PPP_DIAL_ON_DEMAND_KEY "DialOnDemand" -#define PPP_AUTO_REDIAL_KEY "AutoRedial" -#define PPP_LOAD_MODULE_KEY "LoadModule" -#define PPP_PROTOCOL_KEY "Protocol" -#define PPP_DEVICE_KEY "Device" -#define PPP_AUTHENTICATOR_KEY "Authenticator" -#define PPP_PEER_AUTHENTICATOR_KEY "Peer-Authenticator" -#define PPP_MULTILINK_KEY "Multilink-Protocol" - -// settings values -#define PPP_CLIENT_MODE_VALUE "Client" -#define PPP_SERVER_MODE_VALUE "Server" - -// path defines -#define PPP_MODULES_PATH "network/ppp-modules" - -// built-in protocols -#define PPP_LCP_PROTOCOL 0xC021 - - -#define PPP_ERROR_BASE B_ERRORS_END - -// return values for Send()/Receive() methods in addition to B_ERROR and B_OK -// PPP_UNHANDLED is also used by PPPOptionHandler -enum { - // B_ERROR means that the packet is corrupted - // B_OK means the packet was handled correctly - - // return values for PPPProtocol and PPPEncapsulator (and PPPOptionHandler) - PPP_UNHANDLED = PPP_ERROR_BASE, - // The packet does not belong to this handler. - // Do not delete the packet when you return this! - // For PPPOptionHandler: the item is unrecognized - - // return values of PPPInterface::Receive() - PPP_DISCARDED, - // packet was silently discarded - PPP_REJECTED, - // a protocol-reject - - PPP_NO_CONNECTION - // could not send a packet because device is not connected -}; // module key types (used when loading a module) enum { @@ -73,91 +27,6 @@ enum { PPP_MULTILINK_TYPE }; -// protocol and encapsulator flags -enum { - PPP_NO_FLAGS = 0x00, - PPP_ALWAYS_ALLOWED = 0x01, - // protocol may send/receive in PPP_ESTABLISHMENT_PHASE - PPP_NEEDS_DOWN = 0x02, - // protocol needs a Down() in addition to a Reset() to - // terminate the connection properly (losing the connection - // still results in a Reset() only) - PPP_NOT_IMPORTANT = 0x03 - // if this protocol fails to go up we do not disconnect -}; - -// phase when the protocol is brought up -enum PPP_PHASE { - // the following may be used by protocols - PPP_AUTHENTICATION_PHASE = 15, - PPP_NCP_PHASE = 20, - PPP_ESTABLISHED_PHASE = 25, - // only use PPP_ESTABLISHED_PHASE if - // you want to activate this protocol after - // the normal protocols like IP (i.e., IPCP) - - // the following must not be used by protocols! - PPP_DOWN_PHASE = 0, - PPP_TERMINATION_PHASE = 1, - // this is the selected phase when we are GOING down - PPP_ESTABLISHMENT_PHASE = 2 - // in this phase some protocols (with PPP_ALWAYS_ALLOWED - // flag set) may be used -}; - -// this defines the order in which the packets get encapsulated -enum PPP_ENCAPSULATION_LEVEL { - PPP_MULTILINK_LEVEL = 0, - PPP_ENCRYPTION_LEVEL = 5, - PPP_COMPRESSION_LEVEL = 10 -}; - -// we can be a ppp client or a ppp server interface -enum PPP_MODE { - PPP_CLIENT_MODE = 0, - PPP_SERVER_MODE -}; - -// authentication status -enum PPP_AUTHENTICATION_STATUS { - PPP_AUTHENTICATION_FAILED = -1, - PPP_NOT_AUTHENTICATED = 0, - PPP_AUTHENTICATION_SUCCESSFUL = 1, - PPP_AUTHENTICATING = 0xFF -}; - -// PPP states as defined in RFC 1661 -enum PPP_STATE { - PPP_INITIAL_STATE, - PPP_STARTING_STATE, - PPP_CLOSED_STATE, - PPP_STOPPED_STATE, - PPP_CLOSING_STATE, - PPP_STOPPING_STATE, - PPP_REQ_SENT_STATE, - PPP_ACK_RCVD_STATE, - PPP_ACK_SENT_STATE, - PPP_OPENED_STATE -}; - -// PPP actions as defined in RFC 1661 -enum PPP_ACTION { - PPP_ILLEGAL_EVENT_ACTION, - PPP_THIS_LAYER_UP_ACTION, - PPP_THIS_LAYER_DOWN_ACTION, - PPP_THIS_LAYER_STARTED_ACTION, - PPP_THIS_LAYER_FINISHED_ACTION, - PPP_INIT_RESTART_COUNT_ACTION, - PPP_ZERO_RESTART_COUNT_ACTION, - PPP_SEND_CONF_REQ_ACTION, - PPP_SEND_CONF_ACK_ACTION, - PPP_SEND_CONF_NAK_ACTION, - PPP_SEND_TERM_REQ_ACTION, - PPP_SEND_TERM_ACK_ACTION, - PPP_SEND_CODE_REJ_ACTION, - PPP_SEND_ECHO_REPLY_ACTION -}; - // PPP events as defined in RFC 1661 (with one exception: PPP_UP_FAILED_EVENT) enum PPP_EVENT { PPP_UP_FAILED_EVENT, diff --git a/src/tests/kits/net/ppp/headers/KPPPDevice.h b/src/tests/kits/net/ppp/headers/KPPPDevice.h index 181950fa0d..a9c9c44d7d 100644 --- a/src/tests/kits/net/ppp/headers/KPPPDevice.h +++ b/src/tests/kits/net/ppp/headers/KPPPDevice.h @@ -84,7 +84,7 @@ class PPPDevice { bool fIsUp; private: - char *fName; + char fName[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; uint32 fOverhead; PPPInterface *fInterface; driver_parameter *fSettings; diff --git a/src/tests/kits/net/ppp/headers/KPPPEncapsulator.h b/src/tests/kits/net/ppp/headers/KPPPEncapsulator.h index d145facd96..99d65ea7d9 100644 --- a/src/tests/kits/net/ppp/headers/KPPPEncapsulator.h +++ b/src/tests/kits/net/ppp/headers/KPPPEncapsulator.h @@ -104,7 +104,7 @@ class PPPEncapsulator { uint32 fOverhead; private: - char *fName; + char fName[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; PPP_PHASE fPhase; PPP_ENCAPSULATION_LEVEL fLevel; uint16 fProtocol; diff --git a/src/tests/kits/net/ppp/headers/KPPPOptionHandler.h b/src/tests/kits/net/ppp/headers/KPPPOptionHandler.h index be5b73f176..1548cfd1fc 100644 --- a/src/tests/kits/net/ppp/headers/KPPPOptionHandler.h +++ b/src/tests/kits/net/ppp/headers/KPPPOptionHandler.h @@ -60,7 +60,7 @@ class PPPOptionHandler { // notification that we ack these values private: - char *fName; + char fName[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; PPPInterface *fInterface; driver_parameter *fSettings; diff --git a/src/tests/kits/net/ppp/headers/KPPPProtocol.h b/src/tests/kits/net/ppp/headers/KPPPProtocol.h index 74d400c1f8..9992e77579 100644 --- a/src/tests/kits/net/ppp/headers/KPPPProtocol.h +++ b/src/tests/kits/net/ppp/headers/KPPPProtocol.h @@ -80,7 +80,7 @@ class PPPProtocol { // report up/down events private: - char *fName; + char fName[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; PPP_PHASE fPhase; uint16 fProtocol; int32 fAddressFamily; diff --git a/src/tests/kits/net/ppp/headers/KPPPReportDefs.h b/src/tests/kits/net/ppp/headers/KPPPReportDefs.h index 3810ad88a2..b1c3821042 100644 --- a/src/tests/kits/net/ppp/headers/KPPPReportDefs.h +++ b/src/tests/kits/net/ppp/headers/KPPPReportDefs.h @@ -8,56 +8,8 @@ #ifndef _K_PPP_REPORT_DEFS__H #define _K_PPP_REPORT_DEFS__H +#include -#define PPP_REPORT_DATA_LIMIT 128 - // how much optional data can be added to the report -#define PPP_REPORT_CODE '_3PR' - // the code field of read_port - - -// report flags -enum PPP_REPORT_FLAGS { - PPP_NO_REPORT_FLAGS = 0, - PPP_WAIT_FOR_REPLY = 0x1, - PPP_REMOVE_AFTER_REPORT = 0x2, - PPP_NO_REPLY_TIMEOUT = 0x4 -}; - -// report types -enum PPP_REPORT_TYPE { - PPP_DESTRUCTION_REPORT = 0, - // the interface is being destroyed (no code is needed) - PPP_CONNECTION_REPORT = 1, - PPP_AUTHENTICATION_REPORT = 2 -}; - -// report codes (type-specific) -enum PPP_CONNECTION_REPORT_CODES { - PPP_REPORT_GOING_UP = 0, - PPP_REPORT_UP_SUCCESSFUL = 1, - PPP_REPORT_DOWN_SUCCESSFUL = 2, - PPP_REPORT_UP_ABORTED = 3, - PPP_REPORT_DEVICE_UP_FAILED = 4, - PPP_REPORT_AUTHENTICATION_SUCCESSFUL = 5, - PPP_REPORT_PEER_AUTHENTICATION_SUCCESSFUL = 6, - PPP_REPORT_AUTHENTICATION_FAILED = 7, - PPP_REPORT_CONNECTION_LOST = 8 -}; - - -typedef struct ppp_report_packet { - int32 type; - int32 code; - uint8 length; - char data[PPP_REPORT_DATA_LIMIT]; -} ppp_report_packet; - - - -//*********** -// private -//*********** -#define PPP_REPORT_TIMEOUT 10 typedef struct ppp_report_request { thread_id thread; diff --git a/src/tests/kits/net/ppp/src/KPPPUtils.h b/src/tests/kits/net/ppp/headers/KPPPUtils.h similarity index 100% rename from src/tests/kits/net/ppp/src/KPPPUtils.h rename to src/tests/kits/net/ppp/headers/KPPPUtils.h diff --git a/src/tests/kits/net/ppp/headers/PPPControl.h b/src/tests/kits/net/ppp/headers/PPPControl.h new file mode 100644 index 0000000000..4940ab017a --- /dev/null +++ b/src/tests/kits/net/ppp/headers/PPPControl.h @@ -0,0 +1,116 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +// +// Copyright (c) 2003 Waldemar Kornewald, Waldemar.Kornewald@web.de +//--------------------------------------------------------------------- + +#ifndef _PPP_CONTROL__H +#define _PPP_CONTROL__H + +#include +#include + + +// starting values and other values for control ops +#define PPP_RESERVE_OPS_COUNT 0xFFFF +#define PPP_OPS_START B_DEVICE_OP_CODES_END + 1 +#define PPP_DEVICE_OPS_START PPP_OPS_START + 2 * PPP_RESERVE_OPS_COUNT +#define PPP_PROTOCOL_OPS_START PPP_OPS_START + 3 * PPP_RESERVE_OPS_COUNT +#define PPP_ENCAPSULATOR_OPS_START PPP_OPS_START + 4 * PPP_RESERVE_OPS_COUNT +#define PPP_OPTION_HANDLER_OPS_START PPP_OPS_START + 5 * PPP_RESERVE_OPS_COUNT +#define PPP_LCP_EXTENSION_OPS_START PPP_OPS_START + 6 * PPP_RESERVE_OPS_COUNT +#define PPP_COMMON_PROTO_ENCAPS_OPS_START PPP_OPS_START + 10 * PPP_RESERVE_OPS_COUNT +#define PPP_USER_OPS_START PPP_OPS_START + 32 * PPP_RESERVE_OPS_COUNT + + +enum PPP_CONTROL_OPS { + // ----------------------------------------------------- + // PPPInterface + PPPC_GET_STATUS = PPP_OPS_START, + PPPC_GET_MRU, + PPPC_SET_MRU, + PPPC_GET_LINK_MTU, + PPPC_SET_LINK_MTU, + PPPC_GET_DIAL_ON_DEMAND, + PPPC_SET_DIAL_ON_DEMAND, + PPPC_GET_AUTO_REDIAL, + PPPC_SET_AUTO_REDIAL, + PPPC_GET_PROTOCOLS_COUNT, + PPPC_GET_ENCAPSULATORS_COUNT, + PPPC_GET_OPTION_HANDLERS_COUNT, + PPPC_GET_LCP_EXTENSIONS_COUNT, + PPPC_GET_CHILDREN_COUNT, + PPPC_CONTROL_PROTOCOL, + PPPC_CONTROL_ENCAPSULATOR, + PPPC_CONTROL_OPTION_HANDLER, + PPPC_CONTROL_LCP_EXTENSION, + PPPC_CONTROL_CHILD, + // ----------------------------------------------------- + + // ----------------------------------------------------- + // PPPDevice + PPPC_GET_MTU = PPP_DEVICE_OPS_START, + PPPC_SET_MTU, + PPPC_GET_PREFERRED_MTU, + // ----------------------------------------------------- + + // ----------------------------------------------------- + // PPPProtocol + // ----------------------------------------------------- + + // ----------------------------------------------------- + // PPPEncapsulator + // ----------------------------------------------------- + + // ----------------------------------------------------- + // PPPOptionHandler + // ----------------------------------------------------- + + // ----------------------------------------------------- + // PPPLCPExtension + // ----------------------------------------------------- + + // ----------------------------------------------------- + // PPPProtocol and PPPEncapsulator + PPPC_GET_NAME, + PPPC_GET_ENABLED = PPP_COMMON_PROTO_ENCAPS_OPS_START, + PPPC_SET_ENABLED, + // ----------------------------------------------------- + + PPP_CONTROL_OPS_END = B_DEVICE_OP_CODES_END + 0xFFFF +}; + + +typedef struct ppp_control_structure { + uint32 index; + // index of interface/protocol/encapsulator/etc. + uint32 op; + // the Control()/ioctl() opcode + + union { + void *data; + ppp_control_struct *subcontrol; + } pointer; + // either a pointer to the data or a pointer to a control structure for + // accessing protocols/encapsulators/etc. + + size_t length; + // not always needed +} ppp_control_structure; + + +typedef struct ppp_status_structure { + PPP_MODE mode; + PPP_STATE state; + PPP_PHASE phase; + PPP_AUTHENTICATION_STATUS authenticationStatus, peerAuthenticationStatus; + + bigtime_t idle_since; + + uint8 _reserved_[64 - (sizeof(PPP_MODE) + sizeof(PPP_STATE) + sizeof(PPP_PHASE) + + 2 * sizeof(PPP_AUTHENTICATION_STATUS) + sizeof(bigtime_t))]; +} ppp_status_structure; + + +#endif diff --git a/src/tests/kits/net/ppp/headers/PPPDefs.h b/src/tests/kits/net/ppp/headers/PPPDefs.h new file mode 100644 index 0000000000..0e95f5f44f --- /dev/null +++ b/src/tests/kits/net/ppp/headers/PPPDefs.h @@ -0,0 +1,132 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +// +// Copyright (c) 2003 Waldemar Kornewald, Waldemar.Kornewald@web.de +//--------------------------------------------------------------------- + +#ifndef _PPP_DEFS__H +#define _PPP_DEFS__H + +#include + + +// various constants +#define PPP_HANDLER_NAME_LENGTH_LIMIT 255 + // if the name is longer than this value it will be truncated + +// settings keys +#define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY "DisonnectAfterIdleSince" +#define PPP_MODE_KEY "Mode" +#define PPP_DIAL_ON_DEMAND_KEY "DialOnDemand" +#define PPP_AUTO_REDIAL_KEY "AutoRedial" +#define PPP_LOAD_MODULE_KEY "LoadModule" +#define PPP_PROTOCOL_KEY "Protocol" +#define PPP_DEVICE_KEY "Device" +#define PPP_AUTHENTICATOR_KEY "Authenticator" +#define PPP_PEER_AUTHENTICATOR_KEY "Peer-Authenticator" +#define PPP_MULTILINK_KEY "Multilink-Protocol" + +// settings values +#define PPP_CLIENT_MODE_VALUE "Client" +#define PPP_SERVER_MODE_VALUE "Server" + +// path defines +#define PPP_MODULES_PATH "network/ppp-modules" + +// built-in protocols +#define PPP_LCP_PROTOCOL 0xC021 + + +#define PPP_ERROR_BASE B_ERRORS_END + 1 + +// return values for Send()/Receive() methods in addition to B_ERROR and B_OK +// PPP_UNHANDLED is also used by PPPOptionHandler +enum { + // B_ERROR means that the packet is corrupted + // B_OK means the packet was handled correctly + + // return values for PPPProtocol and PPPEncapsulator (and PPPOptionHandler) + PPP_UNHANDLED = PPP_ERROR_BASE, + // The packet does not belong to this handler. + // Do not delete the packet when you return this! + // For PPPOptionHandler: the item is unrecognized + + // return values of PPPInterface::Receive() + PPP_DISCARDED, + // packet was silently discarded + PPP_REJECTED, + // a protocol-reject + + PPP_NO_CONNECTION + // could not send a packet because device is not connected +}; + +// protocol and encapsulator flags +enum { + PPP_NO_FLAGS = 0x00, + PPP_ALWAYS_ALLOWED = 0x01, + // protocol may send/receive in PPP_ESTABLISHMENT_PHASE + PPP_NEEDS_DOWN = 0x02, + // protocol needs a Down() in addition to a Reset() to + // terminate the connection properly (losing the connection + // still results in a Reset() only) + PPP_NOT_IMPORTANT = 0x03 + // if this protocol fails to go up we do not disconnect +}; + +// phase when the protocol is brought up +enum PPP_PHASE { + // the following may be used by protocols + PPP_AUTHENTICATION_PHASE = 15, + PPP_NCP_PHASE = 20, + PPP_ESTABLISHED_PHASE = 25, + // only use PPP_ESTABLISHED_PHASE if + // you want to activate this protocol after + // the normal protocols like IP (i.e., IPCP) + + // the following must not be used by protocols! + PPP_DOWN_PHASE = 0, + PPP_TERMINATION_PHASE = 1, + // this is the selected phase when we are GOING down + PPP_ESTABLISHMENT_PHASE = 2 + // in this phase some protocols (with PPP_ALWAYS_ALLOWED + // flag set) may be used +}; + +// this defines the order in which the packets get encapsulated +enum PPP_ENCAPSULATION_LEVEL { + PPP_MULTILINK_LEVEL = 0, + PPP_ENCRYPTION_LEVEL = 5, + PPP_COMPRESSION_LEVEL = 10 +}; + +// we can be a ppp client or a ppp server interface +enum PPP_MODE { + PPP_CLIENT_MODE = 0, + PPP_SERVER_MODE +}; + +// authentication status +enum PPP_AUTHENTICATION_STATUS { + PPP_AUTHENTICATION_FAILED = -1, + PPP_NOT_AUTHENTICATED = 0, + PPP_AUTHENTICATION_SUCCESSFUL = 1, + PPP_AUTHENTICATING = 0xFF +}; + +// PPP states as defined in RFC 1661 +enum PPP_STATE { + PPP_INITIAL_STATE, + PPP_STARTING_STATE, + PPP_CLOSED_STATE, + PPP_STOPPED_STATE, + PPP_CLOSING_STATE, + PPP_STOPPING_STATE, + PPP_REQ_SENT_STATE, + PPP_ACK_RCVD_STATE, + PPP_ACK_SENT_STATE, + PPP_OPENED_STATE +}; + +#endif diff --git a/src/tests/kits/net/ppp/headers/PPPReportDefs.h b/src/tests/kits/net/ppp/headers/PPPReportDefs.h new file mode 100644 index 0000000000..332ddc83ad --- /dev/null +++ b/src/tests/kits/net/ppp/headers/PPPReportDefs.h @@ -0,0 +1,57 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +// +// Copyright (c) 2003 Waldemar Kornewald, Waldemar.Kornewald@web.de +//--------------------------------------------------------------------- + +#ifndef _PPP_REPORT_DEFS__H +#define _PPP_REPORT_DEFS__H + + +#define PPP_REPORT_TIMEOUT 10 + +#define PPP_REPORT_DATA_LIMIT 128 + // how much optional data can be added to the report +#define PPP_REPORT_CODE '_3PR' + // the code of receive_data() must have this value + +// report flags +enum PPP_REPORT_FLAGS { + PPP_NO_REPORT_FLAGS = 0, + PPP_WAIT_FOR_REPLY = 0x1, + PPP_REMOVE_AFTER_REPORT = 0x2, + PPP_NO_REPLY_TIMEOUT = 0x4 +}; + +// report types +enum PPP_REPORT_TYPE { + PPP_DESTRUCTION_REPORT = 0, + // the interface is being destroyed (no code is needed) + PPP_CONNECTION_REPORT = 1, + PPP_AUTHENTICATION_REPORT = 2 +}; + +// report codes (type-specific) +enum PPP_CONNECTION_REPORT_CODES { + PPP_REPORT_GOING_UP = 0, + PPP_REPORT_UP_SUCCESSFUL = 1, + PPP_REPORT_DOWN_SUCCESSFUL = 2, + PPP_REPORT_UP_ABORTED = 3, + PPP_REPORT_DEVICE_UP_FAILED = 4, + PPP_REPORT_AUTHENTICATION_SUCCESSFUL = 5, + PPP_REPORT_PEER_AUTHENTICATION_SUCCESSFUL = 6, + PPP_REPORT_AUTHENTICATION_FAILED = 7, + PPP_REPORT_CONNECTION_LOST = 8 +}; + + +typedef struct ppp_report_packet { + int32 type; + int32 code; + uint8 length; + char data[PPP_REPORT_DATA_LIMIT]; +} ppp_report_packet; + + +#endif diff --git a/src/tests/kits/net/ppp/src/KPPPDevice.cpp b/src/tests/kits/net/ppp/src/KPPPDevice.cpp index 2ab2d43cbb..4c06783b0a 100644 --- a/src/tests/kits/net/ppp/src/KPPPDevice.cpp +++ b/src/tests/kits/net/ppp/src/KPPPDevice.cpp @@ -16,7 +16,11 @@ PPPDevice::PPPDevice(const char *name, uint32 overhead, PPPInterface *interface, : fOverhead(overhead), fInterface(interface), fSettings(settings) { - fName = name ? strdup(name) : NULL; + if(name) { + strncpy(fName, name, PPP_HANDLER_NAME_LENGTH_LIMIT); + fName[PPP_HANDLER_NAME_LENGTH_LIMIT] = 0; + } else + strcpy(fName, ""); SetMTU(1500); @@ -27,8 +31,6 @@ PPPDevice::PPPDevice(const char *name, uint32 overhead, PPPInterface *interface, PPPDevice::~PPPDevice() { - free(fName); - if(Interface()) Interface()->SetDevice(NULL); } diff --git a/src/tests/kits/net/ppp/src/KPPPEncapsulator.cpp b/src/tests/kits/net/ppp/src/KPPPEncapsulator.cpp index c243bfdc0d..87abb3732a 100644 --- a/src/tests/kits/net/ppp/src/KPPPEncapsulator.cpp +++ b/src/tests/kits/net/ppp/src/KPPPEncapsulator.cpp @@ -18,7 +18,11 @@ PPPEncapsulator::PPPEncapsulator(const char *name, PPP_PHASE phase, fSettings(settings), fFlags(flags), fEnabled(true), fUpRequested(true), fConnectionStatus(PPP_DOWN_PHASE) { - fName = name ? strdup(name) : NULL; + if(name) { + strncpy(fName, name, PPP_HANDLER_NAME_LENGTH_LIMIT); + fName[PPP_HANDLER_NAME_LENGTH_LIMIT] = 0; + } else + strcpy(fName, ""); if(interface) interface->AddEncapsulator(this); @@ -27,8 +31,6 @@ PPPEncapsulator::PPPEncapsulator(const char *name, PPP_PHASE phase, PPPEncapsulator::~PPPEncapsulator() { - free(fName); - if(Interface()) Interface()->RemoveEncapsulator(this); } diff --git a/src/tests/kits/net/ppp/src/KPPPInterface.cpp b/src/tests/kits/net/ppp/src/KPPPInterface.cpp index ff102eaf62..319273f099 100644 --- a/src/tests/kits/net/ppp/src/KPPPInterface.cpp +++ b/src/tests/kits/net/ppp/src/KPPPInterface.cpp @@ -20,12 +20,12 @@ #include #include #include +#include // general helper classes not only belonging to us #include // tools only for us :) -#include "KPPPUtils.h" #include "settings_tools.h" diff --git a/src/tests/kits/net/ppp/src/KPPPOptionHandler.cpp b/src/tests/kits/net/ppp/src/KPPPOptionHandler.cpp index 08e55552b1..ccdf0845a0 100644 --- a/src/tests/kits/net/ppp/src/KPPPOptionHandler.cpp +++ b/src/tests/kits/net/ppp/src/KPPPOptionHandler.cpp @@ -12,7 +12,11 @@ PPPOptionHandler::PPPOptionHandler(const char *name, PPPInterface *interface, driver_parameter *settings) : fInterface(interface), fSettings(settings) { - fName = name ? strdup(name) : NULL; + if(name) { + strncpy(fName, name, PPP_HANDLER_NAME_LENGTH_LIMIT); + fName[PPP_HANDLER_NAME_LENGTH_LIMIT] = 0; + } else + strcpy(fName, ""); if(interface) interface->LCP().AddOptionHandler(this); @@ -21,8 +25,6 @@ PPPOptionHandler::PPPOptionHandler(const char *name, PPPInterface *interface, PPPOptionHandler::~PPPOptionHandler() { - free(fName); - if(Interface()) Interface()->LCP().RemoveOptionHandler(this); } diff --git a/src/tests/kits/net/ppp/src/KPPPProtocol.cpp b/src/tests/kits/net/ppp/src/KPPPProtocol.cpp index dab65ca5b2..2ec76d8246 100644 --- a/src/tests/kits/net/ppp/src/KPPPProtocol.cpp +++ b/src/tests/kits/net/ppp/src/KPPPProtocol.cpp @@ -17,7 +17,11 @@ PPPProtocol::PPPProtocol(const char *name, PPP_PHASE phase, uint16 protocol, fInterface(interface), fSettings(settings), fFlags(flags), fEnabled(true), fUpRequested(true), fConnectionStatus(PPP_DOWN_PHASE) { - fName = name ? strdup(name) : NULL; + if(name) { + strncpy(fName, name, PPP_HANDLER_NAME_LENGTH_LIMIT); + fName[PPP_HANDLER_NAME_LENGTH_LIMIT] = 0; + } else + strcpy(fName, ""); if(interface) interface->AddProtocol(this); @@ -26,8 +30,6 @@ PPPProtocol::PPPProtocol(const char *name, PPP_PHASE phase, uint16 protocol, PPPProtocol::~PPPProtocol() { - free(fName); - if(Interface()) Interface()->RemoveProtocol(this); } diff --git a/src/tests/kits/net/ppp/src/KPPPReportManager.cpp b/src/tests/kits/net/ppp/src/KPPPReportManager.cpp index f54cc574b5..7814ea224d 100644 --- a/src/tests/kits/net/ppp/src/KPPPReportManager.cpp +++ b/src/tests/kits/net/ppp/src/KPPPReportManager.cpp @@ -8,7 +8,7 @@ #include #include -#include "KPPPUtils.h" +#include #include diff --git a/src/tests/kits/net/ppp/src/KPPPUtils.cpp b/src/tests/kits/net/ppp/src/KPPPUtils.cpp index 24c00e7d46..c8d9e0c0e4 100644 --- a/src/tests/kits/net/ppp/src/KPPPUtils.cpp +++ b/src/tests/kits/net/ppp/src/KPPPUtils.cpp @@ -7,7 +7,7 @@ #include -#include "KPPPUtils.h" +#include // These are very simple send/receive_data functions with a timeout