xref: /haiku/src/servers/net/PPPServer.cpp (revision 2d73faba95c911a11d8a4a2070c47d47250ed9a9)
1dceee0deSWaldemar Kornewald /*
2*6e17c55aSWaldemar Kornewald  * Copyright 2004-2005, Waldemar Kornewald <wkornew@gmx.net>
3dceee0deSWaldemar Kornewald  * Distributed under the terms of the MIT License.
4dceee0deSWaldemar Kornewald  */
560abfca0SWaldemar Kornewald 
660abfca0SWaldemar Kornewald #include "PPPServer.h"
760abfca0SWaldemar Kornewald #include <Application.h>
860abfca0SWaldemar Kornewald 
960abfca0SWaldemar Kornewald 
PPPServer()1060abfca0SWaldemar Kornewald PPPServer::PPPServer()
11abdb7d1aSWaldemar Kornewald 	: BHandler("PPPServer"),
12abdb7d1aSWaldemar Kornewald 	fListener(this)
1360abfca0SWaldemar Kornewald {
1460abfca0SWaldemar Kornewald 	be_app->AddHandler(this);
15abdb7d1aSWaldemar Kornewald 
16abdb7d1aSWaldemar Kornewald 	fListener.WatchManager();
170a628cf2SWaldemar Kornewald 
180a628cf2SWaldemar Kornewald 	InitInterfaces();
1960abfca0SWaldemar Kornewald }
2060abfca0SWaldemar Kornewald 
2160abfca0SWaldemar Kornewald 
~PPPServer()2260abfca0SWaldemar Kornewald PPPServer::~PPPServer()
2360abfca0SWaldemar Kornewald {
24abdb7d1aSWaldemar Kornewald 	UninitInterfaces();
25abdb7d1aSWaldemar Kornewald 
26abdb7d1aSWaldemar Kornewald 	fListener.StopWatchingManager();
27abdb7d1aSWaldemar Kornewald 
280a628cf2SWaldemar Kornewald 	be_app->RemoveHandler(this);
2960abfca0SWaldemar Kornewald }
3060abfca0SWaldemar Kornewald 
3160abfca0SWaldemar Kornewald 
3260abfca0SWaldemar Kornewald void
MessageReceived(BMessage * message)3360abfca0SWaldemar Kornewald PPPServer::MessageReceived(BMessage *message)
3460abfca0SWaldemar Kornewald {
3560abfca0SWaldemar Kornewald 	switch(message->what) {
360a628cf2SWaldemar Kornewald 		case PPP_REPORT_MESSAGE:
370a628cf2SWaldemar Kornewald 			HandleReportMessage(message);
380a628cf2SWaldemar Kornewald 		break;
3960abfca0SWaldemar Kornewald 
4060abfca0SWaldemar Kornewald 		default:
4160abfca0SWaldemar Kornewald 			BHandler::MessageReceived(message);
4260abfca0SWaldemar Kornewald 	}
4360abfca0SWaldemar Kornewald }
440a628cf2SWaldemar Kornewald 
450a628cf2SWaldemar Kornewald 
460a628cf2SWaldemar Kornewald void
InitInterfaces()470a628cf2SWaldemar Kornewald PPPServer::InitInterfaces()
480a628cf2SWaldemar Kornewald {
49abdb7d1aSWaldemar Kornewald 	// TODO: create one ConnectionRequestWindow per interface
500a628cf2SWaldemar Kornewald }
510a628cf2SWaldemar Kornewald 
520a628cf2SWaldemar Kornewald 
53abdb7d1aSWaldemar Kornewald void
UninitInterfaces()54abdb7d1aSWaldemar Kornewald PPPServer::UninitInterfaces()
550a628cf2SWaldemar Kornewald {
56abdb7d1aSWaldemar Kornewald 	// TODO: delete all ConnectionRequestWindows
570a628cf2SWaldemar Kornewald }
580a628cf2SWaldemar Kornewald 
590a628cf2SWaldemar Kornewald 
600a628cf2SWaldemar Kornewald void
HandleReportMessage(BMessage * message)610a628cf2SWaldemar Kornewald PPPServer::HandleReportMessage(BMessage *message)
620a628cf2SWaldemar Kornewald {
630a628cf2SWaldemar Kornewald 	ppp_interface_id id;
64abdb7d1aSWaldemar Kornewald 	if (message->FindInt32("interface", reinterpret_cast<int32*>(&id)) != B_OK)
650a628cf2SWaldemar Kornewald 		return;
660a628cf2SWaldemar Kornewald 
670a628cf2SWaldemar Kornewald 	int32 type, code;
680a628cf2SWaldemar Kornewald 	message->FindInt32("type", &type);
690a628cf2SWaldemar Kornewald 	message->FindInt32("code", &code);
700a628cf2SWaldemar Kornewald 
71abdb7d1aSWaldemar Kornewald 	if (type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED)
72abdb7d1aSWaldemar Kornewald 		CreateConnectionRequestWindow(id);
730a628cf2SWaldemar Kornewald }
74dceee0deSWaldemar Kornewald 
75dceee0deSWaldemar Kornewald 
76dceee0deSWaldemar Kornewald void
CreateConnectionRequestWindow(ppp_interface_id id)77abdb7d1aSWaldemar Kornewald PPPServer::CreateConnectionRequestWindow(ppp_interface_id id)
78dceee0deSWaldemar Kornewald {
79abdb7d1aSWaldemar Kornewald 	// TODO: create window, register window as report receiver for the interface
80abdb7d1aSWaldemar Kornewald 	// XXX: if a window for that ID exists then only register it as report receiver
81dceee0deSWaldemar Kornewald }
82