Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
CAListenerInterface Class Reference

#include <CAListenerInterface.hpp>

Collaboration diagram for CAListenerInterface:

Public Member Functions

 CAListenerInterface (const CAListenerInterface &l)
 
CAListenerInterfaceoperator= (const CAListenerInterface &)
 
 ~CAListenerInterface (void)
 
NetworkType getType () const
 
SINT32 getHostName (UINT8 *buff, UINT32 bufflen) const
 
CASocketAddrgetAddr () const
 
bool isHidden () const
 
bool isVirtual () const
 
char * getHostname ()
 
SINT32 toDOMElement (DOMElement *&elem, XERCES_CPP_NAMESPACE::DOMDocument *ownerDoc) const
 

Static Public Member Functions

static CAListenerInterfacegetInstance (const DOMNode *node)
 
static CAListenerInterface ** getInstance (DOMElement *a_elemListenerInterfaces, UINT32 &r_length)
 
static CAListenerInterfacegetInstance (NetworkType type, const UINT8 *path)
 
static CAListenerInterfacegetInstance (NetworkType type, const UINT8 *hostnameOrIP, UINT16 port)
 

Static Public Attributes

static const char * XML_ELEMENT_CONTAINER_NAME = "ListenerInterfaces"
 
static const char * XML_ELEMENT_NAME = "ListenerInterface"
 

Private Member Functions

 CAListenerInterface (void)
 

Private Attributes

CASocketAddrm_pAddr
 
UINT8m_strHostname
 
NetworkType m_Type
 
bool m_bHidden
 
bool m_bVirtual
 

Detailed Description

Definition at line 6 of file CAListenerInterface.hpp.

Constructor & Destructor Documentation

◆ CAListenerInterface() [1/2]

CAListenerInterface::CAListenerInterface ( void  )
private

Definition at line 42 of file CAListenerInterface.cpp.

43  {
44  m_bHidden=false;
45  m_bVirtual=false;
46  m_strHostname=NULL;
47  m_pAddr=NULL;
49  }
@ UNKNOWN_NETWORKTYPE
Definition: typedefs.hpp:30

References m_bHidden, m_bVirtual, m_pAddr, m_strHostname, m_Type, and UNKNOWN_NETWORKTYPE.

Referenced by getInstance().

Here is the caller graph for this function:

◆ CAListenerInterface() [2/2]

CAListenerInterface::CAListenerInterface ( const CAListenerInterface l)
inline

Definition at line 12 of file CAListenerInterface.hpp.

13  {
14  m_Type=l.m_Type;
17  if(l.m_pAddr!=NULL)
18  m_pAddr=l.m_pAddr->clone();
19  else
20  m_pAddr=NULL;
21  if(l.m_strHostname!=NULL)
22  {
23  UINT32 i=strlen((char*)l.m_strHostname);
24  m_strHostname=new UINT8[i+1];
25  memcpy(m_strHostname,l.m_strHostname,i);
26  m_strHostname[i]=0;
27  }
28  else
29  m_strHostname=NULL;
30  }
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
virtual CASocketAddr * clone() const =0
Creates a copy of the Address.

References CASocketAddr::clone(), m_bHidden, m_bVirtual, m_pAddr, m_strHostname, and m_Type.

Here is the call graph for this function:

◆ ~CAListenerInterface()

CAListenerInterface::~CAListenerInterface ( void  )

Definition at line 51 of file CAListenerInterface.cpp.

52  {
53  delete m_pAddr;
54  m_pAddr = NULL;
55  delete[] m_strHostname;
56  m_strHostname = NULL;
57  }

References m_pAddr, and m_strHostname.

Member Function Documentation

◆ getAddr()

CASocketAddr* CAListenerInterface::getAddr ( ) const
inline

Definition at line 47 of file CAListenerInterface.hpp.

48  {
49  return m_pAddr->clone();
50  }

