xref: /haiku/src/servers/net/PPPServer.cpp (revision abdb7d1abbf1686ecb8f7132e576d332f6cc01ed)
1dceee0deSWaldemar Kornewald /*
2*abdb7d1aSWaldemar Kornewald  * Copyright 2004-2005, Waldemar Kornewald <Waldemar.Kornewald@web.de>
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 
1060abfca0SWaldemar Kornewald PPPServer::PPPServer()
11*abdb7d1aSWaldemar Kornewald 	: BHandler("PPPServer"),
12*abdb7d1aSWaldemar Kornewald 	fListener(this)
1360abfca0SWaldemar Kornewald {
1460abfca0SWaldemar Kornewald 	be_app->AddHandler(this);
15*abdb7d1aSWaldemar Kornewald 
16*abdb7d1aSWaldemar Kornewald 	fListener.WatchManager();
170a628cf2SWaldemar Kornewald 
180a628cf2SWaldemar Kornewald 	InitInterfaces();
1960abfca0SWaldemar Kornewald }
2060abfca0SWaldemar Kornewald 
2160abfca0SWaldemar Kornewald 
2260abfca0SWaldemar Kornewald PPPServer::~PPPServer()
2360abfca0SWaldemar Kornewald {
24*abdb7d1aSWaldemar Kornewald 	UninitInterfaces();
25*abdb7d1aSWaldemar Kornewald 
26*abdb7d1aSWaldemar Kornewald 	fListener.StopWatchingManager();
27*abdb7d1aSWaldemar Kornewald 
280a628cf2SWaldemar Kornewald 	be_app->RemoveHandler(this);
2960abfca0SWaldemar Kornewald }
3060abfca0SWaldemar Kornewald 
3160abfca0SWaldemar Kornewald 
3260abfca0SWaldemar Kornewald void
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
470a628cf2SWaldemar Kornewald PPPServer::InitInterfaces()
480a628cf2SWaldemar Kornewald {
49*abdb7d1aSWaldemar Kornewald 	// TODO: create one ConnectionRequestWindow per interface
500a628cf2SWaldemar Kornewald }
510a628cf2SWaldemar Kornewald 
520a628cf2SWaldemar Kornewald 
53*abdb7d1aSWaldemar Kornewald void
54*abdb7d1aSWaldemar Kornewald PPPServer::UninitInterfaces()
550a628cf2SWaldemar Kornewald {
56*abdb7d1aSWaldemar Kornewald 	// TODO: delete all ConnectionRequestWindows
570a628cf2SWaldemar Kornewald }
580a628cf2SWaldemar Kornewald 
590a628cf2SWaldemar Kornewald 
600a628cf2SWaldemar Kornewald void
610a628cf2SWaldemar Kornewald PPPServer::HandleReportMessage(BMessage *message)
620a628cf2SWaldemar Kornewald {
630a628cf2SWaldemar Kornewald 	ppp_interface_id id;
64*abdb7d1aSWaldemar 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 
71*abdb7d1aSWaldemar Kornewald 	if(type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED)
72*abdb7d1aSWaldemar Kornewald 		CreateConnectionRequestWindow(id);
730a628cf2SWaldemar Kornewald }
74dceee0deSWaldemar Kornewald 
75dceee0deSWaldemar Kornewald 
76dceee0deSWaldemar Kornewald void
77*abdb7d1aSWaldemar Kornewald PPPServer::CreateConnectionRequestWindow(ppp_interface_id id)
78dceee0deSWaldemar Kornewald {
79*abdb7d1aSWaldemar Kornewald 	// TODO: create window, register window as report receiver for the interface
80*abdb7d1aSWaldemar Kornewald 	// XXX: if a window for that ID exists then only register it as report receiver
81dceee0deSWaldemar Kornewald }
82