00001 /* 00002 * This source file is part of the ace-radius library. This code was 00003 * written by Alex Agranov in 2004-2009, and is covered by the BSD open source 00004 * license. Refer to the accompanying documentation for details on usage and 00005 * license. 00006 */ 00007 00008 #ifndef _RADIUSCLIENTSTACK_H__ 00009 #define _RADIUSCLIENTSTACK_H__ 00010 00011 #include "Radius.h" 00012 #include "RadiusPacket.h" 00013 #include "RadiusAddress.h" 00014 #include "RadiusAttribute.h" 00015 #include "RadiusSecret.h" 00016 00017 #ifdef _MSC_VER 00018 #include <winsock2.h> 00019 #endif 00020 00021 class RadiusClientConnection; 00022 00023 #define D_MAX_RADIUS_CLIENT_CONNECTIONS 10 00024 00049 class RadiusClientStack 00050 { 00051 public: 00053 00060 RadiusClientStack(uint16_t p_port = 0, 00061 const char * p_hostname = NULL); 00062 00063 00065 ~RadiusClientStack(); 00066 00067 00069 bool isValid(); 00070 00071 00073 00082 int addServer(const char * p_hostname, 00083 uint16_t p_port, 00084 RadiusSecret p_secret, 00085 int p_responseTimeout = 5, 00086 int p_retransmitCount = 2); 00087 00088 00090 00105 RadiusPacket * sendPacket(RadiusPacket & p_packet); 00106 00107 00109 00112 int getNextPacketID(); 00113 00114 00115 private: 00116 00117 friend class RadiusClientConnection; 00118 00120 RadiusClientConnection * m_connections[D_MAX_RADIUS_CLIENT_CONNECTIONS]; 00121 00123 int m_connectionsNum; 00124 00126 int m_lastConnection; 00127 00129 int m_nextPacketID; 00130 00132 RadiusAddress m_clientAddress; 00133 00135 #ifdef _MSC_VER 00136 SOCKET m_socket; 00137 #else 00138 int m_socket; 00139 #endif 00140 00142 bool m_isValid; 00143 }; 00144 00145 00146 00147 #endif // _RADIUSCLIENTSTACK_H__ 00148