References CASocketAddr::clone(), and m_pAddr.

Referenced by CACmdLnOptions::createSockets(), CALastMix::init(), CALocalProxy::init(), and CAMiddleMix::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHostname()

char* CAListenerInterface::getHostname ( )
inline

Definition at line 60 of file CAListenerInterface.hpp.

60 { return (char*)m_strHostname; }

References m_strHostname.

◆ getHostName()

SINT32 CAListenerInterface::getHostName ( UINT8 buff,
UINT32  bufflen 
) const

◆ getInstance() [1/4]

CAListenerInterface * CAListenerInterface::getInstance ( const DOMNode *  node)
static

elemListenerInterface.getNodeName().equals("ListenerInterface"))

Definition at line 157 of file CAListenerInterface.cpp.

158  {
159  if( elemListenerInterface==NULL||
160  elemListenerInterface->getNodeType()!=DOMNode::ELEMENT_NODE)//||
162  return NULL;
163  CAListenerInterface* pListener=new CAListenerInterface();
164  getDOMElementAttribute(elemListenerInterface,"hidden",pListener->m_bHidden);
165  getDOMElementAttribute(elemListenerInterface,"virtual",pListener->m_bVirtual);
166  DOMNode* elemType=NULL;
167  getDOMChildByName(elemListenerInterface,"NetworkProtocol",elemType,false);
168  if (elemType == NULL)
169  {
170  getDOMChildByName(elemListenerInterface,"Type",elemType,false);
171  }
172  UINT32 tmpLen = 255;
173  UINT8 tmpBuff[255];
174  if (elemType != NULL)
175  {
176  if(getDOMElementValue(elemType,tmpBuff,&tmpLen)!=E_SUCCESS)
177  goto ERR;
178  strtrim(tmpBuff);
179  if(strcmp((char*)tmpBuff,"RAW/TCP")==0)
180  pListener->m_Type=RAW_TCP;
181  else if(strcmp((char*)tmpBuff,"RAW/UNIX")==0)
182  pListener->m_Type=RAW_UNIX;
183  else if (strcmp((char*)tmpBuff, "RAW/UDP") == 0)
184  pListener->m_Type = RAW_UDP;
185  else if(strcmp((char*)tmpBuff,"SSL/TCP")==0)
186  pListener->m_Type=SSL_TCP;
187  else if(strcmp((char*)tmpBuff,"SSL/UNIX")==0)
188  pListener->m_Type=SSL_UNIX;
189  else if (strcmp((char*)tmpBuff,"HTTP/TCP")==0)
190  {
191  pListener->m_Type=HTTP_TCP;
192  }
193  else
194  goto ERR;
195  }
196  else
197  {
198  // infoservice old style <= config version 0.61
199  pListener->m_Type=HTTP_TCP;
200  }
201  if(pListener->m_Type==SSL_TCP||pListener->m_Type==RAW_TCP|| pListener->m_Type == RAW_UDP
202  ||pListener->m_Type==HTTP_TCP)
203  {
204  DOMNode* elemIP=NULL;
205  DOMElement* elemPort=NULL;
206  DOMNode* elemHost=NULL;
207  getDOMChildByName(elemListenerInterface,"Port",elemPort,false);
208  UINT32 port;
209  if(getDOMElementValue(elemPort,&port)!=E_SUCCESS)
210  goto ERR;
211  pListener->m_pAddr=new CASocketAddrINet;
212  getDOMChildByName(elemListenerInterface,"IP",elemIP,false);
213  if(elemIP!=NULL)
214  {
215  UINT8 buffIP[50];
216  UINT32 buffIPLen=50;
217  if(getDOMElementValue(elemIP,buffIP,&buffIPLen)!=E_SUCCESS)
218  goto ERR;
219  if(((CASocketAddrINet*)pListener->m_pAddr)->setAddr(buffIP,(UINT16)port)!=E_SUCCESS)
220  goto ERR;
221  }
222  getDOMChildByName(elemListenerInterface,"Host",elemHost,false);
223  tmpLen=255;
224  if(getDOMElementValue(elemHost,tmpBuff,&tmpLen)==E_SUCCESS)
225  {
226  tmpBuff[tmpLen]=0;
227  if(elemIP==NULL&&((CASocketAddrINet*)pListener->m_pAddr)->setAddr(tmpBuff,(UINT16)port)!=E_SUCCESS)
228  goto ERR;
229  pListener->m_strHostname=new UINT8[tmpLen+1];
230  memcpy(pListener->m_strHostname,tmpBuff,tmpLen);
231  pListener->m_strHostname[tmpLen]=0;
232  }
233  else if(elemIP==NULL)
234  goto ERR;
235  }
236  else
237  #ifdef HAVE_UNIX_DOMAIN_PROTOCOL
238  {
239  DOMElement* elemFile=NULL;
240  getDOMChildByName(elemListenerInterface,"File",elemFile,false);
241  tmpLen=255;
242  if(getDOMElementValue(elemFile,tmpBuff,&tmpLen)!=E_SUCCESS)
243  goto ERR;
244  tmpBuff[tmpLen]=0;
245  strtrim(tmpBuff);
246  pListener->m_pAddr=new CASocketAddrUnix;
247  if(((CASocketAddrUnix*)pListener->m_pAddr)->setPath((char*)tmpBuff)!=E_SUCCESS)
248  goto ERR;
249  pListener->m_strHostname=NULL;
250  }
251  #else
252  goto ERR;
253  #endif
254  return pListener;
255 ERR:
256  delete pListener;
257  pListener = NULL;
258  return NULL;
259 }
SINT32 getDOMElementValue(const DOMNode *const pElem, UINT8 *value, UINT32 *valuelen)
Returns the content of the text node(s) under elem as null-terminated C String.
Definition: CAUtil.cpp:746
UINT32 strtrim(UINT8 *s)
Removes leading and ending whitespaces (chars<=32) from a zero terminated string.
Definition: CAUtil.cpp:49
SINT32 getDOMChildByName(const DOMNode *pNode, const char *const name, DOMElement *&child, bool deep)
Definition: CAUtil.cpp:458
SINT32 getDOMElementAttribute(const DOMNode *const elem, const char *attrName, UINT8 *value, UINT32 *len)
Definition: CAUtil.cpp:780
unsigned short UINT16
Definition: basetypedefs.h:133
This class represents a socket address for Internet (IP) connections.
This is a class for Unix Domain Protocol Sockat Addresses.
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
@ RAW_TCP
Definition: typedefs.hpp:30
@ RAW_UDP
Definition: typedefs.hpp:30
@ SSL_TCP
Definition: typedefs.hpp:30
@ RAW_UNIX
Definition: typedefs.hpp:30
@ SSL_UNIX
Definition: typedefs.hpp:30
@ HTTP_TCP
Definition: typedefs.hpp:30

