I had nearly forgotten this.
Changed some constants to match our style-guidelines. Extended settings_tools to support modifying driver_settings/parameter structures (used by DialUpPreflet). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7157 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#include <sys/sockio.h>
|
||||
|
||||
|
||||
#define IPCP_STATE_MACHINE_TIMEOUT 3000000
|
||||
static const bigtime_t kIPCPStateMachineTimeout = 3000000;
|
||||
// 3 seconds
|
||||
|
||||
|
||||
@@ -1194,7 +1194,7 @@ IPCP::SendConfigureRequest()
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
--fRequestCounter;
|
||||
fNextTimeout = system_time() + IPCP_STATE_MACHINE_TIMEOUT;
|
||||
fNextTimeout = system_time() + kIPCPStateMachineTimeout;
|
||||
locker.UnlockNow();
|
||||
|
||||
KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
||||
@@ -1343,7 +1343,7 @@ IPCP::SendTerminateRequest()
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
--fTerminateCounter;
|
||||
fNextTimeout = system_time() + IPCP_STATE_MACHINE_TIMEOUT;
|
||||
fNextTimeout = system_time() + kIPCPStateMachineTimeout;
|
||||
locker.UnlockNow();
|
||||
|
||||
struct mbuf *packet = m_gethdr(MT_DATA);
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <KPPPConfigurePacket.h>
|
||||
|
||||
|
||||
#define ACFC_TYPE 0x8
|
||||
static const uint8 kACFCType = 0x8;
|
||||
|
||||
|
||||
ACFCHandler::ACFCHandler(uint32 options, KPPPInterface& interface)
|
||||
: KPPPOptionHandler("ACFC Handler", ACFC_TYPE, interface, NULL),
|
||||
: KPPPOptionHandler("ACFC Handler", kACFCType, interface, NULL),
|
||||
fOptions(options),
|
||||
fLocalState(ACFC_DISABLED),
|
||||
fPeerState(ACFC_DISABLED)
|
||||
@@ -32,7 +32,7 @@ ACFCHandler::AddToRequest(KPPPConfigurePacket& request)
|
||||
|
||||
// add ACFC request
|
||||
ppp_configure_item item;
|
||||
item.type = ACFC_TYPE;
|
||||
item.type = kACFCType;
|
||||
item.length = 2;
|
||||
return request.AddItem(&item) ? B_OK : B_ERROR;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ status_t
|
||||
ACFCHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
{
|
||||
// naks do not contain ACFC items
|
||||
if(nak.ItemWithType(ACFC_TYPE))
|
||||
if(nak.ItemWithType(kACFCType))
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
@@ -52,7 +52,7 @@ ACFCHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
status_t
|
||||
ACFCHandler::ParseReject(const KPPPConfigurePacket& reject)
|
||||
{
|
||||
if(reject.ItemWithType(ACFC_TYPE)) {
|
||||
if(reject.ItemWithType(kACFCType)) {
|
||||
fLocalState = ACFC_REJECTED;
|
||||
|
||||
if(Options() & FORCE_ACFC_REQUEST)
|
||||
@@ -66,7 +66,7 @@ ACFCHandler::ParseReject(const KPPPConfigurePacket& reject)
|
||||
status_t
|
||||
ACFCHandler::ParseAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
if(ack.ItemWithType(ACFC_TYPE))
|
||||
if(ack.ItemWithType(kACFCType))
|
||||
fLocalState = ACFC_ACCEPTED;
|
||||
else {
|
||||
fLocalState = ACFC_DISABLED;
|
||||
@@ -83,12 +83,12 @@ status_t
|
||||
ACFCHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject)
|
||||
{
|
||||
if(!request.ItemWithType(ACFC_TYPE))
|
||||
if(!request.ItemWithType(kACFCType))
|
||||
return B_OK;
|
||||
|
||||
if((Options() & ALLOW_ACFC) == 0) {
|
||||
ppp_configure_item item;
|
||||
item.type = ACFC_TYPE;
|
||||
item.type = kACFCType;
|
||||
item.length = 2;
|
||||
return reject.AddItem(&item) ? B_OK : B_ERROR;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ ACFCHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
status_t
|
||||
ACFCHandler::SendingAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
ppp_configure_item *item = ack.ItemWithType(ACFC_TYPE);
|
||||
ppp_configure_item *item = ack.ItemWithType(kACFCType);
|
||||
|
||||
if(item && (Options() & ALLOW_ACFC) == 0)
|
||||
return B_ERROR;
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
#include <sys/sockio.h>
|
||||
|
||||
|
||||
#define PAP_TIMEOUT 3000000
|
||||
static const bigtime_t kPAPTimeout = 3000000;
|
||||
// 3 seconds
|
||||
|
||||
|
||||
// PAPHandler
|
||||
#define AUTHENTICATION_TYPE 0x3
|
||||
#define AUTHENTICATOR_TYPE_STRING "Authenticator"
|
||||
static const uint8 kAuthenticationType = 0x3;
|
||||
static const char *kAuthenticatorTypeString = "Authenticator";
|
||||
|
||||
typedef struct authentication_item {
|
||||
uint8 type;
|
||||
@@ -33,7 +32,7 @@ typedef struct authentication_item {
|
||||
|
||||
|
||||
PAPHandler::PAPHandler(PAP& owner, KPPPInterface& interface)
|
||||
: KPPPOptionHandler("PAP", AUTHENTICATION_TYPE, interface, NULL),
|
||||
: KPPPOptionHandler("PAP", kAuthenticationType, interface, NULL),
|
||||
fOwner(owner)
|
||||
{
|
||||
}
|
||||
@@ -47,7 +46,7 @@ PAPHandler::AddToRequest(KPPPConfigurePacket& request)
|
||||
return B_OK;
|
||||
|
||||
authentication_item item;
|
||||
item.type = AUTHENTICATION_TYPE;
|
||||
item.type = kAuthenticationType;
|
||||
item.length = sizeof(item);
|
||||
item.protocolNumber = htons(PAP_PROTOCOL);
|
||||
|
||||
@@ -88,7 +87,7 @@ PAPHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
|
||||
// we merely check if the values are correct
|
||||
authentication_item *item = (authentication_item*) request.ItemAt(index);
|
||||
if(item->type != AUTHENTICATION_TYPE
|
||||
if(item->type != kAuthenticationType
|
||||
|| item->length != 4 || ntohs(item->protocolNumber) != PAP_PROTOCOL)
|
||||
return B_ERROR;
|
||||
|
||||
@@ -113,7 +112,7 @@ PAPHandler::Reset()
|
||||
PAP::PAP(KPPPInterface& interface, driver_parameter *settings)
|
||||
: KPPPProtocol("PAP", PPP_AUTHENTICATION_PHASE, PAP_PROTOCOL, PPP_PROTOCOL_LEVEL,
|
||||
AF_INET, 0, interface, settings, PPP_ALWAYS_ALLOWED,
|
||||
AUTHENTICATOR_TYPE_STRING, new PAPHandler(*this, interface)),
|
||||
kAuthenticatorTypeString, new PAPHandler(*this, interface)),
|
||||
fState(INITIAL),
|
||||
fID(system_time() & 0xFF),
|
||||
fMaxRequest(3),
|
||||
@@ -165,7 +164,7 @@ PAP::Up()
|
||||
} else if(Side() == PPP_PEER_SIDE) {
|
||||
NewState(WAITING_FOR_REQ);
|
||||
InitializeRestartCount();
|
||||
fNextTimeout = system_time() + PAP_TIMEOUT;
|
||||
fNextTimeout = system_time() + kPAPTimeout;
|
||||
} else {
|
||||
UpFailedEvent();
|
||||
return false;
|
||||
@@ -381,7 +380,7 @@ PAP::TOGoodEvent()
|
||||
break;
|
||||
|
||||
case WAITING_FOR_REQ:
|
||||
fNextTimeout = system_time() + PAP_TIMEOUT;
|
||||
fNextTimeout = system_time() + kPAPTimeout;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -541,7 +540,7 @@ PAP::SendRequest()
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
--fRequestCounter;
|
||||
fNextTimeout = system_time() + PAP_TIMEOUT;
|
||||
fNextTimeout = system_time() + kPAPTimeout;
|
||||
locker.UnlockNow();
|
||||
|
||||
struct mbuf *packet = m_gethdr(MT_DATA);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <core_funcs.h>
|
||||
|
||||
|
||||
#define PPP_STATE_MACHINE_TIMEOUT 3000000
|
||||
static const bigtime_t kPPPStateMachineTimeout = 3000000;
|
||||
// 3 seconds
|
||||
|
||||
|
||||
@@ -265,6 +265,8 @@ KPPPStateMachine::LocalAuthenticationDenied(const char *name)
|
||||
fLocalAuthenticationName = strdup(name);
|
||||
else
|
||||
fLocalAuthenticationName = NULL;
|
||||
|
||||
// the report will be sent in DownEvent()
|
||||
}
|
||||
|
||||
|
||||
@@ -329,6 +331,8 @@ KPPPStateMachine::PeerAuthenticationDenied(const char *name)
|
||||
fPeerAuthenticationName = NULL;
|
||||
|
||||
CloseEvent();
|
||||
|
||||
// the report will be sent in DownEvent()
|
||||
}
|
||||
|
||||
|
||||
@@ -1762,7 +1766,7 @@ KPPPStateMachine::SendConfigureRequest()
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
--fRequestCounter;
|
||||
fNextTimeout = system_time() + PPP_STATE_MACHINE_TIMEOUT;
|
||||
fNextTimeout = system_time() + kPPPStateMachineTimeout;
|
||||
locker.UnlockNow();
|
||||
|
||||
KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
||||
@@ -1843,7 +1847,7 @@ KPPPStateMachine::SendTerminateRequest()
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
--fTerminateCounter;
|
||||
fNextTimeout = system_time() + PPP_STATE_MACHINE_TIMEOUT;
|
||||
fNextTimeout = system_time() + kPPPStateMachineTimeout;
|
||||
locker.UnlockNow();
|
||||
|
||||
struct mbuf *packet = m_gethdr(MT_DATA);
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
||||
#define AUTHENTICATION_TYPE 0x3
|
||||
#define AUTHENTICATOR_TYPE_STRING "Authenticator"
|
||||
static const uint8 kAuthenticationType = 0x3;
|
||||
static const char *kAuthenticatorTypeString = "Authenticator";
|
||||
|
||||
typedef struct authentication_item {
|
||||
uint8 type;
|
||||
@@ -24,7 +24,7 @@ typedef struct authentication_item {
|
||||
|
||||
|
||||
_KPPPAuthenticationHandler::_KPPPAuthenticationHandler(KPPPInterface& interface)
|
||||
: KPPPOptionHandler("Authentication Handler", AUTHENTICATION_TYPE, interface, NULL),
|
||||
: KPPPOptionHandler("Authentication Handler", kAuthenticationType, interface, NULL),
|
||||
fLocalAuthenticator(NULL),
|
||||
fPeerAuthenticator(NULL),
|
||||
fSuggestedLocalAuthenticator(NULL),
|
||||
@@ -42,7 +42,7 @@ _KPPPAuthenticationHandler::NextAuthenticator(const KPPPProtocol *start,
|
||||
KPPPProtocol *current = start ? start->NextProtocol() : Interface().FirstProtocol();
|
||||
|
||||
for(; current; current = current->NextProtocol()) {
|
||||
if(current->Type() && !strcasecmp(current->Type(), AUTHENTICATOR_TYPE_STRING)
|
||||
if(current->Type() && !strcasecmp(current->Type(), kAuthenticatorTypeString)
|
||||
&& current->OptionHandler() && current->Side() == side)
|
||||
return current;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ _KPPPAuthenticationHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
// The authenticator's OptionHandler is not notified.
|
||||
|
||||
authentication_item *item =
|
||||
(authentication_item*) nak.ItemWithType(AUTHENTICATION_TYPE);
|
||||
(authentication_item*) nak.ItemWithType(kAuthenticationType);
|
||||
|
||||
if(!item)
|
||||
return B_OK;
|
||||
@@ -137,7 +137,7 @@ _KPPPAuthenticationHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
fPeerAuthenticatorRejected = true;
|
||||
KPPPProtocol *authenticator = Interface().ProtocolFor(ntohs(item->protocolNumber));
|
||||
if(authenticator && authenticator->Type()
|
||||
&& !strcasecmp(authenticator->Type(), AUTHENTICATOR_TYPE_STRING)
|
||||
&& !strcasecmp(authenticator->Type(), kAuthenticatorTypeString)
|
||||
&& authenticator->OptionHandler())
|
||||
fSuggestedPeerAuthenticator = authenticator;
|
||||
else
|
||||
@@ -151,7 +151,7 @@ status_t
|
||||
_KPPPAuthenticationHandler::ParseReject(const KPPPConfigurePacket& reject)
|
||||
{
|
||||
// an authentication request must not be rejected!
|
||||
if(reject.ItemWithType(AUTHENTICATION_TYPE))
|
||||
if(reject.ItemWithType(kAuthenticationType))
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
@@ -162,7 +162,7 @@ status_t
|
||||
_KPPPAuthenticationHandler::ParseAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
authentication_item *item =
|
||||
(authentication_item*) ack.ItemWithType(AUTHENTICATION_TYPE);
|
||||
(authentication_item*) ack.ItemWithType(kAuthenticationType);
|
||||
|
||||
if(!item) {
|
||||
if(fPeerAuthenticator)
|
||||
@@ -200,7 +200,7 @@ _KPPPAuthenticationHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
// try to find the requested protocol
|
||||
fLocalAuthenticator = Interface().ProtocolFor(ntohs(item->protocolNumber));
|
||||
if(fLocalAuthenticator && fLocalAuthenticator->Type()
|
||||
&& !strcasecmp(fLocalAuthenticator->Type(), AUTHENTICATOR_TYPE_STRING)
|
||||
&& !strcasecmp(fLocalAuthenticator->Type(), kAuthenticatorTypeString)
|
||||
&& fLocalAuthenticator->OptionHandler())
|
||||
return fLocalAuthenticator->OptionHandler()->ParseRequest(request, index,
|
||||
nak, reject);
|
||||
@@ -225,7 +225,7 @@ _KPPPAuthenticationHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
|
||||
// nak this authenticator and suggest an alternative
|
||||
authentication_item suggestion;
|
||||
suggestion.type = AUTHENTICATION_TYPE;
|
||||
suggestion.type = kAuthenticationType;
|
||||
suggestion.length = 4;
|
||||
suggestion.protocolNumber = htons(nextAuthenticator->ProtocolNumber());
|
||||
return nak.AddItem((ppp_configure_item*) &suggestion) ? B_OK : B_ERROR;
|
||||
@@ -238,7 +238,7 @@ _KPPPAuthenticationHandler::SendingAck(const KPPPConfigurePacket& ack)
|
||||
// do not insist on authenticating our side of the link ;)
|
||||
|
||||
authentication_item *item =
|
||||
(authentication_item*) ack.ItemWithType(AUTHENTICATION_TYPE);
|
||||
(authentication_item*) ack.ItemWithType(kAuthenticationType);
|
||||
|
||||
if(!item)
|
||||
return B_OK;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
||||
#define MRU_TYPE 0x1
|
||||
static const uint8 kMRUType = 0x1;
|
||||
|
||||
typedef struct mru_item {
|
||||
uint8 type;
|
||||
@@ -25,7 +25,7 @@ status_t ParseRequestedItem(mru_item *item, KPPPInterface& interface);
|
||||
|
||||
|
||||
_KPPPMRUHandler::_KPPPMRUHandler(KPPPInterface& interface)
|
||||
: KPPPOptionHandler("MRU Handler", MRU_TYPE, interface, NULL)
|
||||
: KPPPOptionHandler("MRU Handler", kMRUType, interface, NULL)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
@@ -39,7 +39,7 @@ _KPPPMRUHandler::AddToRequest(KPPPConfigurePacket& request)
|
||||
|
||||
// add MRU request
|
||||
mru_item item;
|
||||
item.type = MRU_TYPE;
|
||||
item.type = kMRUType;
|
||||
item.length = 4;
|
||||
item.MRU = htons(fLocalMRU);
|
||||
return request.AddItem((ppp_configure_item*) &item) ? B_OK : B_ERROR;
|
||||
@@ -49,7 +49,7 @@ _KPPPMRUHandler::AddToRequest(KPPPConfigurePacket& request)
|
||||
status_t
|
||||
_KPPPMRUHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
{
|
||||
mru_item *item = (mru_item*) nak.ItemWithType(MRU_TYPE);
|
||||
mru_item *item = (mru_item*) nak.ItemWithType(kMRUType);
|
||||
if(!item || item->length != 4)
|
||||
return B_OK;
|
||||
|
||||
@@ -64,7 +64,7 @@ _KPPPMRUHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
status_t
|
||||
_KPPPMRUHandler::ParseReject(const KPPPConfigurePacket& reject)
|
||||
{
|
||||
if(reject.ItemWithType(MRU_TYPE))
|
||||
if(reject.ItemWithType(kMRUType))
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
@@ -75,7 +75,7 @@ status_t
|
||||
_KPPPMRUHandler::ParseAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
uint16 MRU = 1500;
|
||||
mru_item *item = (mru_item*) ack.ItemWithType(MRU_TYPE);
|
||||
mru_item *item = (mru_item*) ack.ItemWithType(kMRUType);
|
||||
|
||||
if(item)
|
||||
MRU = ntohs(item->MRU);
|
||||
@@ -103,7 +103,7 @@ _KPPPMRUHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
status_t
|
||||
_KPPPMRUHandler::SendingAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
return ParseRequestedItem((mru_item*) ack.ItemWithType(MRU_TYPE), Interface());
|
||||
return ParseRequestedItem((mru_item*) ack.ItemWithType(kMRUType), Interface());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include <KPPPConfigurePacket.h>
|
||||
|
||||
|
||||
#define PFC_TYPE 0x7
|
||||
static const uint8 kPFCType = 0x7;
|
||||
|
||||
|
||||
_KPPPPFCHandler::_KPPPPFCHandler(ppp_pfc_state& localPFCState,
|
||||
ppp_pfc_state& peerPFCState, KPPPInterface& interface)
|
||||
: KPPPOptionHandler("PFC Handler", PFC_TYPE, interface, NULL),
|
||||
: KPPPOptionHandler("PFC Handler", kPFCType, interface, NULL),
|
||||
fLocalPFCState(localPFCState),
|
||||
fPeerPFCState(peerPFCState)
|
||||
{
|
||||
@@ -32,7 +32,7 @@ _KPPPPFCHandler::AddToRequest(KPPPConfigurePacket& request)
|
||||
|
||||
// add PFC request
|
||||
ppp_configure_item item;
|
||||
item.type = PFC_TYPE;
|
||||
item.type = kPFCType;
|
||||
item.length = 2;
|
||||
return request.AddItem(&item) ? B_OK : B_ERROR;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ status_t
|
||||
_KPPPPFCHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
{
|
||||
// naks do not contain PFC items
|
||||
if(nak.ItemWithType(PFC_TYPE))
|
||||
if(nak.ItemWithType(kPFCType))
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
@@ -52,7 +52,7 @@ _KPPPPFCHandler::ParseNak(const KPPPConfigurePacket& nak)
|
||||
status_t
|
||||
_KPPPPFCHandler::ParseReject(const KPPPConfigurePacket& reject)
|
||||
{
|
||||
if(reject.ItemWithType(PFC_TYPE)) {
|
||||
if(reject.ItemWithType(kPFCType)) {
|
||||
fLocalPFCState = PPP_PFC_REJECTED;
|
||||
|
||||
if(Interface().PFCOptions() & PPP_FORCE_PFC_REQUEST)
|
||||
@@ -66,7 +66,7 @@ _KPPPPFCHandler::ParseReject(const KPPPConfigurePacket& reject)
|
||||
status_t
|
||||
_KPPPPFCHandler::ParseAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
if(ack.ItemWithType(PFC_TYPE))
|
||||
if(ack.ItemWithType(kPFCType))
|
||||
fLocalPFCState = PPP_PFC_ACCEPTED;
|
||||
else {
|
||||
fLocalPFCState = PPP_PFC_DISABLED;
|
||||
@@ -83,12 +83,12 @@ status_t
|
||||
_KPPPPFCHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject)
|
||||
{
|
||||
if(!request.ItemWithType(PFC_TYPE))
|
||||
if(!request.ItemWithType(kPFCType))
|
||||
return B_OK;
|
||||
|
||||
if((Interface().PFCOptions() & PPP_ALLOW_PFC) == 0) {
|
||||
ppp_configure_item item;
|
||||
item.type = PFC_TYPE;
|
||||
item.type = kPFCType;
|
||||
item.length = 2;
|
||||
return reject.AddItem(&item) ? B_OK : B_ERROR;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ _KPPPPFCHandler::ParseRequest(const KPPPConfigurePacket& request,
|
||||
status_t
|
||||
_KPPPPFCHandler::SendingAck(const KPPPConfigurePacket& ack)
|
||||
{
|
||||
ppp_configure_item *item = ack.ItemWithType(PFC_TYPE);
|
||||
ppp_configure_item *item = ack.ItemWithType(kPFCType);
|
||||
|
||||
if(item && (Interface().PFCOptions() & PPP_ALLOW_PFC) == 0)
|
||||
return B_ERROR;
|
||||
|
||||
@@ -98,9 +98,9 @@ typedef struct ppp_interface_description_info {
|
||||
} u;
|
||||
//!< Different values for describing an interface.
|
||||
const driver_settings *profile;
|
||||
//!<
|
||||
//!< An optional profile. If \a profile == NULL the default profile is used.
|
||||
ppp_interface_id interface;
|
||||
//!< the found/created interface
|
||||
//!< The id of the found/created interface.
|
||||
} ppp_interface_description_info;
|
||||
|
||||
|
||||
@@ -109,11 +109,11 @@ typedef struct ppp_get_interfaces_info {
|
||||
ppp_interface_id *interfaces;
|
||||
//!< The interface ids will be written to this pointer's target.
|
||||
int32 count;
|
||||
//!< \a Interface has \a count entries.
|
||||
//!< The \a interfaces field has enough space for \a count entries.
|
||||
ppp_interface_filter filter;
|
||||
//!< Only interfaces that match this filter will be returned
|
||||
int32 resultCount;
|
||||
//!< The number of saved interfaces.
|
||||
//!< The number of entries that the \a interfaces field contains.
|
||||
} ppp_get_interfaces_info;
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ typedef struct ppp_control_info {
|
||||
uint32 op;
|
||||
//!< The Control()/ioctl() opcode. This can be any value from ppp_control_ops.
|
||||
void *data;
|
||||
//!< Additional data may be specified.
|
||||
//!< Additional data may be specified here.
|
||||
size_t length;
|
||||
//!< The length should always be set.
|
||||
} ppp_control_info;
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
// TODO: remove this as soon as we get the extended driver_settings API
|
||||
extern driver_settings *dup_driver_settings(const driver_settings *settings);
|
||||
extern void free_driver_settings(driver_settings *settings);
|
||||
extern void free_driver_parameter_fields(driver_parameter *parameter);
|
||||
|
||||
extern driver_settings *new_driver_settings();
|
||||
extern driver_parameter *new_driver_parameter(const char *name);
|
||||
extern bool copy_driver_parameter(const driver_parameter *from, driver_parameter *to);
|
||||
extern bool set_driver_parameter_name(const char *name, driver_parameter *parameter);
|
||||
extern bool add_driver_parameter_value(const char *value, driver_parameter *to);
|
||||
extern bool add_driver_parameter(driver_parameter *add, driver_settings *to);
|
||||
|
||||
extern bool equal_driver_settings(const driver_settings *lhs,
|
||||
const driver_settings *rhs);
|
||||
@@ -31,12 +39,26 @@ extern const char *get_settings_value(const char *name,
|
||||
const driver_settings *settings);
|
||||
|
||||
|
||||
inline
|
||||
bool
|
||||
add_driver_parameter(driver_parameter *add, driver_parameter *to)
|
||||
{
|
||||
if(!to)
|
||||
return false;
|
||||
|
||||
return add_driver_parameter(add, (driver_settings*) &to->parameter_count);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
const driver_parameter*
|
||||
get_parameter_with_name(const char *name, const driver_parameter *parameters)
|
||||
{
|
||||
if(!parameters)
|
||||
return NULL;
|
||||
|
||||
return get_parameter_with_name(name,
|
||||
parameters ? (driver_settings*) ¶meters->parameter_count : NULL);
|
||||
(driver_settings*) ¶meters->parameter_count);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +66,10 @@ inline
|
||||
const char*
|
||||
get_parameter_value(const char *name, const driver_parameter *parameters)
|
||||
{
|
||||
return get_settings_value(name,
|
||||
parameters ? (driver_settings*) ¶meters->parameter_count : NULL);
|
||||
if(parameters)
|
||||
return NULL;
|
||||
|
||||
return get_settings_value(name, (driver_settings*) ¶meters->parameter_count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
static char *sSkipInterfaceParameters[] = {
|
||||
static const char *sSkipInterfaceParameters[] = {
|
||||
PPP_ASK_BEFORE_DIALING_KEY,
|
||||
PPP_DISONNECT_AFTER_IDLE_SINCE_KEY,
|
||||
PPP_DIAL_RETRIES_LIMIT_KEY,
|
||||
@@ -25,9 +25,6 @@ static char *sSkipInterfaceParameters[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static void copy_parameter(const driver_parameter *from, driver_parameter *to);
|
||||
static void free_driver_parameter(driver_parameter *parameter);
|
||||
|
||||
|
||||
driver_settings*
|
||||
dup_driver_settings(const driver_settings *dup)
|
||||
@@ -40,27 +37,87 @@ dup_driver_settings(const driver_settings *dup)
|
||||
ret->parameter_count = dup->parameter_count;
|
||||
|
||||
if(ret->parameter_count > 0)
|
||||
ret->parameters =
|
||||
(driver_parameter*) malloc(ret->parameter_count * sizeof(driver_parameter));
|
||||
ret->parameters = (driver_parameter*)
|
||||
malloc(ret->parameter_count * sizeof(driver_parameter));
|
||||
else
|
||||
ret->parameters = NULL;
|
||||
|
||||
for(int32 index = 0; index < ret->parameter_count; index++)
|
||||
copy_parameter(&dup->parameters[index], &ret->parameters[index]);
|
||||
copy_driver_parameter(&dup->parameters[index], &ret->parameters[index]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void
|
||||
copy_parameter(const driver_parameter *from, driver_parameter *to)
|
||||
free_driver_settings(driver_settings *settings)
|
||||
{
|
||||
to->name = strdup(from->name);
|
||||
to->value_count = from->value_count;
|
||||
if(!settings)
|
||||
return;
|
||||
|
||||
if(to->value_count > 0)
|
||||
to->values = (char**) malloc(to->value_count * sizeof(char*));
|
||||
for(int32 index = 0; index < settings->parameter_count; index++)
|
||||
free_driver_parameter_fields(&settings->parameters[index]);
|
||||
|
||||
free(settings->parameters);
|
||||
free(settings);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
free_driver_parameter_fields(driver_parameter *parameter)
|
||||
{
|
||||
free(parameter->name);
|
||||
|
||||
for(int32 index = 0; index < parameter->value_count; index++)
|
||||
free(parameter->values[index]);
|
||||
|
||||
free(parameter->values);
|
||||
|
||||
for(int32 index = 0; index < parameter->parameter_count; index++)
|
||||
free_driver_parameter_fields(¶meter->parameters[index]);
|
||||
|
||||
free(parameter->parameters);
|
||||
}
|
||||
|
||||
|
||||
driver_settings*
|
||||
new_driver_settings()
|
||||
{
|
||||
driver_settings *settings = (driver_settings*) malloc(sizeof(driver_settings));
|
||||
memset(settings, 0, sizeof(driver_settings));
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
driver_parameter*
|
||||
new_driver_parameter(const char *name)
|
||||
{
|
||||
driver_parameter *parameter = (driver_parameter*) malloc(sizeof(driver_parameter));
|
||||
memset(parameter, 0, sizeof(driver_parameter));
|
||||
|
||||
set_driver_parameter_name(name, parameter);
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
copy_driver_parameter(const driver_parameter *from, driver_parameter *to)
|
||||
{
|
||||
if(!from || !to)
|
||||
return false;
|
||||
|
||||
free_driver_parameter_fields(to);
|
||||
|
||||
if(from->name)
|
||||
to->name = strdup(from->name);
|
||||
else
|
||||
to->name = NULL;
|
||||
|
||||
to->value_count = from->value_count;
|
||||
if(from->value_count > 0)
|
||||
to->values = (char**) malloc(from->value_count * sizeof(char*));
|
||||
else
|
||||
to->values = NULL;
|
||||
|
||||
@@ -76,39 +133,75 @@ copy_parameter(const driver_parameter *from, driver_parameter *to)
|
||||
to->parameters = NULL;
|
||||
|
||||
for(int32 index = 0; index < to->parameter_count; index++)
|
||||
copy_parameter(&from->parameters[index], &to->parameters[index]);
|
||||
copy_driver_parameter(&from->parameters[index], &to->parameters[index]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
free_driver_settings(driver_settings *settings)
|
||||
bool
|
||||
set_driver_parameter_name(const char *name, driver_parameter *parameter)
|
||||
{
|
||||
if(!settings)
|
||||
return;
|
||||
if(!parameter)
|
||||
return false;
|
||||
|
||||
for(int32 index = 0; index < settings->parameter_count; index++)
|
||||
free_driver_parameter(&settings->parameters[index]);
|
||||
|
||||
free(settings->parameters);
|
||||
free(settings);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void
|
||||
free_driver_parameter(driver_parameter *parameter)
|
||||
{
|
||||
free(parameter->name);
|
||||
|
||||
for(int32 index = 0; index < parameter->value_count; index++)
|
||||
free(parameter->values[index]);
|
||||
if(name)
|
||||
parameter->name = strdup(name);
|
||||
else
|
||||
parameter->name = NULL;
|
||||
|
||||
free(parameter->values);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
add_driver_parameter_value(const char *value, driver_parameter *to)
|
||||
{
|
||||
if(!value || !to)
|
||||
return false;
|
||||
|
||||
for(int32 index = 0; index < parameter->parameter_count; index++)
|
||||
free_driver_parameter(¶meter->parameters[index]);
|
||||
int32 oldCount = to->value_count;
|
||||
char **old = to->values;
|
||||
|
||||
free(parameter->parameters);
|
||||
to->values = (char**) malloc(to->value_count + 1 * sizeof(char*));
|
||||
|
||||
if(!to->values) {
|
||||
to->values = old;
|
||||
return false;
|
||||
}
|
||||
|
||||
to->value_count++;
|
||||
memcpy(to->values, old, oldCount * sizeof(char*));
|
||||
to->values[oldCount] = strdup(value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
add_driver_parameter(driver_parameter *add, driver_settings *to)
|
||||
{
|
||||
if(!add || !to)
|
||||
return false;
|
||||
|
||||
int32 oldCount = to->parameter_count;
|
||||
driver_parameter *old = to->parameters;
|
||||
|
||||
to->parameters =
|
||||
(driver_parameter*) malloc(to->parameter_count + 1 * sizeof(driver_parameter));
|
||||
|
||||
if(!to->parameters) {
|
||||
to->parameters = old;
|
||||
return false;
|
||||
}
|
||||
|
||||
to->parameter_count++;
|
||||
memcpy(to->parameters, old, oldCount * sizeof(driver_parameter));
|
||||
memcpy(to->parameters + oldCount, add, sizeof(driver_parameter));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
SubDir OBOS_TOP src add-ons kernel network ppp shared libppp ;
|
||||
|
||||
UsePrivateHeaders net ;
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src servers net ] ;
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libppp headers ] ;
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp headers ] ;
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include <LockerHelper.h>
|
||||
|
||||
|
||||
#define REPORT_FLAGS PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT \
|
||||
| PPP_ALLOW_ANY_REPLY_THREAD
|
||||
static const uint32 kReportFlags = PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT
|
||||
| PPP_ALLOW_ANY_REPLY_THREAD;
|
||||
|
||||
#define QUIT_REPORT_THREAD 'QUIT'
|
||||
static const uint32 kCodeQuitReportThread = 'QUIT';
|
||||
|
||||
|
||||
class PPPInterfaceListenerThread {
|
||||
@@ -46,7 +46,7 @@ PPPInterfaceListenerThread::Run()
|
||||
while(true) {
|
||||
code = receive_data(&sender, &packet, sizeof(packet));
|
||||
|
||||
if(code == QUIT_REPORT_THREAD)
|
||||
if(code == kCodeQuitReportThread)
|
||||
break;
|
||||
else if(code != PPP_REPORT_CODE)
|
||||
continue;
|
||||
@@ -121,7 +121,7 @@ PPPInterfaceListener::~PPPInterfaceListener()
|
||||
Manager().DisableReports(PPP_ALL_REPORTS, fReportThread);
|
||||
|
||||
// tell thread to quit
|
||||
send_data(fReportThread, QUIT_REPORT_THREAD, NULL, 0);
|
||||
send_data(fReportThread, kCodeQuitReportThread, NULL, 0);
|
||||
int32 tmp;
|
||||
wait_for_thread(fReportThread, &tmp);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ PPPInterfaceListener::WatchInterface(ppp_interface_id ID)
|
||||
if(interface.InitCheck() != B_OK)
|
||||
return false;
|
||||
|
||||
if(!interface.EnableReports(PPP_CONNECTION_REPORT, fReportThread, REPORT_FLAGS))
|
||||
if(!interface.EnableReports(PPP_CONNECTION_REPORT, fReportThread, kReportFlags))
|
||||
return false;
|
||||
|
||||
fDoesWatch = true;
|
||||
@@ -182,7 +182,7 @@ PPPInterfaceListener::WatchAllInterfaces()
|
||||
|
||||
for(int32 index = 0; index < count; index++) {
|
||||
interface.SetTo(interfaceList[index]);
|
||||
interface.EnableReports(PPP_CONNECTION_REPORT, fReportThread, REPORT_FLAGS);
|
||||
interface.EnableReports(PPP_CONNECTION_REPORT, fReportThread, kReportFlags);
|
||||
}
|
||||
delete interfaceList;
|
||||
|
||||
@@ -231,5 +231,5 @@ PPPInterfaceListener::Construct()
|
||||
resume_thread(fReportThread);
|
||||
|
||||
// enable manager reports
|
||||
Manager().EnableReports(PPP_MANAGER_REPORT, fReportThread, REPORT_FLAGS);
|
||||
Manager().EnableReports(PPP_MANAGER_REPORT, fReportThread, kReportFlags);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#define __libppputils__h
|
||||
|
||||
#include <net_stack_driver.h>
|
||||
#include <NetServer.h>
|
||||
|
||||
|
||||
#define PPP_SERVER_SIGNATURE NET_SERVER_SIGNATURE
|
||||
|
||||
|
||||
char *get_stack_driver_path();
|
||||
|
||||
Reference in New Issue
Block a user