📄 waripaccesslist.h
字号:
/** */#ifndef WAR_IP_ACCESS_LIST_H#define WAR_IP_ACCESS_LIST_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_TYPES_H# include "WarTypes.h"#endif#ifndef WAR_EXCEPTION_H# include "WarException.h"#endif#ifndef WAR_IP_MASK_H# include "WarIpMask.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarIpAccessList {public: enum ModeE { DEFAULT_ALLOW, // Allow all, except when in list DEFAULT_DENY // Disallow all, except when in list }; // LIFECYCLE /** * Default constructor. */ WarIpAccessList(); /** * Copy constructor. * * @param from The value to copy to this object. */ WarIpAccessList(const WarIpAccessList& from); /** * Destructor. */ ~WarIpAccessList(); // OPERATORS /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarIpAccessList& operator=(const WarIpAccessList& from); // OPERATIONS /// Set the value from a string with ip[/subnet] definitions template <class charT> void SetValue(const ModeE setMode, const charT *strList) throw (WarException) { mMode = setMode; if (!strList) return; const charT *p = strList; while(*p) { // Get next token while(*p && !isdigit(*p)) ++p; WarIpMask new_mask; new_mask = p; mIpList.insert(new_mask); // Skip this token while(*p && (';' != *p)) ++p; } } // CALLBACK // ACCESS // INQUIRY template <class charT> void GetStrList(std::basic_string<charT>& retStr) const { int index; retStr.erase(); for(war_ip_mask_set_t::const_iterator P = mIpList.begin() ; P != mIpList.end() ; ++P) { if (!retStr.empty()) retStr += ';'; unsigned char *pbyte = (unsigned char *)&(P->mIpAddress); for(index = 0; index < 4; index++, ++pbyte) { WarItoa(retStr, *pbyte); if (index < 3) retStr += '.'; } if (P->mIpMask.s_addr != 0xffffffff) { retStr += '/'; pbyte = (unsigned char *)&(P->mIpMask); for(index = 0; index < 4; index++, ++pbyte) { WarItoa(retStr, *pbyte); if (index < 3) retStr += '.'; } } } } bool IsAllowed(const struct in_addr& hostAddr) const; // PROPERTIES ModeE mMode; war_ip_mask_set_t mIpList;protected:private:};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_IP_ACCESS_LIST_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -