Initial checkin of skeleton net_server.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7136 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+1
-1
@@ -5,8 +5,8 @@ SubInclude OBOS_TOP src servers input ;
|
|||||||
SubInclude OBOS_TOP src servers media ;
|
SubInclude OBOS_TOP src servers media ;
|
||||||
SubInclude OBOS_TOP src servers media_addon ;
|
SubInclude OBOS_TOP src servers media_addon ;
|
||||||
SubInclude OBOS_TOP src servers midi ;
|
SubInclude OBOS_TOP src servers midi ;
|
||||||
|
SubInclude OBOS_TOP src servers net ;
|
||||||
SubInclude OBOS_TOP src servers print ;
|
SubInclude OBOS_TOP src servers print ;
|
||||||
SubInclude OBOS_TOP src servers registrar ;
|
SubInclude OBOS_TOP src servers registrar ;
|
||||||
SubInclude OBOS_TOP src servers screensaver ;
|
SubInclude OBOS_TOP src servers screensaver ;
|
||||||
SubInclude OBOS_TOP src servers syslog_daemon ;
|
SubInclude OBOS_TOP src servers syslog_daemon ;
|
||||||
# SubInclude OBOS_TOP src servers net ;
|
|
||||||
|
|||||||
+12
-5
@@ -3,13 +3,20 @@ SubDir OBOS_TOP src servers net ;
|
|||||||
UsePrivateHeaders net ;
|
UsePrivateHeaders net ;
|
||||||
|
|
||||||
Server net_server :
|
Server net_server :
|
||||||
userland_server.c
|
NetServer.cpp
|
||||||
userland_ipc.c
|
|
||||||
|
# utils
|
||||||
|
SimpleMessageFilter.cpp
|
||||||
|
|
||||||
|
# built-in add-ons
|
||||||
|
PPPServer.cpp
|
||||||
|
|
||||||
|
# old net_server (was a netstack tester app)
|
||||||
|
# userland_server.c
|
||||||
|
# userland_ipc.c
|
||||||
;
|
;
|
||||||
|
|
||||||
LinkSharedOSLibs net_server :
|
LinkSharedOSLibs net_server :
|
||||||
be
|
be
|
||||||
root
|
net
|
||||||
libnet.so
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004 Waldemar Kornewald, [email protected]
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Alert.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const char *kSignature = "application/x-obos.net_server";
|
||||||
|
|
||||||
|
|
||||||
|
class NetServerApplication : public BApplication {
|
||||||
|
public:
|
||||||
|
NetServerApplication();
|
||||||
|
|
||||||
|
virtual void AboutRequested();
|
||||||
|
virtual void ReadyToRun();
|
||||||
|
// loads add-ons
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
// unloads add-ons
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
new NetServerApplication();
|
||||||
|
|
||||||
|
be_app->Run();
|
||||||
|
|
||||||
|
delete be_app;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NetServerApplication::NetServerApplication()
|
||||||
|
: BApplication(kSignature)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
NetServerApplication::AboutRequested()
|
||||||
|
{
|
||||||
|
// the alert should not block because we might get _very_ important messages
|
||||||
|
(new BAlert("About...",
|
||||||
|
"OpenBeOS net_server\n\n"
|
||||||
|
"The net_server manages all userland tasks that "
|
||||||
|
"cannot be handled by the netstack.",
|
||||||
|
"Uhm...Cool?", NULL, NULL, B_WIDTH_AS_USUAL,
|
||||||
|
B_INFO_ALERT))->Go(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
NetServerApplication::ReadyToRun()
|
||||||
|
{
|
||||||
|
// load integrated add-ons
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: load add-on binaries
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
NetServerApplication::QuitRequested()
|
||||||
|
{
|
||||||
|
// unload integrated add-ons
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: unload add-on binaries
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004 Waldemar Kornewald, [email protected]
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PPPServer::~PPPServer()
|
||||||
|
{
|
||||||
|
be_app->RemoveHandler(this);
|
||||||
|
be_app->RemoveCommonFilter(fFilter);
|
||||||
|
delete fFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPServer::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch(message->what) {
|
||||||
|
// TODO: handle PPP stack messages
|
||||||
|
|
||||||
|
// TODO: handle requests from DialUpPreflet
|
||||||
|
|
||||||
|
default:
|
||||||
|
BHandler::MessageReceived(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004 Waldemar Kornewald, [email protected]
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _PPP_SERVER__H
|
||||||
|
#define _PPP_SERVER__H
|
||||||
|
|
||||||
|
#include <Handler.h>
|
||||||
|
|
||||||
|
class SimpleMessageFilter;
|
||||||
|
|
||||||
|
|
||||||
|
class PPPServer : public BHandler {
|
||||||
|
public:
|
||||||
|
PPPServer();
|
||||||
|
virtual ~PPPServer();
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
// the SimpleMessageFilter routes ppp_server messages to this handler
|
||||||
|
|
||||||
|
private:
|
||||||
|
SimpleMessageFilter *fFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004 Waldemar Kornewald, [email protected]
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*! \class SimpleMessageFilter
|
||||||
|
\brief This is a BMessageFilter that can filter multiple \a what values.
|
||||||
|
|
||||||
|
This class extends the BMessageFilter's ability of handling one \a what value
|
||||||
|
to handling multiple \a what values.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SimpleMessageFilter.h"
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Creates a copy of the \a what array.
|
||||||
|
|
||||||
|
\param what A pointer to an array of \a what values that should be filtered.
|
||||||
|
The end-of-list indicator is an element valued 0 (zero).
|
||||||
|
\param target The target for messages matching one of the \a what values.
|
||||||
|
If \a target == NULL the messages will be discarded.
|
||||||
|
*/
|
||||||
|
SimpleMessageFilter::SimpleMessageFilter(const uint32 *what, BHandler *target)
|
||||||
|
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||||
|
fTarget(target)
|
||||||
|
{
|
||||||
|
if(!what) {
|
||||||
|
fWhatArray = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// include the trailing zero in the copy
|
||||||
|
int32 count = 0;
|
||||||
|
while(what[count++] != 0)
|
||||||
|
;
|
||||||
|
fWhatArray = new uint32[count];
|
||||||
|
memcpy(fWhatArray, what, count * sizeof(uint32));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Frees the copied \a what array.
|
||||||
|
SimpleMessageFilter::~SimpleMessageFilter()
|
||||||
|
{
|
||||||
|
delete fWhatArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Filters all messages that match the \a what array given in the constructor.
|
||||||
|
filter_result
|
||||||
|
SimpleMessageFilter::Filter(BMessage *message, BHandler **target)
|
||||||
|
{
|
||||||
|
for(int32 index = 0; fWhatArray[index] != 0; index++)
|
||||||
|
if(fWhatArray[index] == message->what) {
|
||||||
|
if(!fTarget)
|
||||||
|
return B_SKIP_MESSAGE;
|
||||||
|
|
||||||
|
*target = fTarget;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_DISPATCH_MESSAGE;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004 Waldemar Kornewald, [email protected]
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _SIMPLE_MESSAGE_FILTER__H
|
||||||
|
#define _SIMPLE_MESSAGE_FILTER__H
|
||||||
|
|
||||||
|
#include <MessageFilter.h>
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleMessageFilter : public BMessageFilter {
|
||||||
|
public:
|
||||||
|
SimpleMessageFilter(const uint32 *what, BHandler *target);
|
||||||
|
virtual ~SimpleMessageFilter();
|
||||||
|
|
||||||
|
virtual filter_result Filter(BMessage *message, BHandler **target);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32 *fWhatArray;
|
||||||
|
BHandler *fTarget;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user