haiku/src/servers/net/PPPServer.cpp
Waldemar Kornewald 0a628cf2fc Nothing special. Just bringing the cvs version up-to-date with my private version.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7206 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-04-15 16:05:40 +00:00

104 lines
2.1 KiB
C++

//-----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// Copyright (c) 2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
//-----------------------------------------------------------------------
#include "PPPServer.h"
#include "SimpleMessageFilter.h"
#include <Application.h>
// the message constants that should be filtered
static const uint32 *kPPPWhatValues = {
// PPPS_CONNECT,
0 // end-of-list
};
PPPServer::PPPServer()
: BHandler("PPPServer")
{
be_app->AddHandler(this);
fFilter = new SimpleMessageFilter(kPPPWhatValues, this);
be_app->AddCommonFilter(fFilter);
fListener = new PPPInterfaceListener(this);
fListener->WatchAllInterfaces();
InitInterfaces();
}
PPPServer::~PPPServer()
{
delete fListener;
be_app->RemoveCommonFilter(fFilter);
be_app->RemoveHandler(this);
delete fFilter;
}
void
PPPServer::MessageReceived(BMessage *message)
{
switch(message->what) {
case PPP_REPORT_MESSAGE:
HandleReportMessage(message);
break;
// TODO: handle
default:
BHandler::MessageReceived(message);
}
}
void
PPPServer::InitInterfaces()
{
}
bool
PPPServer::AskBeforeDialing(ppp_interface_id id)
{
return false;
}
void
PPPServer::HandleReportMessage(BMessage *message)
{
thread_id sender;
message->FindInt32("sender", &sender);
ppp_interface_id id;
if(message->FindInt32("interface", reinterpret_cast<int32*>(&id)) != B_OK) {
send_data(sender, B_OK, NULL, 0);
return;
}
int32 type, code;
message->FindInt32("type", &type);
message->FindInt32("code", &code);
if(type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED) {
// TODO: check if we need to add this interface to our watch-list
} else if(type == PPP_CONNECTION_REPORT) {
switch(code) {
case PPP_REPORT_GOING_UP: {
if(AskBeforeDialing(id)) {
// OpenDialRequestWindow(id, sender);
return;
}
} break;
}
} else if(type == PPP_DESTRUCTION_REPORT) {
// TODO: check if this interface has DOD enabled. if so: create new!
}
send_data(sender, B_OK, NULL, 0);
}