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:
Waldemar Kornewald 2004-12-20 10:36:43 +00:00
parent beabca50a7
commit 0cbb739d3b
11 changed files with 137 additions and 139 deletions

View File

@ -183,7 +183,7 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
++entry->accessing; ++entry->accessing;
locker.UnlockNow(); locker.UnlockNow();
if(!entry->interface->DoesDialOnDemand() if(!entry->interface->DoesConnectOnDemand()
&& ifp->if_flags & (IFF_UP | IFF_RUNNING) != (IFF_UP | IFF_RUNNING)) { && ifp->if_flags & (IFF_UP | IFF_RUNNING) != (IFF_UP | IFF_RUNNING)) {
m_freem(buf); m_freem(buf);
--entry->accessing; --entry->accessing;
@ -232,7 +232,7 @@ PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data)
switch(cmd) { switch(cmd) {
case SIOCSIFFLAGS: case SIOCSIFFLAGS:
if(((ifreq*)data)->ifr_flags & IFF_DOWN) { if(((ifreq*)data)->ifr_flags & IFF_DOWN) {
if(entry->interface->DoesDialOnDemand() if(entry->interface->DoesConnectOnDemand()
&& entry->interface->Phase() == PPP_DOWN_PHASE) && entry->interface->Phase() == PPP_DOWN_PHASE)
DeleteInterface(entry->interface->ID()); DeleteInterface(entry->interface->ID());
else else

View File

@ -424,7 +424,7 @@ IPCP::UpdateAddresses()
{ {
RemoveRoutes(); RemoveRoutes();
if(State() != PPP_OPENED_STATE && !Interface().DoesDialOnDemand()) if(State() != PPP_OPENED_STATE && !Interface().DoesConnectOnDemand())
return; return;
struct in_aliasreq inreq; struct in_aliasreq inreq;

View File

@ -22,7 +22,7 @@ class PPPoEDevice;
#define PPPoE_TIMEOUT 3000000 #define PPPoE_TIMEOUT 3000000
// 3 seconds // 3 seconds
#define PPPoE_MAX_ATTEMPTS 2 #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_VERSION 0x1
#define PPPoE_TYPE 0x1 #define PPPoE_TYPE 0x1

View File

@ -52,17 +52,17 @@
// TODO: // TODO:
// - implement timers with support for setting next event instead of receiving timer // - implement timers with support for setting next event instead of receiving timer
// events periodically // events periodically
// - add missing settings support (DialRetryDelay, etc.) // - add missing settings support (ConnectRetryDelay, etc.)
//! Private structure needed for redialing. //! Private structure needed for reconnecting.
typedef struct redial_info { typedef struct reconnect_info {
KPPPInterface *interface; KPPPInterface *interface;
thread_id *thread; thread_id *thread;
uint32 delay; uint32 delay;
} redial_info; } reconnect_info;
status_t redial_thread(void *data); status_t reconnect_thread(void *data);
// other functions // other functions
status_t interface_deleter_thread(void *data); status_t interface_deleter_thread(void *data);
@ -91,9 +91,9 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
fUpThread(-1), fUpThread(-1),
fOpenEventThread(-1), fOpenEventThread(-1),
fCloseEventThread(-1), fCloseEventThread(-1),
fRedialThread(-1), fReconnectThread(-1),
fDialRetry(0), fConnectRetry(0),
fDialRetriesLimit(0), fConnectRetriesLimit(0),
fManager(NULL), fManager(NULL),
fIdleSince(0), fIdleSince(0),
fMRU(1500), fMRU(1500),
@ -101,8 +101,8 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
fHeaderLength(2), fHeaderLength(2),
fParent(NULL), fParent(NULL),
fIsMultilink(false), fIsMultilink(false),
fAutoRedial(false), fAutoReconnect(false),
fDialOnDemand(false), fConnectOnDemand(false),
fMode(PPP_CLIENT_MODE), fMode(PPP_CLIENT_MODE),
fLocalPFCState(PPP_PFC_DISABLED), fLocalPFCState(PPP_PFC_DISABLED),
fPeerPFCState(PPP_PFC_DISABLED), fPeerPFCState(PPP_PFC_DISABLED),
@ -171,11 +171,11 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
delete pfcHandler; delete pfcHandler;
} }
// set up dial delays // set up connect delays
fDialRetryDelay = 3000; fConnectRetryDelay = 3000;
// 3s delay between each new attempt to redial // 3s delay between each new attempt to reconnect
fRedialDelay = 1000; fReconnectDelay = 1000;
// 1s delay between lost connection and redial // 1s delay between lost connection and reconnect
if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK) if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK)
ERROR("KPPPInterface: Manager module not found!\n"); ERROR("KPPPInterface: Manager module not found!\n");
@ -214,12 +214,12 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
fMode = PPP_CLIENT_MODE; fMode = PPP_CLIENT_MODE;
// we are a client by default // we are a client by default
SetAutoRedial( SetAutoReconnect(
get_boolean_value( get_boolean_value(
get_settings_value(PPP_AUTO_REDIAL_KEY, fSettings), get_settings_value(PPP_AUTO_RECONNECT_KEY, fSettings),
false) false)
); );
// auto redial is disabled by default // auto reconnect is disabled by default
// load all protocols and the device // load all protocols and the device
if(!LoadModules(fSettings, 0, fSettings->parameter_count)) { if(!LoadModules(fSettings, 0, fSettings->parameter_count)) {
@ -261,9 +261,9 @@ KPPPInterface::~KPPPInterface()
// tell all listeners that we are being destroyed // tell all listeners that we are being destroyed
int32 tmp; 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) // 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(fOpenEventThread, &tmp);
wait_for_thread(fCloseEventThread, &tmp); wait_for_thread(fCloseEventThread, &tmp);
@ -418,14 +418,14 @@ KPPPInterface::Control(uint32 op, void *data, size_t length)
info->childrenCount = CountChildren(); info->childrenCount = CountChildren();
info->MRU = MRU(); info->MRU = MRU();
info->interfaceMTU = InterfaceMTU(); info->interfaceMTU = InterfaceMTU();
info->dialRetry = fDialRetry; info->connectRetry = fConnectRetry;
info->dialRetriesLimit = fDialRetriesLimit; info->connectRetriesLimit = fConnectRetriesLimit;
info->dialRetryDelay = DialRetryDelay(); info->connectRetryDelay = ConnectRetryDelay();
info->redialDelay = RedialDelay(); info->reconnectDelay = ReconnectDelay();
info->idleSince = IdleSince(); info->idleSince = IdleSince();
info->disconnectAfterIdleSince = DisconnectAfterIdleSince(); info->disconnectAfterIdleSince = DisconnectAfterIdleSince();
info->doesDialOnDemand = DoesDialOnDemand(); info->doesConnectOnDemand = DoesConnectOnDemand();
info->doesAutoRedial = DoesAutoRedial(); info->doesAutoReconnect = DoesAutoReconnect();
info->hasDevice = Device(); info->hasDevice = Device();
info->isMultilink = IsMultilink(); info->isMultilink = IsMultilink();
info->hasParent = Parent(); info->hasParent = Parent();
@ -438,18 +438,18 @@ KPPPInterface::Control(uint32 op, void *data, size_t length)
SetMRU(*((uint32*)data)); SetMRU(*((uint32*)data));
break; break;
case PPPC_SET_DIAL_ON_DEMAND: case PPPC_SET_CONNECT_ON_DEMAND:
if(length < sizeof(uint32) || !data) if(length < sizeof(uint32) || !data)
return B_ERROR; return B_ERROR;
SetDialOnDemand(*((uint32*)data)); SetConnectOnDemand(*((uint32*)data));
break; break;
case PPPC_SET_AUTO_REDIAL: case PPPC_SET_AUTO_RECONNECT:
if(length < sizeof(uint32) || !data) if(length < sizeof(uint32) || !data)
return B_ERROR; return B_ERROR;
SetAutoRedial(*((uint32*)data)); SetAutoReconnect(*((uint32*)data));
break; break;
case PPPC_HAS_INTERFACE_SETTINGS: 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 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) if(Mode() != PPP_CLIENT_MODE)
return; return;
LockerHelper locker(fLock); LockerHelper locker(fLock);
fAutoRedial = autoRedial; fAutoReconnect = autoReconnect;
} }
//! Enables or disables the dial-on-demand feature. //! Enables or disables the connect-on-demand feature.
void 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. // 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) { if(Mode() != PPP_CLIENT_MODE) {
TRACE("KPPPInterface::SetDialOnDemand(): Wrong mode!\n"); TRACE("KPPPInterface::SetConnectOnDemand(): Wrong mode!\n");
fDialOnDemand = false; fConnectOnDemand = false;
return; return;
} else if(DoesDialOnDemand() == dialOnDemand) } else if(DoesConnectOnDemand() == connectOnDemand)
return; return;
LockerHelper locker(fLock); LockerHelper locker(fLock);
fDialOnDemand = dialOnDemand; fConnectOnDemand = connectOnDemand;
// Do not allow changes when we are disconnected (only main interfaces). // Do not allow changes when we are disconnected (only main interfaces).
// This would make no sense because // 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) // could not establish a connection (the user cannot access hidden interfaces)
// - disabling: the interface disappears as seen from the user, so we delete it // - disabling: the interface disappears as seen from the user, so we delete it
if(!Parent() && State() == PPP_INITIAL_STATE && Phase() == PPP_DOWN_PHASE) { if(!Parent() && State() == PPP_INITIAL_STATE && Phase() == PPP_DOWN_PHASE) {
if(!dialOnDemand) if(!connectOnDemand)
Delete(); Delete();
// as long as the protocols were not configured we can just delete us // 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 // check if we need to set/unset flags
if(dialOnDemand) { if(connectOnDemand) {
if(Ifnet()) if(Ifnet())
Ifnet()->if_flags |= IFF_UP; Ifnet()->if_flags |= IFF_UP;
} else if(!dialOnDemand && Phase() < PPP_ESTABLISHED_PHASE) { } else if(!connectOnDemand && Phase() < PPP_ESTABLISHED_PHASE) {
if(Ifnet()) if(Ifnet())
Ifnet()->if_flags &= ~IFF_UP; Ifnet()->if_flags &= ~IFF_UP;
} }
@ -947,9 +947,9 @@ KPPPInterface::Up()
ReportManager().EnableReports(PPP_CONNECTION_REPORT, me, PPP_WAIT_FOR_REPLY); 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) // because we might not receive report messages otherwise)
if(me == fUpThread || me == fRedialThread) { if(me == fUpThread || me == fReconnectThread) {
if(fOpenEventThread != -1) { if(fOpenEventThread != -1) {
int32 tmp; int32 tmp;
wait_for_thread(fOpenEventThread, &tmp); wait_for_thread(fOpenEventThread, &tmp);
@ -960,13 +960,13 @@ KPPPInterface::Up()
} }
fLock.Unlock(); fLock.Unlock();
if(me == fRedialThread && me != fUpThread) if(me == fReconnectThread && me != fUpThread)
return true; 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) // is waiting for new reports)
while(true) { 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 // of a Down() request. In that case a report will follow soon, so
// this can be ignored. // this can be ignored.
if(receive_data(&sender, &report, sizeof(report)) != PPP_REPORT_CODE) if(receive_data(&sender, &report, sizeof(report)) != PPP_REPORT_CODE)
@ -977,7 +977,7 @@ KPPPInterface::Up()
if(IsUp()) { if(IsUp()) {
if(me == fUpThread) { if(me == fUpThread) {
fDialRetry = 0; fConnectRetry = 0;
fUpThread = -1; fUpThread = -1;
} }
@ -987,7 +987,7 @@ KPPPInterface::Up()
if(report.type == PPP_DESTRUCTION_REPORT) { if(report.type == PPP_DESTRUCTION_REPORT) {
if(me == fUpThread) { if(me == fUpThread) {
fDialRetry = 0; fConnectRetry = 0;
fUpThread = -1; fUpThread = -1;
} }
@ -1003,10 +1003,10 @@ KPPPInterface::Up()
continue; continue;
} else if(report.code == PPP_REPORT_UP_SUCCESSFUL) { } else if(report.code == PPP_REPORT_UP_SUCCESSFUL) {
if(me == fUpThread) { if(me == fUpThread) {
fDialRetry = 0; fConnectRetry = 0;
fUpThread = -1; fUpThread = -1;
send_data_with_timeout(fRedialThread, 0, NULL, 0, 200); send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
// notify redial thread that we do not need it anymore // notify reconnect thread that we do not need it anymore
} }
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
@ -1016,7 +1016,7 @@ KPPPInterface::Up()
|| report.code == PPP_REPORT_LOCAL_AUTHENTICATION_FAILED || report.code == PPP_REPORT_LOCAL_AUTHENTICATION_FAILED
|| report.code == PPP_REPORT_PEER_AUTHENTICATION_FAILED) { || report.code == PPP_REPORT_PEER_AUTHENTICATION_FAILED) {
if(me == fUpThread) { if(me == fUpThread) {
fDialRetry = 0; fConnectRetry = 0;
fUpThread = -1; fUpThread = -1;
if(report.code != PPP_REPORT_DOWN_SUCCESSFUL) if(report.code != PPP_REPORT_DOWN_SUCCESSFUL)
@ -1030,7 +1030,7 @@ KPPPInterface::Up()
if(me != fUpThread) { if(me != fUpThread) {
// I am an observer // I am an observer
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) { 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); PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
return false; return false;
} else { } else {
@ -1038,7 +1038,7 @@ KPPPInterface::Up()
continue; continue;
} }
} else if(report.code == PPP_REPORT_CONNECTION_LOST) { } else if(report.code == PPP_REPORT_CONNECTION_LOST) {
if(DoesAutoRedial()) { if(DoesAutoReconnect()) {
PPP_REPLY(sender, B_OK); PPP_REPLY(sender, B_OK);
continue; continue;
} else { } else {
@ -1049,10 +1049,10 @@ KPPPInterface::Up()
} else { } else {
// I am the thread for the real task // I am the thread for the real task
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) { if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
if(fDialRetry >= fDialRetriesLimit) { if(fConnectRetry >= fConnectRetriesLimit) {
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n"); TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n");
fDialRetry = 0; fConnectRetry = 0;
fUpThread = -1; fUpThread = -1;
Delete(); Delete();
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
@ -1061,22 +1061,22 @@ KPPPInterface::Up()
} else { } else {
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n"); TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n");
++fDialRetry; ++fConnectRetry;
PPP_REPLY(sender, B_OK); PPP_REPLY(sender, B_OK);
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: replied\n"); TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: replied\n");
Redial(DialRetryDelay()); Reconnect(ConnectRetryDelay());
continue; continue;
} }
} else if(report.code == PPP_REPORT_CONNECTION_LOST) { } else if(report.code == PPP_REPORT_CONNECTION_LOST) {
// the state machine knows that we are going up and leaves // the state machine knows that we are going up and leaves
// the redial task to us // the reconnect task to us
if(DoesAutoRedial() && fDialRetry < fDialRetriesLimit) { if(DoesAutoReconnect() && fConnectRetry < fConnectRetriesLimit) {
++fDialRetry; ++fConnectRetry;
PPP_REPLY(sender, B_OK); PPP_REPLY(sender, B_OK);
Redial(DialRetryDelay()); Reconnect(ConnectRetryDelay());
continue; continue;
} else { } else {
fDialRetry = 0; fConnectRetry = 0;
fUpThread = -1; fUpThread = -1;
Delete(); Delete();
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
@ -1111,8 +1111,8 @@ KPPPInterface::Down()
else if(State() == PPP_INITIAL_STATE && Phase() == PPP_DOWN_PHASE) else if(State() == PPP_INITIAL_STATE && Phase() == PPP_DOWN_PHASE)
return true; return true;
send_data_with_timeout(fRedialThread, 0, NULL, 0, 200); send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
// the redial thread should be notified that the user wants to disconnect // the reconnect thread should be notified that the user wants to disconnect
// this locked section guarantees that there are no state changes before we // this locked section guarantees that there are no state changes before we
// enable the connection reports // enable the connection reports
@ -1286,7 +1286,7 @@ KPPPInterface::IsAllowedToSend() const
/*! \brief Sends a packet to the device. /*! \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 connected. \n
PFC encoding is handled here. PFC encoding is handled here.
@ -1313,8 +1313,8 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
return B_ERROR; return B_ERROR;
} }
// go up if DialOnDemand enabled and we are down // go up if ConnectOnDemand enabled and we are down
if(protocolNumber != PPP_LCP_PROTOCOL && DoesDialOnDemand() if(protocolNumber != PPP_LCP_PROTOCOL && DoesConnectOnDemand()
&& (Phase() == PPP_DOWN_PHASE && (Phase() == PPP_DOWN_PHASE
|| Phase() == PPP_ESTABLISHMENT_PHASE) || Phase() == PPP_ESTABLISHMENT_PHASE)
&& !Up()) { && !Up()) {
@ -1549,7 +1549,7 @@ KPPPInterface::RegisterInterface()
if(!fIfnet) if(!fIfnet)
return false; return false;
if(DoesDialOnDemand()) if(DoesConnectOnDemand())
fIfnet->if_flags |= IFF_UP; fIfnet->if_flags |= IFF_UP;
CalculateInterfaceMTU(); 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 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; return;
// start a new thread that calls our Up() method // start a new thread that calls our Up() method
redial_info info; reconnect_info info;
info.interface = this; info.interface = this;
info.thread = &fRedialThread; info.thread = &fReconnectThread;
info.delay = delay; 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); 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 status_t
redial_thread(void *data) reconnect_thread(void *data)
{ {
redial_info info; reconnect_info info;
thread_id sender; thread_id sender;
int32 code; 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 // 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) { if(receive_data_with_timeout(&sender, &code, NULL, 0, info.delay) == B_OK) {

View File

@ -671,7 +671,7 @@ KPPPStateMachine::DownEvent()
case PPP_STOPPED_STATE: case PPP_STOPPED_STATE:
// The RFC says we should reconnect, but our implementation // 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); NewState(PPP_STARTING_STATE);
break; break;
@ -692,11 +692,11 @@ KPPPStateMachine::DownEvent()
DownProtocols(); DownProtocols();
// maybe we need to redial // maybe we need to reconnect
if(State() == PPP_STARTING_STATE) { 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 if(fLocalAuthenticationStatus == PPP_AUTHENTICATION_FAILED
|| fLocalAuthenticationStatus == PPP_AUTHENTICATING) || fLocalAuthenticationStatus == PPP_AUTHENTICATING)
Interface().Report(PPP_CONNECTION_REPORT, Interface().Report(PPP_CONNECTION_REPORT,
@ -708,10 +708,10 @@ KPPPStateMachine::DownEvent()
PPP_REPORT_PEER_AUTHENTICATION_FAILED, &fInterface.fID, PPP_REPORT_PEER_AUTHENTICATION_FAILED, &fInterface.fID,
sizeof(ppp_interface_id)); sizeof(ppp_interface_id));
else { else {
// if we are going up and lost connection the redial attempt becomes // if we are going up and lost connection the reconnect attempt becomes
// a dial retry which is managed by the main thread in Interface::Up() // a connect retry which is managed by the main thread in Interface::Up()
if(Interface().fUpThread == -1) if(Interface().fUpThread == -1)
needsRedial = true; needsReconnect = true;
// test if UpFailedEvent() was not called // test if UpFailedEvent() was not called
if(oldPhase != PPP_DOWN_PHASE) if(oldPhase != PPP_DOWN_PHASE)
@ -724,9 +724,9 @@ KPPPStateMachine::DownEvent()
NewState(PPP_INITIAL_STATE); NewState(PPP_INITIAL_STATE);
if(Interface().DoesAutoRedial()) { if(Interface().DoesAutoReconnect()) {
if(needsRedial) if(needsReconnect)
Interface().Redial(Interface().RedialDelay()); Interface().Reconnect(Interface().ReconnectDelay());
} else } else
Interface().Delete(); Interface().Delete();
} else { } else {

View File

@ -1,3 +1,3 @@
- add missing settings support (DialRetryDelay, etc.) - add missing settings support (ConnectRetryDelay, etc.)
- finish support for server mode (profiles, etc.) - finish support for server mode (profiles, etc.)
- add callback support - add callback support

View File

@ -82,12 +82,12 @@ class KPPPInterface : public KPPPLayer {
struct ifnet *Ifnet() const struct ifnet *Ifnet() const
{ return fIfnet; } { return fIfnet; }
//! Delay in miliseconds between a dial retry. //! Delay in miliseconds between a connect retry.
uint32 DialRetryDelay() const uint32 ConnectRetryDelay() const
{ return fDialRetryDelay; } { return fConnectRetryDelay; }
//! Delay in miliseconds to wait until redialing. //! Delay in miliseconds to wait until reconnecting.
uint32 RedialDelay() const uint32 ReconnectDelay() const
{ return fRedialDelay; } { return fReconnectDelay; }
//! Used for reporting that a packet was send/received (updates idle time). //! Used for reporting that a packet was send/received (updates idle time).
void UpdateIdleSince() void UpdateIdleSince()
@ -143,15 +143,15 @@ class KPPPInterface : public KPPPLayer {
bool IsMultilink() const bool IsMultilink() const
{ return fIsMultilink; } { return fIsMultilink; }
void SetAutoRedial(bool autoRedial = true); void SetAutoReconnect(bool autoReconnect = true);
//! Returns whether this interface redials automatically. //! Returns whether this interface reconnects automatically.
bool DoesAutoRedial() const bool DoesAutoReconnect() const
{ return fAutoRedial; } { return fAutoReconnect; }
void SetDialOnDemand(bool dialOnDemand = true); void SetConnectOnDemand(bool connectOnDemand = true);
//! Returns whether dial-on-demand (auto-dial) is enabled. //! Returns whether connect-on-demand (auto-connect) is enabled.
bool DoesDialOnDemand() const bool DoesConnectOnDemand() const
{ return fDialOnDemand; } { return fConnectOnDemand; }
//! Clients are in \c PPP_CLIENT_MODE and servers are in \c PPP_SERVER_MODE. //! Clients are in \c PPP_CLIENT_MODE and servers are in \c PPP_SERVER_MODE.
ppp_mode Mode() const ppp_mode Mode() const
@ -241,7 +241,7 @@ class KPPPInterface : public KPPPLayer {
void CallCloseEvent() void CallCloseEvent()
{ StateMachine().CloseEvent(); } { StateMachine().CloseEvent(); }
void Redial(uint32 delay); void Reconnect(uint32 delay);
// multilink methods // multilink methods
//! Set the parent of this interface. //! Set the parent of this interface.
@ -256,9 +256,9 @@ class KPPPInterface : public KPPPLayer {
thread_id fUpThread, fOpenEventThread, fCloseEventThread; thread_id fUpThread, fOpenEventThread, fCloseEventThread;
thread_id fRedialThread; thread_id fReconnectThread;
uint32 fDialRetry, fDialRetriesLimit; uint32 fConnectRetry, fConnectRetriesLimit;
uint32 fDialRetryDelay, fRedialDelay; uint32 fConnectRetryDelay, fReconnectDelay;
ppp_interface_module_info *fManager; ppp_interface_module_info *fManager;
@ -270,7 +270,7 @@ class KPPPInterface : public KPPPLayer {
TemplateList<KPPPInterface*> fChildren; TemplateList<KPPPInterface*> fChildren;
bool fIsMultilink; bool fIsMultilink;
bool fAutoRedial, fDialOnDemand; bool fAutoReconnect, fConnectOnDemand;
ppp_mode fMode; ppp_mode fMode;
ppp_pfc_state fLocalPFCState, fPeerPFCState; ppp_pfc_state fLocalPFCState, fPeerPFCState;

View File

@ -86,7 +86,7 @@ class KPPPProtocol : public KPPPLayer {
/*! \brief Bring this protocol down. /*! \brief Bring this protocol down.
You must call DownStarted() from here. \n 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; virtual bool Down() = 0;
//! Is this protocol up? //! Is this protocol up?

View File

@ -47,8 +47,8 @@ enum ppp_control_ops {
// KPPPInterface // KPPPInterface
PPPC_GET_INTERFACE_INFO = PPP_INTERFACE_OPS_START, PPPC_GET_INTERFACE_INFO = PPP_INTERFACE_OPS_START,
PPPC_SET_MRU, PPPC_SET_MRU,
PPPC_SET_DIAL_ON_DEMAND, PPPC_SET_CONNECT_ON_DEMAND,
PPPC_SET_AUTO_REDIAL, PPPC_SET_AUTO_RECONNECT,
PPPC_HAS_INTERFACE_SETTINGS, PPPC_HAS_INTERFACE_SETTINGS,
PPPC_SET_PROFILE, PPPC_SET_PROFILE,
@ -151,11 +151,11 @@ typedef struct ppp_interface_info {
uint32 protocolsCount, optionHandlersCount, LCPExtensionsCount, childrenCount; uint32 protocolsCount, optionHandlersCount, LCPExtensionsCount, childrenCount;
uint32 MRU, interfaceMTU; uint32 MRU, interfaceMTU;
uint32 dialRetry, dialRetriesLimit; uint32 connectRetry, connectRetriesLimit;
uint32 dialRetryDelay, redialDelay; uint32 connectRetryDelay, reconnectDelay;
uint32 idleSince, disconnectAfterIdleSince; uint32 idleSince, disconnectAfterIdleSince;
bool doesDialOnDemand, doesAutoRedial, hasDevice, isMultilink, hasParent; bool doesConnectOnDemand, doesAutoReconnect, hasDevice, isMultilink, hasParent;
} ppp_interface_info; } ppp_interface_info;
/*! \brief You \e must use this encapsulator instead of \c ppp_interface_info! /*! \brief You \e must use this encapsulator instead of \c ppp_interface_info!

View File

@ -15,15 +15,14 @@ typedef uint32 ppp_interface_id;
// settings keys // settings keys
#define PPP_ASK_BEFORE_DIALING_KEY "AskBeforeDialing" #define PPP_ASK_BEFORE_CONNECTING_KEY "AskBeforeConnecting"
// userland ppp_server and preflet handle this key // userland ppp_up and preflet handle this key
#define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY "DisonnectAfterIdleSince" #define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY "DisonnectAfterIdleSince"
#define PPP_MODE_KEY "Mode" #define PPP_MODE_KEY "Mode"
#define PPP_DIAL_RETRIES_LIMIT_KEY "DialRetriesLimit" #define PPP_CONNECT_RETRIES_LIMIT_KEY "ConnectRetriesLimit"
#define PPP_DIAL_RETRY_DELAY_KEY "DialRetryDelay" #define PPP_CONNECT_RETRY_DELAY_KEY "ConnectRetryDelay"
#define PPP_DIAL_ON_DEMAND_KEY "DialOnDemand" #define PPP_AUTO_RECONNECT_KEY "AutoReconnect"
#define PPP_AUTO_REDIAL_KEY "AutoRedial" #define PPP_RECONNECT_DELAY_KEY "ReconnectDelay"
#define PPP_REDIAL_DELAY_KEY "RedialDelay"
#define PPP_LOAD_MODULE_KEY "LoadModule" #define PPP_LOAD_MODULE_KEY "LoadModule"
#define PPP_PROTOCOL_KEY "Protocol" #define PPP_PROTOCOL_KEY "Protocol"
#define PPP_DEVICE_KEY "Device" #define PPP_DEVICE_KEY "Device"

View File

@ -13,13 +13,12 @@
static const char *sSkipInterfaceParameters[] = { static const char *sSkipInterfaceParameters[] = {
PPP_ASK_BEFORE_DIALING_KEY, PPP_ASK_BEFORE_CONNECTING_KEY,
PPP_DISONNECT_AFTER_IDLE_SINCE_KEY, PPP_DISONNECT_AFTER_IDLE_SINCE_KEY,
PPP_DIAL_RETRIES_LIMIT_KEY, PPP_CONNECT_RETRIES_LIMIT_KEY,
PPP_DIAL_RETRY_DELAY_KEY, PPP_CONNECT_RETRY_DELAY_KEY,
PPP_DIAL_ON_DEMAND_KEY, PPP_AUTO_RECONNECT_KEY,
PPP_AUTO_REDIAL_KEY, PPP_RECONNECT_DELAY_KEY,
PPP_REDIAL_DELAY_KEY,
NULL NULL
}; };