References CAListenerInterface(), E_SUCCESS, getDOMChildByName(), getDOMElementAttribute(), getDOMElementValue(), HTTP_TCP, m_bHidden, m_bVirtual, m_pAddr, m_strHostname, m_Type, RAW_TCP, RAW_UDP, RAW_UNIX, SSL_TCP, SSL_UNIX, and strtrim().

Referenced by getInstance(), CACmdLnOptions::parse(), CACmdLnOptions::parseInfoServices(), CACmdLnOptions::setInfoServices(), and CACmdLnOptions::setListenerInterfaces().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstance() [2/4]

CAListenerInterface ** CAListenerInterface::getInstance ( DOMElement *  a_elemListenerInterfaces,
UINT32 r_length 
)
static

Definition at line 121 of file CAListenerInterface.cpp.

123 {
124  CAListenerInterface** interfaces = NULL;
125  if(a_elemListenerInterfaces!=NULL)
126  {
127  DOMNodeList* nlListenerInterfaces =
129  r_length=nlListenerInterfaces->getLength();
130  if(r_length>0)
131  {
132  interfaces=new CAListenerInterface*[r_length];
133  UINT32 aktInterface=0;
134  for(UINT32 i=0;i<r_length;i++)
135  {
136  DOMNode* elemListenerInterface;
137  elemListenerInterface=nlListenerInterfaces->item(i);
138  CAListenerInterface* pListener=CAListenerInterface::getInstance(elemListenerInterface);
139  if(pListener!=NULL)
140  {
141  interfaces[aktInterface++]=pListener;
142  }
143  }
144  r_length=aktInterface;
145  }
146  }
147  else
148  {
149  r_length = 0;
150  interfaces=NULL;
151  }
152 
153  return interfaces;
154 }
DOMNodeList * getElementsByTagName(DOMElement *pElem, const char *const name)
Definition: CAUtil.cpp:1711
static const char * XML_ELEMENT_NAME
static CAListenerInterface * getInstance(const DOMNode *node)

