Inetd.h

Go to the documentation of this file.
00001 #ifndef __INETD_H__
00002 #define __INETD_H__
00003 
00004 /*
00005 
00006 $Header$
00007 
00008 */
00009 
00010 #include <map>
00011 
00012 #include "Service.h"
00013 #include "TcpServer.h"
00014 #include "Core.h"
00015 #include "S11nInetdItem.h"
00016 #include "Registry.h"
00017 
00018 // Messages.
00019 static const char *const MSG_INETD_UNKNOWN_SERVER           = "Unknown server.";
00020 static const char *const MSG_INETD_SERVICE_INSTANCE_STARTED = "Instance of service '%s' started for user '%s' from host '%s'.";
00021 static const char *const MSG_INETD_AUTHORIZATION_FAILED     = "Authorization failed.";
00022 static const char *const MSG_INETD_LOGIN                    = "Login: ";
00023 static const char *const MSG_INETD_PASSWORD                 = "Password: ";
00024 
00025 static const char *const NAME_INETD = "inetd";
00026 static const char *const MAN_INETD  = "\
00027 Service <service>inetd</service> is inspired by <keyword>Unix</keyword> inetd daemon. \
00028 So, it performs the same function. It uses <registry>inetd.services</registry> registry \
00029 entry to obtain the list of services to be started. This registry entry contains pairs of \
00030 service name and correspondent <keyword>TCP</keyword> port. When incoming connection appears \
00031 on that port <service>inetd</service> starts the correspondent service. It passes <keyword>TCP</keyword> \
00032 session as a parameter to started service.\
00033 ";
00034 
00035 // Registry manuals.
00036 
00037 static const char *const MAN_INETD_SERVICES = "\
00038 <registry>vector<InetdItem> init.services()</registry>\n\n\
00039 Contains service name and correspondent <keyword>TCP</keyword> port, login and password, \
00040 allowed and denied IP network addresses (last four are optional). When incoming connection appears \
00041 on that port <service>inetd</service> authenticates the user and in case of success starts \
00042 the correspondent service. It passes <keyword>TCP</keyword> \
00043 session as a parameter to started service.\
00044 ";
00045 
00046 using namespace std;
00047 
00048 class Inetd;
00049 
00050 class Inetd : public Service<Inetd>
00051 {
00052 
00053 friend class Service<Inetd>;
00054 
00055   PYLON_OBJECT
00056 
00057 public:
00058 
00059   inline
00060   static String NAME();
00061 
00062   inline
00063   static String MANUAL();
00064 
00065   static unsigned int instancesNumberLimit();
00066 
00067 protected:
00068 
00069   Inetd(const ValueList &params);
00070   virtual ~Inetd();
00071 
00072 private:
00073 
00074   REGISTRY(vector<InetdItem>, services, vector<InetdItem>(), MAN_INETD_SERVICES);
00075 
00076   typedef map<TcpServer *, InetdItem> InetdServerList;
00077   typedef map<unsigned int, TcpServer *> InetdServersByPort;
00078 
00079   SLOT(startService, TcpConnection *);
00080 
00081   int authorize(const InetdItem &item, TcpConnection *connection, bool &valid);
00082 
00083   InetdServerList _servers;
00084   vector<InetdItem> _services;
00085   Core *_core;
00086   InetdServersByPort _serversByPort;
00087 };
00088 
00089 inline
00090 String Inetd::NAME()
00091 {
00092   return NAME_INETD;
00093 }
00094 
00095 inline
00096 String Inetd::MANUAL()
00097 {
00098   return MAN_INETD;
00099 }
00100 
00101 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1