00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef XRDMONSENDERINFO_HH
00014 #define XRDMONSENDERINFO_HH
00015
00016 #include "XrdMon/XrdMonTypes.hh"
00017 #include <stdio.h>
00018 #include <netinet/in.h>
00019 #include <map>
00020 #include <vector>
00021 using std::map;
00022 using std::vector;
00023
00024 class XrdMonSenderInfo {
00025 public:
00026 static senderid_t convert2Id(struct sockaddr_in sAddr);
00027 static hp_t addr2HostPort(struct sockaddr_in sAddr) {
00028 return id2HostPort(convert2Id(sAddr));
00029 }
00030 static hp_t id2HostPort(senderid_t id) {
00031 if ( id >= _hps.size() ) {
00032 return hp_t((char*) "Error, invalid offset", 0);
00033 }
00034 return _hps[id];
00035 }
00036 static const char* id2HostPortStr(senderid_t id) {
00037 hp_t hp = id2HostPort(id);
00038 static char x[256];
00039 sprintf(x, "%s:%d", hp.first, hp.second);
00040 return x;
00041 }
00042
00043 static const char* id2Host(senderid_t id) {
00044 if ( id >= _hps.size() ) {
00045 return "Error, invalid offset";
00046 }
00047 return _hps[id].first;
00048 }
00049 static void printSelf();
00050
00051 static void shutdown();
00052
00053 private:
00054 static void registerSender(struct sockaddr_in sAddr);
00055
00056 private:
00057
00058
00059 static map<kXR_int64, senderid_t> _ids;
00060
00061 static vector<hp_t> _hps;
00062 };
00063
00064 #endif