Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bind to the same address as NAS-IP-Address, instead of 0.0.0.0

  • Loading branch information...
commit 6be5acbd51324d4bff2ec69c09499edc0c8e0672 1 parent 0eb07ac
Vadim Schetinin authored committed
View
12 RadiusClass/RadiusPacket.cpp
@@ -383,7 +383,7 @@ int RadiusPacket::unShapeRadiusPacket(void)
* @return Returns the number of bytes successfully sent,
* SOCKET_ERROR or UNKNOWN_HOST in case of error.
*/
-int RadiusPacket::radiusSend(list<RadiusServer>::iterator server)
+int RadiusPacket::radiusSend( list<RadiusServer>::iterator server, const char * bind_ip )
{
int socket2Radius;
@@ -436,9 +436,9 @@ int RadiusPacket::radiusSend(list<RadiusServer>::iterator server)
}
// Bind any port
- cliAddr.sin_family=AF_INET;
- cliAddr.sin_addr.s_addr=htonl(INADDR_ANY);
- cliAddr.sin_port=htons(0);
+ cliAddr.sin_family = AF_INET;
+ cliAddr.sin_addr.s_addr = inet_addr( bind_ip );
+ cliAddr.sin_port = htons(0);
//Bind the socket port,
if(bind(socket2Radius,(struct sockaddr*)&cliAddr,sizeof(struct sockaddr))<0)
@@ -464,7 +464,7 @@ int RadiusPacket::radiusSend(list<RadiusServer>::iterator server)
* @param serverlist : A list of radius server.
* @return Returns 0 if everything is ok, else ALLOC_ERROR, UNKNOWN_HOST, WRONG_AUTHENTICATOR_IN_RECV_PACKET or NO_RESPONSE in case of error.
*/
-int RadiusPacket::radiusReceive(list<RadiusServer> *serverlist)
+int RadiusPacket::radiusReceive( list<RadiusServer> *serverlist, const char * bind_ip )
{
list<RadiusServer>::iterator server;
@@ -541,7 +541,7 @@ int RadiusPacket::radiusReceive(list<RadiusServer> *serverlist)
//the server retries
if(retries <= server->getRetry())
{
- this->radiusSend(server);
+ this->radiusSend( server, bind_ip );
}
}
retries++;
View
4 RadiusClass/RadiusPacket.h
@@ -93,8 +93,8 @@ class RadiusPacket
void dumpRadiusPacket(void);
void dumpShapedRadiusPacket(void);
- int radiusSend(list<RadiusServer>::iterator);
- int radiusReceive(list<RadiusServer> *);
+ int radiusSend( list<RadiusServer>::iterator, const char * bind_ip );
+ int radiusReceive( list<RadiusServer> *, const char * bind_ip );
int getRadiusAttribNumber(void);
char * getAuthenticator(void);
View
12 UserAcct.cpp
@@ -197,13 +197,13 @@ int UserAcct::sendUpdatePacket(PluginContext *context)
}
//send the packet to the server
- if (packet.radiusSend(server)<0)
+ if (packet.radiusSend( server, context->radiusconf.getNASIpAddress() )<0)
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND-ACCT: Packet was not send.\n";
}
//get the response
- if (packet.radiusReceive(serverlist)>=0)
+ if (packet.radiusReceive(serverlist, context->radiusconf.getNASIpAddress() )>=0)
{
//is the packet a ACCOUNTING_RESPONSE?
if(packet.getCode()==ACCOUNTING_RESPONSE)
@@ -344,13 +344,13 @@ int UserAcct::sendStartPacket(PluginContext * context)
}
//send the packet
- if (packet.radiusSend(server)<0)
+ if (packet.radiusSend( server, context->radiusconf.getNASIpAddress() )<0)
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND-ACCT: Packet was not send.\n";
}
//receive the response
- if (packet.radiusReceive(serverlist)>=0)
+ if (packet.radiusReceive(serverlist, context->radiusconf.getNASIpAddress() )>=0)
{
//is is a accounting resopnse ?
if(packet.getCode()==ACCOUNTING_RESPONSE)
@@ -526,13 +526,13 @@ int UserAcct::sendStopPacket(PluginContext * context)
}
//send the packet
- if (packet.radiusSend(server)<0)
+ if (packet.radiusSend( server, context->radiusconf.getNASIpAddress() )<0)
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND-ACCT: Packet was not send.\n";
}
//get the response
- if (packet.radiusReceive(serverlist)>=0)
+ if (packet.radiusReceive(serverlist, context->radiusconf.getNASIpAddress() )>=0)
{
//is it an accounting response
if(packet.getCode()==ACCOUNTING_RESPONSE)
View
4 UserAuth.cpp
@@ -145,12 +145,12 @@ int UserAuth::sendAcceptRequestPacket(PluginContext * context)
if (DEBUG (context->getVerbosity()))
cerr << getTime() << "RADIUS-PLUGIN: Send packet to " << server->getName().c_str() <<".\n";
//send the packet
- if (packet.radiusSend(server)<0)
+ if (packet.radiusSend( server, context->radiusconf.getNASIpAddress() )<0)
{
cerr << getTime() << "RADIUS-PLUGIN: Packet was not send.\n";
}
//receive the packet
- if (packet.radiusReceive(serverlist)==0)
+ if (packet.radiusReceive(serverlist, context->radiusconf.getNASIpAddress() )==0)
{
//is it a accept?
if(packet.getCode()==ACCESS_ACCEPT)
Please sign in to comment.
Something went wrong with that request. Please try again.