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

#include <CAIPAddrWithNetmask.hpp>

Collaboration diagram for CAIPAddrWithNetmask:

Public Member Functions

 CAIPAddrWithNetmask ()
 
 CAIPAddrWithNetmask (const UINT8 *strIPAddr, const UINT8 *strNetmask)
 
 ~CAIPAddrWithNetmask (void)
 
SINT32 setAddr (const UINT8 *strIPAddr)
 
SINT32 setNetmask (const UINT8 *strNetmask)
 
bool equals (UINT32 nIPAddr) const
 
bool equals (const UINT8 *pIPAddr) const
 
SINT32 toString (UINT8 *buff, UINT32 *buffLen)
 

Private Attributes

UINT32 m_nIPAddr
 
UINT32 m_nNetmask
 
UINT32 m_nIPAddrAndNetmask
 

Detailed Description

Definition at line 29 of file CAIPAddrWithNetmask.hpp.

Constructor & Destructor Documentation

◆ CAIPAddrWithNetmask() [1/2]

CAIPAddrWithNetmask::CAIPAddrWithNetmask ( )
inline

Definition at line 32 of file CAIPAddrWithNetmask.hpp.

33  {
34  m_nIPAddr=0;
35  m_nNetmask=0xFFFFFFFF;
37  }

References m_nIPAddr, m_nIPAddrAndNetmask, and m_nNetmask.

◆ CAIPAddrWithNetmask() [2/2]

CAIPAddrWithNetmask::CAIPAddrWithNetmask ( const UINT8 strIPAddr,
const UINT8 strNetmask 
)
inline

Definition at line 39 of file CAIPAddrWithNetmask.hpp.

40  {
41  m_nIPAddr=htonl(inet_addr((const char*)strIPAddr));
42  m_nNetmask=htonl(inet_addr((const char*)strNetmask));
44  }

References m_nIPAddr, m_nIPAddrAndNetmask, and m_nNetmask.

◆ ~CAIPAddrWithNetmask()

CAIPAddrWithNetmask::~CAIPAddrWithNetmask ( void  )

Definition at line 32 of file CAIPAddrWithNetmask.cpp.

33  {
34  }

Member Function Documentation

◆ equals() [1/2]

bool CAIPAddrWithNetmask::equals ( const UINT8 pIPAddr) const
inline

Definition at line 68 of file CAIPAddrWithNetmask.hpp.

69  {
70  UINT32 nIPAddr=pIPAddr[0];
71  nIPAddr<<=8;
72  nIPAddr|=pIPAddr[1];
73  nIPAddr<<=8;
74  nIPAddr|=pIPAddr[2];
75  nIPAddr<<=8;
76  nIPAddr|=pIPAddr[3];
77  return m_nIPAddrAndNetmask==(nIPAddr&m_nNetmask);
78  }
unsigned int UINT32
Definition: basetypedefs.h:131

References m_nIPAddrAndNetmask, and m_nNetmask.

◆ equals() [2/2]

bool CAIPAddrWithNetmask::equals ( UINT32  nIPAddr) const
inline

Definition at line 63 of file CAIPAddrWithNetmask.hpp.

64  {
65  return m_nIPAddrAndNetmask==(nIPAddr&m_nNetmask);
66  }

References m_nIPAddrAndNetmask, and m_nNetmask.

◆ setAddr()

SINT32 CAIPAddrWithNetmask::setAddr ( const UINT8 strIPAddr)
inline

Definition at line 48 of file CAIPAddrWithNetmask.hpp.

49  {
50  m_nIPAddr=htonl(inet_addr((const char*)strIPAddr));
52  return E_SUCCESS;
53  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2

References E_SUCCESS, m_nIPAddr, m_nIPAddrAndNetmask, and m_nNetmask.

◆ setNetmask()

SINT32 CAIPAddrWithNetmask::setNetmask ( const UINT8 strNetmask)
inline

Definition at line 55 of file CAIPAddrWithNetmask.hpp.

56  {
57  m_nNetmask=htonl(inet_addr((const char*)strNetmask));
59  return E_SUCCESS;
60  }

References E_SUCCESS, m_nIPAddr, m_nIPAddrAndNetmask, and m_nNetmask.

◆ toString()

SINT32 CAIPAddrWithNetmask::toString ( UINT8 buff,
UINT32 buffLen 
)
inline

Definition at line 80 of file CAIPAddrWithNetmask.hpp.

81  {
82  UINT8 strIP[255];
83  UINT8 strNetmask[255];
84  struct in_addr addr;
85  addr.s_addr=ntohl(m_nIPAddr);
86  strcpy((char*)strIP,inet_ntoa(addr));
87  addr.s_addr=ntohl(m_nNetmask);
88  strcpy((char*)strNetmask,inet_ntoa(addr));
89  SINT32 ret=snprintf((char*)buff,*buffLen,"%s/%s",strIP,strNetmask);
90  if(ret<=0||((UINT32)ret)>=*buffLen)
91  {
92  buff[0]=0;
93  *buffLen=0;
94  return E_UNKNOWN;
95  }
96  *buffLen=ret;
97  return E_SUCCESS;
98  }
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References E_SUCCESS, E_UNKNOWN, m_nIPAddr, and m_nNetmask.

Member Data Documentation

◆ m_nIPAddr

UINT32 CAIPAddrWithNetmask::m_nIPAddr
private

Definition at line 101 of file CAIPAddrWithNetmask.hpp.

Referenced by CAIPAddrWithNetmask(), setAddr(), setNetmask(), and toString().

◆ m_nIPAddrAndNetmask

UINT32 CAIPAddrWithNetmask::m_nIPAddrAndNetmask
private

Definition at line 103 of file CAIPAddrWithNetmask.hpp.

Referenced by CAIPAddrWithNetmask(), equals(), setAddr(), and setNetmask().

◆ m_nNetmask

UINT32 CAIPAddrWithNetmask::m_nNetmask
private

Definition at line 102 of file CAIPAddrWithNetmask.hpp.

Referenced by CAIPAddrWithNetmask(), equals(), setAddr(), setNetmask(), and toString().


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