Some minor changes.
Started to get familiar with the code, again. ;) Some _very_ small work on Up(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4305 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -138,7 +138,10 @@ class PPPInterface {
|
|||||||
PPPLCP fLCP;
|
PPPLCP fLCP;
|
||||||
PPPReportManager fReportManager;
|
PPPReportManager fReportManager;
|
||||||
ifnet *fIfnet;
|
ifnet *fIfnet;
|
||||||
|
|
||||||
thread_id fUpThread;
|
thread_id fUpThread;
|
||||||
|
uint32 fRetry;
|
||||||
|
int32 fMaxRetries;
|
||||||
|
|
||||||
ppp_manager_info *fManager;
|
ppp_manager_info *fManager;
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ enum PPP_REPORT_TYPE {
|
|||||||
|
|
||||||
// report codes (type-specific)
|
// report codes (type-specific)
|
||||||
enum PPP_CONNECTION_REPORT_CODES {
|
enum PPP_CONNECTION_REPORT_CODES {
|
||||||
PPP_GOING_UP = 0,
|
PPP_REPORT_GOING_UP = 0,
|
||||||
PPP_UP_SUCCESSFUL = 1,
|
PPP_REPORT_UP_SUCCESSFUL = 1,
|
||||||
PPP_DOWN_SUCCESSFUL = 2,
|
PPP_REPORT_DOWN_SUCCESSFUL = 2,
|
||||||
PPP_UP_ABORTED = 3,
|
PPP_REPORT_UP_ABORTED = 3,
|
||||||
PPP_UP_FAILED = 4,
|
PPP_REPORT_DEVICE_UP_FAILED = 4,
|
||||||
PPP_AUTHENTICATION_FAILED = 5,
|
PPP_REPORT_AUTHENTICATION_FAILED = 5,
|
||||||
PPP_CONNECTION_LOST = 6
|
PPP_REPORT_CONNECTION_LOST = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ppp_report_packet {
|
typedef struct ppp_report_packet {
|
||||||
|
|||||||
@@ -26,8 +26,9 @@
|
|||||||
PPPInterface::PPPInterface(driver_settings *settings, PPPInterface *parent = NULL)
|
PPPInterface::PPPInterface(driver_settings *settings, PPPInterface *parent = NULL)
|
||||||
: fSettings(dup_driver_settings(settings)),
|
: fSettings(dup_driver_settings(settings)),
|
||||||
fStateMachine(*this), fLCP(*this), fReportManager(StateMachine().Locker()),
|
fStateMachine(*this), fLCP(*this), fReportManager(StateMachine().Locker()),
|
||||||
fIfnet(NULL), fUpThread(-1), fLinkMTU(1500), fAccessing(0), fChildrenCount(0),
|
fIfnet(NULL), fUpThread(-1), fRetry(0), fMaxRetries(0), fLinkMTU(1500),
|
||||||
fDevice(NULL), fFirstEncapsulator(NULL), fLock(StateMachine().Locker())
|
fAccessing(0), fChildrenCount(0), fDevice(NULL), fFirstEncapsulator(NULL),
|
||||||
|
fLock(StateMachine().Locker())
|
||||||
{
|
{
|
||||||
if(get_module(PPP_MANAGER_MODULE_NAME, (module_info**) &fManager) != B_OK)
|
if(get_module(PPP_MANAGER_MODULE_NAME, (module_info**) &fManager) != B_OK)
|
||||||
fManager = NULL;
|
fManager = NULL;
|
||||||
@@ -46,7 +47,7 @@ PPPInterface::PPPInterface(driver_settings *settings, PPPInterface *parent = NUL
|
|||||||
|
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
value = get_settings_value(PPP_MODE_KEY, fsettings);
|
value = get_settings_value(PPP_MODE_KEY, fSettings);
|
||||||
if(!strcasecmp(value, PPP_SERVER_MODE_VALUE))
|
if(!strcasecmp(value, PPP_SERVER_MODE_VALUE))
|
||||||
fMode = PPP_SERVER_MODE;
|
fMode = PPP_SERVER_MODE;
|
||||||
else
|
else
|
||||||
@@ -456,29 +457,41 @@ PPPInterface::Up()
|
|||||||
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(report.code == PPP_GOING_UP) {
|
if(report.code == PPP_REPORT_GOING_UP) {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
continue;
|
continue;
|
||||||
} else if(report.code == PPP_UP_SUCCESSFUL) {
|
} else if(report.code == PPP_REPORT_UP_SUCCESSFUL) {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
||||||
return true;
|
return true;
|
||||||
} else if(report.code == PPP_DOWN_SUCCESSFUL
|
} else if(report.code == PPP_REPORT_DOWN_SUCCESSFUL
|
||||||
|| report.code == PPP_UP_ABORTED) {
|
|| report.code == PPP_REPORT_UP_ABORTED
|
||||||
|
|| report.code == PPP_REPORT_AUTHENTICATION_FAILED) {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
||||||
return false;
|
return false;
|
||||||
} else if(report.code == PPP_UP_FAILED) {
|
} else if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// if maximum number of retries is reached we return false
|
// !!! check code (after vacation you sometimes forget things ;) !!!
|
||||||
// otherwise we wait for the next dial-attempt
|
if(fRetry >= fMaxRetries || fUpThread == -1) {
|
||||||
} else if(report.code == PPP_AUTHENTICATION_FAILED) {
|
PPP_REPLY(sender, B_OK);
|
||||||
PPP_REPLY(sender, B_OK);
|
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
||||||
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
} else if(report.code == PPP_CONNECTION_LOST) {
|
PPP_REPLY(sender, B_OK);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if(report.code == PPP_REPORT_CONNECTION_LOST) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// if autoredial is enabled wait for redial attemts (just continue)
|
// !!! check code (after vacation you sometimes forget things ;) !!!
|
||||||
|
if(DoesAutoRedial()) {
|
||||||
|
PPP_REPLY(sender, B_OK);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
PPP_REPLY(sender, B_OK);
|
||||||
|
fReportManager.DisableReports(PPP_CONNECTION_REPORT, me);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -318,7 +318,8 @@ PPPStateMachine::UpFailedEvent()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Interface()->Report(PPP_CONNECTION_REPORT, PPP_UP_FAILED, NULL, 0);
|
Interface()->Report(PPP_CONNECTION_REPORT, PPP_REPORT_DEVICE_UP_FAILED,
|
||||||
|
NULL, 0);
|
||||||
|
|
||||||
if(Interface()->Parent())
|
if(Interface()->Parent())
|
||||||
Interface()->Parent()->StateMachine().UpFailedEvent(Interface());
|
Interface()->Parent()->StateMachine().UpFailedEvent(Interface());
|
||||||
@@ -430,10 +431,10 @@ PPPStateMachine::DownEvent()
|
|||||||
|| fAuthenticationStatus == PPP_AUTHENTICATING
|
|| fAuthenticationStatus == PPP_AUTHENTICATING
|
||||||
|| fPeerAuthenticationStatus == PPP_AUTHENTICATION_FAILED
|
|| fPeerAuthenticationStatus == PPP_AUTHENTICATION_FAILED
|
||||||
|| fPeerAuthenticationStatus == PPP_AUTHENTICATING)
|
|| fPeerAuthenticationStatus == PPP_AUTHENTICATING)
|
||||||
Interface()->Report(PPP_CONNECTION_REPORT, PPP_AUTHENTICATION_FAILED,
|
Interface()->Report(PPP_CONNECTION_REPORT, PPP_REPORT_AUTHENTICATION_FAILED,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
else
|
else
|
||||||
Interface()->Report(PPP_CONNECTION_REPORT, PPP_CONNECTION_LOST,
|
Interface()->Report(PPP_CONNECTION_REPORT, PPP_REPORT_CONNECTION_LOST,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
|
||||||
if(Interface()->Parent())
|
if(Interface()->Parent())
|
||||||
@@ -443,11 +444,14 @@ PPPStateMachine::DownEvent()
|
|||||||
|
|
||||||
if(Interface()->DoesAutoRedial()) {
|
if(Interface()->DoesAutoRedial()) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// Redial()
|
// redial if we have been connected
|
||||||
|
// problem: if we are reconfiguring we should redial, too
|
||||||
|
// if(oldState == PPP_OPENED_STATE)
|
||||||
|
// Interface()->Redial();
|
||||||
} else if(!Interface()->DoesDialOnDemand())
|
} else if(!Interface()->DoesDialOnDemand())
|
||||||
Interface()->Delete();
|
Interface()->Delete();
|
||||||
} else {
|
} else {
|
||||||
Interface()->Report(PPP_CONNECTION_REPORT, PPP_DOWN_SUCCESSFUL, NULL, 0);
|
Interface()->Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL, NULL, 0);
|
||||||
|
|
||||||
if(!Interface()->DoesDialOnDemand())
|
if(!Interface()->DoesDialOnDemand())
|
||||||
Interface()->Delete();
|
Interface()->Delete();
|
||||||
@@ -463,7 +467,7 @@ PPPStateMachine::OpenEvent()
|
|||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
if(!Interface()->Report(PPP_CONNECTION_REPORT, PPP_GOING_UP, NULL, 0))
|
if(!Interface()->Report(PPP_CONNECTION_REPORT, PPP_REPORT_GOING_UP, NULL, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Interface()->Mode() == PPP_SERVER_MODE) {
|
if(Interface()->Mode() == PPP_SERVER_MODE) {
|
||||||
@@ -1378,7 +1382,7 @@ PPPStateMachine::BringHandlersUp()
|
|||||||
if(Interface()->Ifnet())
|
if(Interface()->Ifnet())
|
||||||
Interface()->Ifnet()->if_flags |= IFF_RUNNING;
|
Interface()->Ifnet()->if_flags |= IFF_RUNNING;
|
||||||
|
|
||||||
Interface()->Report(PPP_CONNECTION_REPORT, PPP_UP_SUCCESSFUL, NULL, 0);
|
Interface()->Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_SUCCESSFUL, NULL, 0);
|
||||||
} else
|
} else
|
||||||
NewPhase(Phase() + 1);
|
NewPhase(Phase() + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ send_data_with_timeout(thread_id thread, int32 code, void *buffer,
|
|||||||
for(tries = 0; tries < timeout; tries++) {
|
for(tries = 0; tries < timeout; tries++) {
|
||||||
if(has_data(thread))
|
if(has_data(thread))
|
||||||
snooze(1000);
|
snooze(1000);
|
||||||
else
|
|
||||||
return send_data(thread, code, buffer, buffer_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_TIMED_OUT;
|
if(!has_data(thread))
|
||||||
|
return send_data(thread, code, buffer, buffer_size);
|
||||||
|
else
|
||||||
|
return B_TIMED_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -30,14 +31,15 @@ receive_data_with_timeout(thread_id *sender, int32 *code, void *buffer,
|
|||||||
int32 tries;
|
int32 tries;
|
||||||
|
|
||||||
for(tries = 0; tries < timeout; tries++) {
|
for(tries = 0; tries < timeout; tries++) {
|
||||||
if(has_data(find_thread(NULL))) {
|
if(!has_data(find_thread(NULL))) {
|
||||||
snooze(1000);
|
snooze(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
*code = receive_data(sender, buffer, buffer_size);
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_TIMED_OUT;
|
if(has_data(find_thread(NULL))) {
|
||||||
|
*code = receive_data(sender, buffer, buffer_size);
|
||||||
|
return B_OK;
|
||||||
|
} else
|
||||||
|
return B_TIMED_OUT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user