xrootd
XrdMonDecUserInfo.hh
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* */
3 /* XrdMonDecUserInfo.hh */
4 /* */
5 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Jacek Becla for Stanford University under contract */
8 /* DE-AC02-76SF00515 with the Department of Energy */
9 /*****************************************************************************/
10 
11 // $Id$
12 
13 #ifndef XRDMONDECUSERINFO_HH
14 #define XRDMONDECUSERINFO_HH
15 
16 #include "XrdMon/XrdMonCommon.hh"
17 #include "XrdMon/XrdMonTypes.hh"
18 #include "XrdSys/XrdSysHeaders.hh"
19 
20 #include <string>
21 #include <strings.h>
22 #include <string.h>
23 
24 using std::ostream;
25 using std::string;
26 
27 class XrdMonDecTraceInfo;
28 
30 public:
31  enum TYPE { CONNECT, DISCONNECT };
32 
36  const char* theString,
37  int len,
39 
40  inline bool readyToBeStored() const {return _dTime > 0;}
41 
42  void setDisconnectInfo(kXR_int32 sec, kXR_int32 timestamp);
43 
44  dictid_t xrdId() const { return _myXrdId; }
45  dictid_t uniqueId() const { return _myUniqueId; }
46  senderid_t senderId() const { return _senderId; }
47 
48  const char* convert2string() const;
49  const char* writeRT2Buffer(TYPE t) const;
50  string convert2stringRTDisconnect() const;
51  int mySize();
52 
53 private:
54  int doOne(const char* s, char* buf, int len, char delim) {
55  int x = 0;
56  while ( x < len && *(s+x) != delim ) {
57  ++x;
58  }
59  if ( x >= len ) {
60  return -1;
61  }
62 
63  memcpy(buf, s, x);
64  *(buf+x) = '\0';
65  return x;
66  }
67 
68  dictid_t _myXrdId; // the one that come inside packet, not unique
69  dictid_t _myUniqueId; // unique (across all dictIds for given xrd server)
70 
71  string _user;
72  kXR_int16 _pid; // client process id
73  string _cHost; // client host
74 
76 
77  kXR_int32 _sec; // number of seconds that client was connected
78  kXR_int32 _dTime; // disconnect time
79 
80  friend ostream& operator<<(ostream& o, const XrdMonDecUserInfo& m);
81 };
82 
83 #endif /* XRDMONDECUSERINFO_HH */