Renamed "Dial" to "Connect" (only modems dial).
Removed DialOnDemand settings key. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10496 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
beabca50a7
commit
0cbb739d3b
@ -183,7 +183,7 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
||||
++entry->accessing;
|
||||
locker.UnlockNow();
|
||||
|
||||
if(!entry->interface->DoesDialOnDemand()
|
||||
if(!entry->interface->DoesConnectOnDemand()
|
||||
&& ifp->if_flags & (IFF_UP | IFF_RUNNING) != (IFF_UP | IFF_RUNNING)) {
|
||||
m_freem(buf);
|
||||
--entry->accessing;
|
||||
@ -232,7 +232,7 @@ PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data)
|
||||
switch(cmd) {
|
||||
case SIOCSIFFLAGS:
|
||||
if(((ifreq*)data)->ifr_flags & IFF_DOWN) {
|
||||
if(entry->interface->DoesDialOnDemand()
|
||||
if(entry->interface->DoesConnectOnDemand()
|
||||
&& entry->interface->Phase() == PPP_DOWN_PHASE)
|
||||
DeleteInterface(entry->interface->ID());
|
||||
else
|
||||
|
@ -424,7 +424,7 @@ IPCP::UpdateAddresses()
|
||||
{
|
||||
RemoveRoutes();
|
||||
|
||||
if(State() != PPP_OPENED_STATE && !Interface().DoesDialOnDemand())
|
||||
if(State() != PPP_OPENED_STATE && !Interface().DoesConnectOnDemand())
|
||||
return;
|
||||
|
||||
struct in_aliasreq inreq;
|
||||
|
@ -22,7 +22,7 @@ class PPPoEDevice;
|
||||
#define PPPoE_TIMEOUT 3000000
|
||||
// 3 seconds
|
||||
#define PPPoE_MAX_ATTEMPTS 2
|
||||
// maximum number of PPPoE's dial-retries
|
||||
// maximum number of PPPoE's connect-retries
|
||||
|
||||
#define PPPoE_VERSION 0x1
|
||||
#define PPPoE_TYPE 0x1
|
||||
|
@ -52,17 +52,17 @@
|
||||
// TODO:
|
||||
// - implement timers with support for setting next event instead of receiving timer
|
||||
// events periodically
|
||||
// - add missing settings support (DialRetryDelay, etc.)
|
||||
// - add missing settings support (ConnectRetryDelay, etc.)
|
||||
|
||||
|
||||
//! Private structure needed for redialing.
|
||||
typedef struct redial_info {
|
||||
//! Private structure needed for reconnecting.
|
||||
typedef struct reconnect_info {
|
||||
KPPPInterface *interface;
|
||||
thread_id *thread;
|
||||
uint32 delay;
|
||||
} redial_info;
|
||||
} reconnect_info;
|
||||
|
||||
status_t redial_thread(void *data);
|
||||
status_t reconnect_thread(void *data);
|
||||
|
||||
// other functions
|
||||
status_t interface_deleter_thread(void *data);
|
||||
@ -91,9 +91,9 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
||||
fUpThread(-1),
|
||||
fOpenEventThread(-1),
|
||||
fCloseEventThread(-1),
|
||||
fRedialThread(-1),
|
||||
fDialRetry(0),
|
||||
fDialRetriesLimit(0),
|
||||
fReconnectThread(-1),
|
||||
fConnectRetry(0),
|
||||
fConnectRetriesLimit(0),
|
||||
fManager(NULL),
|
||||
fIdleSince(0),
|
||||
fMRU(1500),
|
||||
@ -101,8 +101,8 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
||||
fHeaderLength(2),
|
||||
fParent(NULL),
|
||||
fIsMultilink(false),
|
||||
fAutoRedial(false),
|
||||
fDialOnDemand(false),
|
||||
fAutoReconnect(false),
|
||||
fConnectOnDemand(false),
|
||||
fMode(PPP_CLIENT_MODE),
|
||||
fLocalPFCState(PPP_PFC_DISABLED),
|
||||
fPeerPFCState(PPP_PFC_DISABLED),
|
||||
@ -171,11 +171,11 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
||||
delete pfcHandler;
|
||||
}
|
||||
|
||||
// set up dial delays
|
||||
fDialRetryDelay = 3000;
|
||||
// 3s delay between each new attempt to redial
|
||||
fRedialDelay = 1000;
|
||||
// 1s delay between lost connection and redial
|
||||
// set up connect delays
|
||||
fConnectRetryDelay = 3000;
|
||||
// 3s delay between each new attempt to reconnect
|
||||
fReconnectDelay = 1000;
|
||||
// 1s delay between lost connection and reconnect
|
||||
|
||||
if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK)
|
||||
ERROR("KPPPInterface: Manager module not found!\n");
|
||||
@ -214,12 +214,12 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
||||
fMode = PPP_CLIENT_MODE;
|
||||
// we are a client by default
|
||||
|
||||
SetAutoRedial(
|
||||
SetAutoReconnect(
|
||||
get_boolean_value(
|
||||
get_settings_value(PPP_AUTO_REDIAL_KEY, fSettings),
|
||||
get_settings_value(PPP_AUTO_RECONNECT_KEY, fSettings),
|
||||
false)
|
||||
);
|
||||
// auto redial is disabled by default
|
||||
// auto reconnect is disabled by default
|
||||
|
||||
// load all protocols and the device
|
||||
if(!LoadModules(fSettings, 0, fSettings->parameter_count)) {
|
||||
@ -261,9 +261,9 @@ KPPPInterface::~KPPPInterface()
|
||||
// tell all listeners that we are being destroyed
|
||||
|
||||
int32 tmp;
|
||||
send_data_with_timeout(fRedialThread, 0, NULL, 0, 200);
|
||||
send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
|
||||
// tell thread that we are being destroyed (200ms timeout)
|
||||
wait_for_thread(fRedialThread, &tmp);
|
||||
wait_for_thread(fReconnectThread, &tmp);
|
||||
wait_for_thread(fOpenEventThread, &tmp);
|
||||
wait_for_thread(fCloseEventThread, &tmp);
|
||||
|
||||
@ -418,14 +418,14 @@ KPPPInterface::Control(uint32 op, void *data, size_t length)
|
||||
info->childrenCount = CountChildren();
|
||||
info->MRU = MRU();
|
||||
info->interfaceMTU = InterfaceMTU();
|
||||
info->dialRetry = fDialRetry;
|
||||
info->dialRetriesLimit = fDialRetriesLimit;
|
||||
info->dialRetryDelay = DialRetryDelay();
|
||||
info->redialDelay = RedialDelay();
|
||||
info->connectRetry = fConnectRetry;
|
||||
info->connectRetriesLimit = fConnectRetriesLimit;
|
||||
info->connectRetryDelay = ConnectRetryDelay();
|
||||
info->reconnectDelay = ReconnectDelay();
|
||||
info->idleSince = IdleSince();
|
||||
info->disconnectAfterIdleSince = DisconnectAfterIdleSince();
|
||||
info->doesDialOnDemand = DoesDialOnDemand();
|
||||
info->doesAutoRedial = DoesAutoRedial();
|
||||
info->doesConnectOnDemand = DoesConnectOnDemand();
|
||||
info->doesAutoReconnect = DoesAutoReconnect();
|
||||
info->hasDevice = Device();
|
||||
info->isMultilink = IsMultilink();
|
||||
info->hasParent = Parent();
|
||||
@ -438,18 +438,18 @@ KPPPInterface::Control(uint32 op, void *data, size_t length)
|
||||
SetMRU(*((uint32*)data));
|
||||
break;
|
||||
|
||||
case PPPC_SET_DIAL_ON_DEMAND:
|
||||
case PPPC_SET_CONNECT_ON_DEMAND:
|
||||
if(length < sizeof(uint32) || !data)
|
||||
return B_ERROR;
|
||||
|
||||
SetDialOnDemand(*((uint32*)data));
|
||||
SetConnectOnDemand(*((uint32*)data));
|
||||
break;
|
||||
|
||||
case PPPC_SET_AUTO_REDIAL:
|
||||
case PPPC_SET_AUTO_RECONNECT:
|
||||
if(length < sizeof(uint32) || !data)
|
||||
return B_ERROR;
|
||||
|
||||
SetAutoRedial(*((uint32*)data));
|
||||
SetAutoReconnect(*((uint32*)data));
|
||||
break;
|
||||
|
||||
case PPPC_HAS_INTERFACE_SETTINGS:
|
||||
@ -841,41 +841,41 @@ KPPPInterface::ChildAt(int32 index) const
|
||||
}
|
||||
|
||||
|
||||
//! Enables or disables the auto-redial feture.
|
||||
//! Enables or disables the auto-reconnect feture.
|
||||
void
|
||||
KPPPInterface::SetAutoRedial(bool autoRedial = true)
|
||||
KPPPInterface::SetAutoReconnect(bool autoReconnect = true)
|
||||
{
|
||||
TRACE("KPPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false");
|
||||
TRACE("KPPPInterface: SetAutoReconnect(%s)\n", autoReconnect ? "true" : "false");
|
||||
|
||||
if(Mode() != PPP_CLIENT_MODE)
|
||||
return;
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
|
||||
fAutoRedial = autoRedial;
|
||||
fAutoReconnect = autoReconnect;
|
||||
}
|
||||
|
||||
|
||||
//! Enables or disables the dial-on-demand feature.
|
||||
//! Enables or disables the connect-on-demand feature.
|
||||
void
|
||||
KPPPInterface::SetDialOnDemand(bool dialOnDemand = true)
|
||||
KPPPInterface::SetConnectOnDemand(bool connectOnDemand = true)
|
||||
{
|
||||
// All protocols must check if DialOnDemand was enabled/disabled after this
|
||||
// All protocols must check if ConnectOnDemand was enabled/disabled after this
|
||||
// interface went down. This is the only situation where a change is relevant.
|
||||
|
||||
TRACE("KPPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false");
|
||||
TRACE("KPPPInterface: SetConnectOnDemand(%s)\n", connectOnDemand ? "true" : "false");
|
||||
|
||||
// Only clients support DialOnDemand.
|
||||
// Only clients support ConnectOnDemand.
|
||||
if(Mode() != PPP_CLIENT_MODE) {
|
||||
TRACE("KPPPInterface::SetDialOnDemand(): Wrong mode!\n");
|
||||
fDialOnDemand = false;
|
||||
TRACE("KPPPInterface::SetConnectOnDemand(): Wrong mode!\n");
|
||||
fConnectOnDemand = false;
|
||||
return;
|
||||
} else if(DoesDialOnDemand() == dialOnDemand)
|
||||
} else if(DoesConnectOnDemand() == connectOnDemand)
|
||||
return;
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
|
||||
fDialOnDemand = dialOnDemand;
|
||||
fConnectOnDemand = connectOnDemand;
|
||||
|
||||
// Do not allow changes when we are disconnected (only main interfaces).
|
||||
// This would make no sense because
|
||||
@ -883,7 +883,7 @@ KPPPInterface::SetDialOnDemand(bool dialOnDemand = true)
|
||||
// could not establish a connection (the user cannot access hidden interfaces)
|
||||
// - disabling: the interface disappears as seen from the user, so we delete it
|
||||
if(!Parent() && State() == PPP_INITIAL_STATE && Phase() == PPP_DOWN_PHASE) {
|
||||
if(!dialOnDemand)
|
||||
if(!connectOnDemand)
|
||||
Delete();
|
||||
// as long as the protocols were not configured we can just delete us
|
||||
|
||||
@ -891,10 +891,10 @@ KPPPInterface::SetDialOnDemand(bool dialOnDemand = true)
|
||||
}
|
||||
|
||||
// check if we need to set/unset flags
|
||||
if(dialOnDemand) {
|
||||
if(connectOnDemand) {
|
||||
if(Ifnet())
|
||||
Ifnet()->if_flags |= IFF_UP;
|
||||
} else if(!dialOnDemand && Phase() < PPP_ESTABLISHED_PHASE) {
|
||||
} else if(!connectOnDemand && Phase() < PPP_ESTABLISHED_PHASE) {
|
||||
if(Ifnet())
|
||||
Ifnet()->if_flags &= ~IFF_UP;
|
||||
}
|
||||
@ -947,9 +947,9 @@ KPPPInterface::Up()
|
||||
|
||||
ReportManager().EnableReports(PPP_CONNECTION_REPORT, me, PPP_WAIT_FOR_REPLY);
|
||||
|
||||
// fUpThread/fRedialThread tells the state machine to go up (using a new thread
|
||||
// fUpThread/fReconnectThread tells the state machine to go up (using a new thread
|
||||
// because we might not receive report messages otherwise)
|
||||
if(me == fUpThread || me == fRedialThread) {
|
||||
if(me == fUpThread || me == fReconnectThread) {
|
||||
if(fOpenEventThread != -1) {
|
||||
int32 tmp;
|
||||
wait_for_thread(fOpenEventThread, &tmp);
|
||||
@ -960,13 +960,13 @@ KPPPInterface::Up()
|
||||
}
|
||||
fLock.Unlock();
|
||||
|
||||
if(me == fRedialThread && me != fUpThread)
|
||||
if(me == fReconnectThread && me != fUpThread)
|
||||
return true;
|
||||
// the redial thread is doing a DialRetry in this case (fUpThread
|
||||
// the reconnect thread is doing a ConnectRetry in this case (fUpThread
|
||||
// is waiting for new reports)
|
||||
|
||||
while(true) {
|
||||
// A wrong code usually happens when the redial thread gets notified
|
||||
// A wrong code usually happens when the reconnect thread gets notified
|
||||
// of a Down() request. In that case a report will follow soon, so
|
||||
// this can be ignored.
|
||||
if(receive_data(&sender, &report, sizeof(report)) != PPP_REPORT_CODE)
|
||||
@ -977,7 +977,7 @@ KPPPInterface::Up()
|
||||
|
||||
if(IsUp()) {
|
||||
if(me == fUpThread) {
|
||||
fDialRetry = 0;
|
||||
fConnectRetry = 0;
|
||||
fUpThread = -1;
|
||||
}
|
||||
|
||||
@ -987,7 +987,7 @@ KPPPInterface::Up()
|
||||
|
||||
if(report.type == PPP_DESTRUCTION_REPORT) {
|
||||
if(me == fUpThread) {
|
||||
fDialRetry = 0;
|
||||
fConnectRetry = 0;
|
||||
fUpThread = -1;
|
||||
}
|
||||
|
||||
@ -1003,10 +1003,10 @@ KPPPInterface::Up()
|
||||
continue;
|
||||
} else if(report.code == PPP_REPORT_UP_SUCCESSFUL) {
|
||||
if(me == fUpThread) {
|
||||
fDialRetry = 0;
|
||||
fConnectRetry = 0;
|
||||
fUpThread = -1;
|
||||
send_data_with_timeout(fRedialThread, 0, NULL, 0, 200);
|
||||
// notify redial thread that we do not need it anymore
|
||||
send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
|
||||
// notify reconnect thread that we do not need it anymore
|
||||
}
|
||||
|
||||
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||
@ -1016,7 +1016,7 @@ KPPPInterface::Up()
|
||||
|| report.code == PPP_REPORT_LOCAL_AUTHENTICATION_FAILED
|
||||
|| report.code == PPP_REPORT_PEER_AUTHENTICATION_FAILED) {
|
||||
if(me == fUpThread) {
|
||||
fDialRetry = 0;
|
||||
fConnectRetry = 0;
|
||||
fUpThread = -1;
|
||||
|
||||
if(report.code != PPP_REPORT_DOWN_SUCCESSFUL)
|
||||
@ -1030,7 +1030,7 @@ KPPPInterface::Up()
|
||||
if(me != fUpThread) {
|
||||
// I am an observer
|
||||
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
||||
if(fDialRetry >= fDialRetriesLimit || fUpThread == -1) {
|
||||
if(fConnectRetry >= fConnectRetriesLimit || fUpThread == -1) {
|
||||
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||
return false;
|
||||
} else {
|
||||
@ -1038,7 +1038,7 @@ KPPPInterface::Up()
|
||||
continue;
|
||||
}
|
||||
} else if(report.code == PPP_REPORT_CONNECTION_LOST) {
|
||||
if(DoesAutoRedial()) {
|
||||
if(DoesAutoReconnect()) {
|
||||
PPP_REPLY(sender, B_OK);
|
||||
continue;
|
||||
} else {
|
||||
@ -1049,10 +1049,10 @@ KPPPInterface::Up()
|
||||
} else {
|
||||
// I am the thread for the real task
|
||||
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
||||
if(fDialRetry >= fDialRetriesLimit) {
|
||||
if(fConnectRetry >= fConnectRetriesLimit) {
|
||||
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n");
|
||||
|
||||
fDialRetry = 0;
|
||||
fConnectRetry = 0;
|
||||
fUpThread = -1;
|
||||
Delete();
|
||||
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||
@ -1061,22 +1061,22 @@ KPPPInterface::Up()
|
||||
} else {
|
||||
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n");
|
||||
|
||||
++fDialRetry;
|
||||
++fConnectRetry;
|
||||
PPP_REPLY(sender, B_OK);
|
||||
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: replied\n");
|
||||
Redial(DialRetryDelay());
|
||||
Reconnect(ConnectRetryDelay());
|
||||
continue;
|
||||
}
|
||||
} else if(report.code == PPP_REPORT_CONNECTION_LOST) {
|
||||
// the state machine knows that we are going up and leaves
|
||||
// the redial task to us
|
||||
if(DoesAutoRedial() && fDialRetry < fDialRetriesLimit) {
|
||||
++fDialRetry;
|
||||
// the reconnect task to us
|
||||
if(DoesAutoReconnect() && fConnectRetry < fConnectRetriesLimit) {
|
||||
++fConnectRetry;
|
||||
PPP_REPLY(sender, B_OK);
|
||||
Redial(DialRetryDelay());
|
||||
Reconnect(ConnectRetryDelay());
|
||||
continue;
|
||||
} else {
|
||||
fDialRetry = 0;
|
||||
fConnectRetry = 0;
|
||||
fUpThread = -1;
|
||||
Delete();
|
||||
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||
@ -1111,8 +1111,8 @@ KPPPInterface::Down()
|
||||
else if(State() == PPP_INITIAL_STATE && Phase() == PPP_DOWN_PHASE)
|
||||
return true;
|
||||
|
||||
send_data_with_timeout(fRedialThread, 0, NULL, 0, 200);
|
||||
// the redial thread should be notified that the user wants to disconnect
|
||||
send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
|
||||
// the reconnect thread should be notified that the user wants to disconnect
|
||||
|
||||
// this locked section guarantees that there are no state changes before we
|
||||
// enable the connection reports
|
||||
@ -1286,7 +1286,7 @@ KPPPInterface::IsAllowedToSend() const
|
||||
|
||||
/*! \brief Sends a packet to the device.
|
||||
|
||||
This brings the interface up if dial-on-demand is enabled and we are not
|
||||
This brings the interface up if connect-on-demand is enabled and we are not
|
||||
connected. \n
|
||||
PFC encoding is handled here.
|
||||
|
||||
@ -1313,8 +1313,8 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// go up if DialOnDemand enabled and we are down
|
||||
if(protocolNumber != PPP_LCP_PROTOCOL && DoesDialOnDemand()
|
||||
// go up if ConnectOnDemand enabled and we are down
|
||||
if(protocolNumber != PPP_LCP_PROTOCOL && DoesConnectOnDemand()
|
||||
&& (Phase() == PPP_DOWN_PHASE
|
||||
|| Phase() == PPP_ESTABLISHMENT_PHASE)
|
||||
&& !Up()) {
|
||||
@ -1549,7 +1549,7 @@ KPPPInterface::RegisterInterface()
|
||||
if(!fIfnet)
|
||||
return false;
|
||||
|
||||
if(DoesDialOnDemand())
|
||||
if(DoesConnectOnDemand())
|
||||
fIfnet->if_flags |= IFF_UP;
|
||||
|
||||
CalculateInterfaceMTU();
|
||||
@ -1714,38 +1714,38 @@ KPPPInterface::CalculateBaudRate()
|
||||
}
|
||||
|
||||
|
||||
//! Redials. Waits a given delay (in miliseconds) before redialing.
|
||||
//! Reconnects. Waits a given delay (in miliseconds) before reconnecting.
|
||||
void
|
||||
KPPPInterface::Redial(uint32 delay)
|
||||
KPPPInterface::Reconnect(uint32 delay)
|
||||
{
|
||||
TRACE("KPPPInterface: Redial(%ld)\n", delay);
|
||||
TRACE("KPPPInterface: Reconnect(%ld)\n", delay);
|
||||
|
||||
if(fRedialThread != -1)
|
||||
if(fReconnectThread != -1)
|
||||
return;
|
||||
|
||||
// start a new thread that calls our Up() method
|
||||
redial_info info;
|
||||
reconnect_info info;
|
||||
info.interface = this;
|
||||
info.thread = &fRedialThread;
|
||||
info.thread = &fReconnectThread;
|
||||
info.delay = delay;
|
||||
|
||||
fRedialThread = spawn_kernel_thread(redial_thread, "KPPPInterface: redial_thread",
|
||||
fReconnectThread = spawn_kernel_thread(reconnect_thread, "KPPPInterface: reconnect_thread",
|
||||
B_NORMAL_PRIORITY, NULL);
|
||||
|
||||
resume_thread(fRedialThread);
|
||||
resume_thread(fReconnectThread);
|
||||
|
||||
send_data(fRedialThread, 0, &info, sizeof(redial_info));
|
||||
send_data(fReconnectThread, 0, &info, sizeof(reconnect_info));
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
redial_thread(void *data)
|
||||
reconnect_thread(void *data)
|
||||
{
|
||||
redial_info info;
|
||||
reconnect_info info;
|
||||
thread_id sender;
|
||||
int32 code;
|
||||
|
||||
receive_data(&sender, &info, sizeof(redial_info));
|
||||
receive_data(&sender, &info, sizeof(reconnect_info));
|
||||
|
||||
// we try to receive data instead of snooze, so we can quit on destruction
|
||||
if(receive_data_with_timeout(&sender, &code, NULL, 0, info.delay) == B_OK) {
|
||||
|
@ -671,7 +671,7 @@ KPPPStateMachine::DownEvent()
|
||||
|
||||
case PPP_STOPPED_STATE:
|
||||
// The RFC says we should reconnect, but our implementation
|
||||
// will only do this if auto-redial is enabled (only clients).
|
||||
// will only do this if auto-reconnect is enabled (only clients).
|
||||
NewState(PPP_STARTING_STATE);
|
||||
break;
|
||||
|
||||
@ -692,11 +692,11 @@ KPPPStateMachine::DownEvent()
|
||||
|
||||
DownProtocols();
|
||||
|
||||
// maybe we need to redial
|
||||
// maybe we need to reconnect
|
||||
if(State() == PPP_STARTING_STATE) {
|
||||
bool needsRedial = false;
|
||||
bool needsReconnect = false;
|
||||
|
||||
// we do not try to redial if authentication failed
|
||||
// we do not try to reconnect if authentication failed
|
||||
if(fLocalAuthenticationStatus == PPP_AUTHENTICATION_FAILED
|
||||
|| fLocalAuthenticationStatus == PPP_AUTHENTICATING)
|
||||
Interface().Report(PPP_CONNECTION_REPORT,
|
||||
@ -708,10 +708,10 @@ KPPPStateMachine::DownEvent()
|
||||
PPP_REPORT_PEER_AUTHENTICATION_FAILED, &fInterface.fID,
|
||||
sizeof(ppp_interface_id));
|
||||
else {
|
||||
// if we are going up and lost connection the redial attempt becomes
|
||||
// a dial retry which is managed by the main thread in Interface::Up()
|
||||
// if we are going up and lost connection the reconnect attempt becomes
|
||||
// a connect retry which is managed by the main thread in Interface::Up()
|
||||
if(Interface().fUpThread == -1)
|
||||
needsRedial = true;
|
||||
needsReconnect = true;
|
||||
|
||||
// test if UpFailedEvent() was not called
|
||||
if(oldPhase != PPP_DOWN_PHASE)
|
||||
@ -724,9 +724,9 @@ KPPPStateMachine::DownEvent()
|
||||
|
||||
NewState(PPP_INITIAL_STATE);
|
||||
|
||||
if(Interface().DoesAutoRedial()) {
|
||||
if(needsRedial)
|
||||
Interface().Redial(Interface().RedialDelay());
|
||||
if(Interface().DoesAutoReconnect()) {
|
||||
if(needsReconnect)
|
||||
Interface().Reconnect(Interface().ReconnectDelay());
|
||||
} else
|
||||
Interface().Delete();
|
||||
} else {
|
||||
|
@ -1,3 +1,3 @@
|
||||
- add missing settings support (DialRetryDelay, etc.)
|
||||
- add missing settings support (ConnectRetryDelay, etc.)
|
||||
- finish support for server mode (profiles, etc.)
|
||||
- add callback support
|
||||
|
@ -82,12 +82,12 @@ class KPPPInterface : public KPPPLayer {
|
||||
struct ifnet *Ifnet() const
|
||||
{ return fIfnet; }
|
||||
|
||||
//! Delay in miliseconds between a dial retry.
|
||||
uint32 DialRetryDelay() const
|
||||
{ return fDialRetryDelay; }
|
||||
//! Delay in miliseconds to wait until redialing.
|
||||
uint32 RedialDelay() const
|
||||
{ return fRedialDelay; }
|
||||
//! Delay in miliseconds between a connect retry.
|
||||
uint32 ConnectRetryDelay() const
|
||||
{ return fConnectRetryDelay; }
|
||||
//! Delay in miliseconds to wait until reconnecting.
|
||||
uint32 ReconnectDelay() const
|
||||
{ return fReconnectDelay; }
|
||||
|
||||
//! Used for reporting that a packet was send/received (updates idle time).
|
||||
void UpdateIdleSince()
|
||||
@ -143,15 +143,15 @@ class KPPPInterface : public KPPPLayer {
|
||||
bool IsMultilink() const
|
||||
{ return fIsMultilink; }
|
||||
|
||||
void SetAutoRedial(bool autoRedial = true);
|
||||
//! Returns whether this interface redials automatically.
|
||||
bool DoesAutoRedial() const
|
||||
{ return fAutoRedial; }
|
||||
void SetAutoReconnect(bool autoReconnect = true);
|
||||
//! Returns whether this interface reconnects automatically.
|
||||
bool DoesAutoReconnect() const
|
||||
{ return fAutoReconnect; }
|
||||
|
||||
void SetDialOnDemand(bool dialOnDemand = true);
|
||||
//! Returns whether dial-on-demand (auto-dial) is enabled.
|
||||
bool DoesDialOnDemand() const
|
||||
{ return fDialOnDemand; }
|
||||
void SetConnectOnDemand(bool connectOnDemand = true);
|
||||
//! Returns whether connect-on-demand (auto-connect) is enabled.
|
||||
bool DoesConnectOnDemand() const
|
||||
{ return fConnectOnDemand; }
|
||||
|
||||
//! Clients are in \c PPP_CLIENT_MODE and servers are in \c PPP_SERVER_MODE.
|
||||
ppp_mode Mode() const
|
||||
@ -241,7 +241,7 @@ class KPPPInterface : public KPPPLayer {
|
||||
void CallCloseEvent()
|
||||
{ StateMachine().CloseEvent(); }
|
||||
|
||||
void Redial(uint32 delay);
|
||||
void Reconnect(uint32 delay);
|
||||
|
||||
// multilink methods
|
||||
//! Set the parent of this interface.
|
||||
@ -256,9 +256,9 @@ class KPPPInterface : public KPPPLayer {
|
||||
|
||||
thread_id fUpThread, fOpenEventThread, fCloseEventThread;
|
||||
|
||||
thread_id fRedialThread;
|
||||
uint32 fDialRetry, fDialRetriesLimit;
|
||||
uint32 fDialRetryDelay, fRedialDelay;
|
||||
thread_id fReconnectThread;
|
||||
uint32 fConnectRetry, fConnectRetriesLimit;
|
||||
uint32 fConnectRetryDelay, fReconnectDelay;
|
||||
|
||||
ppp_interface_module_info *fManager;
|
||||
|
||||
@ -270,7 +270,7 @@ class KPPPInterface : public KPPPLayer {
|
||||
TemplateList<KPPPInterface*> fChildren;
|
||||
bool fIsMultilink;
|
||||
|
||||
bool fAutoRedial, fDialOnDemand;
|
||||
bool fAutoReconnect, fConnectOnDemand;
|
||||
|
||||
ppp_mode fMode;
|
||||
ppp_pfc_state fLocalPFCState, fPeerPFCState;
|
||||
|
@ -86,7 +86,7 @@ class KPPPProtocol : public KPPPLayer {
|
||||
/*! \brief Bring this protocol down.
|
||||
|
||||
You must call DownStarted() from here. \n
|
||||
If DialOnDemand is supported check for DialOnDemand settings change.
|
||||
If ConnectOnDemand is supported check for ConnectOnDemand settings change.
|
||||
*/
|
||||
virtual bool Down() = 0;
|
||||
//! Is this protocol up?
|
||||
|
@ -47,8 +47,8 @@ enum ppp_control_ops {
|
||||
// KPPPInterface
|
||||
PPPC_GET_INTERFACE_INFO = PPP_INTERFACE_OPS_START,
|
||||
PPPC_SET_MRU,
|
||||
PPPC_SET_DIAL_ON_DEMAND,
|
||||
PPPC_SET_AUTO_REDIAL,
|
||||
PPPC_SET_CONNECT_ON_DEMAND,
|
||||
PPPC_SET_AUTO_RECONNECT,
|
||||
PPPC_HAS_INTERFACE_SETTINGS,
|
||||
PPPC_SET_PROFILE,
|
||||
|
||||
@ -151,11 +151,11 @@ typedef struct ppp_interface_info {
|
||||
uint32 protocolsCount, optionHandlersCount, LCPExtensionsCount, childrenCount;
|
||||
uint32 MRU, interfaceMTU;
|
||||
|
||||
uint32 dialRetry, dialRetriesLimit;
|
||||
uint32 dialRetryDelay, redialDelay;
|
||||
uint32 connectRetry, connectRetriesLimit;
|
||||
uint32 connectRetryDelay, reconnectDelay;
|
||||
uint32 idleSince, disconnectAfterIdleSince;
|
||||
|
||||
bool doesDialOnDemand, doesAutoRedial, hasDevice, isMultilink, hasParent;
|
||||
bool doesConnectOnDemand, doesAutoReconnect, hasDevice, isMultilink, hasParent;
|
||||
} ppp_interface_info;
|
||||
/*! \brief You \e must use this encapsulator instead of \c ppp_interface_info!
|
||||
|
||||
|
@ -15,15 +15,14 @@ typedef uint32 ppp_interface_id;
|
||||
|
||||
|
||||
// settings keys
|
||||
#define PPP_ASK_BEFORE_DIALING_KEY "AskBeforeDialing"
|
||||
// userland ppp_server and preflet handle this key
|
||||
#define PPP_ASK_BEFORE_CONNECTING_KEY "AskBeforeConnecting"
|
||||
// userland ppp_up and preflet handle this key
|
||||
#define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY "DisonnectAfterIdleSince"
|
||||
#define PPP_MODE_KEY "Mode"
|
||||
#define PPP_DIAL_RETRIES_LIMIT_KEY "DialRetriesLimit"
|
||||
#define PPP_DIAL_RETRY_DELAY_KEY "DialRetryDelay"
|
||||
#define PPP_DIAL_ON_DEMAND_KEY "DialOnDemand"
|
||||
#define PPP_AUTO_REDIAL_KEY "AutoRedial"
|
||||
#define PPP_REDIAL_DELAY_KEY "RedialDelay"
|
||||
#define PPP_CONNECT_RETRIES_LIMIT_KEY "ConnectRetriesLimit"
|
||||
#define PPP_CONNECT_RETRY_DELAY_KEY "ConnectRetryDelay"
|
||||
#define PPP_AUTO_RECONNECT_KEY "AutoReconnect"
|
||||
#define PPP_RECONNECT_DELAY_KEY "ReconnectDelay"
|
||||
#define PPP_LOAD_MODULE_KEY "LoadModule"
|
||||
#define PPP_PROTOCOL_KEY "Protocol"
|
||||
#define PPP_DEVICE_KEY "Device"
|
||||
|
@ -13,13 +13,12 @@
|
||||
|
||||
|
||||
static const char *sSkipInterfaceParameters[] = {
|
||||
PPP_ASK_BEFORE_DIALING_KEY,
|
||||
PPP_ASK_BEFORE_CONNECTING_KEY,
|
||||
PPP_DISONNECT_AFTER_IDLE_SINCE_KEY,
|
||||
PPP_DIAL_RETRIES_LIMIT_KEY,
|
||||
PPP_DIAL_RETRY_DELAY_KEY,
|
||||
PPP_DIAL_ON_DEMAND_KEY,
|
||||
PPP_AUTO_REDIAL_KEY,
|
||||
PPP_REDIAL_DELAY_KEY,
|
||||
PPP_CONNECT_RETRIES_LIMIT_KEY,
|
||||
PPP_CONNECT_RETRY_DELAY_KEY,
|
||||
PPP_AUTO_RECONNECT_KEY,
|
||||
PPP_RECONNECT_DELAY_KEY,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user