References getElementsByTagName(), getInstance(), and XML_ELEMENT_NAME.

Here is the call graph for this function:

◆ getInstance() [3/4]

CAListenerInterface * CAListenerInterface::getInstance ( NetworkType  type,
const UINT8 hostnameOrIP,
UINT16  port 
)
static

Definition at line 75 of file CAListenerInterface.cpp.

76  {
77  if( (type!=RAW_TCP&&type!=SSL_TCP&&type!=RAW_UDP))
78  return NULL;
80  pListener->m_Type=type;
81  pListener->m_pAddr=new CASocketAddrINet();
82  if(((CASocketAddrINet*)pListener->m_pAddr)->setAddr(hostnameOrIP,port)!=E_SUCCESS)
83  {
84  delete pListener;
85  pListener=NULL;
86  }
87  return pListener;
88  }
UINT8 type
Definition: typedefs.hpp:1

References CAListenerInterface(), E_SUCCESS, m_pAddr, m_Type, RAW_TCP, RAW_UDP, SSL_TCP, and type.

Here is the call graph for this function:

◆ getInstance() [4/4]

CAListenerInterface * CAListenerInterface::getInstance ( NetworkType  type,
const UINT8 path 
)
static

Definition at line 59 of file CAListenerInterface.cpp.

60  {
61  #ifdef HAVE_UNIX_DOMAIN_PROTOCOL
62  if( (type!=RAW_UNIX&&type!=SSL_UNIX)||
63  file==NULL)
64  return NULL;
66  pListener->m_Type=type;
67  pListener->m_pAddr=new CASocketAddrUnix();
68  ((CASocketAddrUnix*)pListener->m_pAddr)->setPath((const char*)file);
69  return pListener;
70  #else
71  return NULL;
72  #endif
73  }

References CAListenerInterface(), m_pAddr, m_Type, RAW_UNIX, SSL_UNIX, and type.

Here is the call graph for this function:

◆ getType()

NetworkType CAListenerInterface::getType ( ) const
inline

Definition at line 41 of file CAListenerInterface.hpp.

42  {
43  return m_Type;
44  }

References m_Type.

Referenced by CAMix::initMixCascadeInfo().

Here is the caller graph for this function:

◆ isHidden()

bool CAListenerInterface::isHidden ( ) const
inline

Definition at line 52 of file CAListenerInterface.hpp.

53  {
54  return m_bHidden;
55  }

References m_bHidden.

Referenced by CACmdLnOptions::createSockets(), and CAMix::initMixCascadeInfo().

Here is the caller graph for this function:

◆ isVirtual()

bool CAListenerInterface::isVirtual ( ) const
inline

Definition at line 56 of file CAListenerInterface.hpp.

57  {
58  return m_bVirtual;
59  }

References m_bVirtual.

Referenced by CACmdLnOptions::createSockets(), CALastMix::init(), CAMiddleMix::init(), and CAFirstMix::initOnce().

Here is the caller graph for this function:

◆ operator=()

CAListenerInterface& CAListenerInterface::operator= ( const CAListenerInterface )

◆ toDOMElement()

SINT32 CAListenerInterface::toDOMElement ( DOMElement *&  elem,
XERCES_CPP_NAMESPACE::DOMDocument *  ownerDoc 
) const

Definition at line 91 of file CAListenerInterface.cpp.

92  {
93  elemListenerInterface=createDOMElement(ownerDoc,"ListenerInterface");
94  DOMElement* elem=createDOMElement(ownerDoc,"Type");
95  elemListenerInterface->appendChild(elem);
96  if(m_Type==RAW_TCP)
97  setDOMElementValue(elem,(UINT8*)"RAW/TCP");
98  else if (m_Type == RAW_UDP)
99  setDOMElementValue(elem, (UINT8*)"RAW/UDP");
100  elem=createDOMElement(ownerDoc,"Port");
101  elemListenerInterface->appendChild(elem);
102  UINT32 port=((CASocketAddrINet*)m_pAddr)->getPort();
103  setDOMElementValue(elem,port);
104  elem=createDOMElement(ownerDoc,"Host");
105  elemListenerInterface->appendChild(elem);
106  UINT8 ip[50];
107  if(m_strHostname!=NULL)
109  else
110  {
111  ((CASocketAddrINet*)m_pAddr)->getIPAsStr(ip,50);
112  setDOMElementValue(elem,ip);
113  }
114  elem=createDOMElement(ownerDoc,"IP");
115  elemListenerInterface->appendChild(elem);
116  ((CASocketAddrINet*)m_pAddr)->getIPAsStr(ip,50);
117  setDOMElementValue(elem,ip);
118  return E_SUCCESS;
119  }
SINT32 setDOMElementValue(DOMElement *pElem, SINT32 value)
Definition: CAUtil.cpp:939
DOMElement * createDOMElement(XERCES_CPP_NAMESPACE::DOMDocument *pOwnerDoc, const char *const name)
Creates a new DOMElement with the given name which belongs to the DOMDocument owernDoc.
Definition: CAUtil.cpp:814

References createDOMElement(), E_SUCCESS, m_pAddr, m_strHostname, m_Type, RAW_TCP, RAW_UDP, and setDOMElementValue().

Referenced by CAMix::initMixCascadeInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_bHidden

bool CAListenerInterface::m_bHidden
private

Definition at line 71 of file CAListenerInterface.hpp.

Referenced by CAListenerInterface(), getInstance(), and isHidden().

◆ m_bVirtual

bool CAListenerInterface::m_bVirtual
private

Definition at line 72 of file CAListenerInterface.hpp.

Referenced by CAListenerInterface(), getInstance(), and isVirtual().

◆ m_pAddr

CASocketAddr* CAListenerInterface::m_pAddr
private

◆ m_strHostname

UINT8* CAListenerInterface::m_strHostname
private

◆ m_Type

NetworkType CAListenerInterface::m_Type
private

Definition at line 70 of file CAListenerInterface.hpp.

Referenced by CAListenerInterface(), getInstance(), getType(), and toDOMElement().

◆ XML_ELEMENT_CONTAINER_NAME

const char * CAListenerInterface::XML_ELEMENT_CONTAINER_NAME = "ListenerInterfaces"
static

Definition at line 63 of file CAListenerInterface.hpp.

Referenced by CACmdLnOptions::parseInfoServices().

◆ XML_ELEMENT_NAME

const char * CAListenerInterface::XML_ELEMENT_NAME = "ListenerInterface"
static

Definition at line 64 of file CAListenerInterface.hpp.

Referenced by getInstance().


The documentation for this class was generated from the following files: