Commit 5e853fcc authored by Nigel Kukard's avatar Nigel Kukard

Renamed POD to COA and added backwards compatibility

parent 5f4abf79
...@@ -931,64 +931,76 @@ sub process_request { ...@@ -931,64 +931,76 @@ sub process_request {
# Grab packet # Grab packet
my $response = auth_resp($resp->pack, getAttributeValue($user->{'ConfigAttributes'},"SMRadius-Config-Secret")); my $response = auth_resp($resp->pack, getAttributeValue($user->{'ConfigAttributes'},"SMRadius-Config-Secret"));
# Check for POD Servers and send disconnect my $coaServer;
# Check for old POD server attribute
if (defined($user->{'ConfigAttributes'}->{'SMRadius-Config-PODServer'})) { if (defined($user->{'ConfigAttributes'}->{'SMRadius-Config-PODServer'})) {
$self->log(LOG_DEBUG,"[SMRADIUS] SMRadius-Config-PODServer is defined"); $self->log(LOG_DEBUG,"[SMRADIUS] SMRadius-Config-PODServer is defined");
$coaServer = $user->{'ConfigAttributes'}->{'SMRadius-Config-PODServer'};
}
# Check for new CoA server attribute
if (defined($user->{'ConfigAttributes'}->{'SMRadius-Config-CoAServer'})) {
$self->log(LOG_DEBUG,"[SMRADIUS] SMRadius-Config-CoAServer is defined");
$coaServer = $user->{'ConfigAttributes'}->{'SMRadius-Config-CoAServer'};
}
# Check for CoA servers
if (defined($coaServer)) {
# Check address format # Check address format
foreach my $podServerAttribute (@{$user->{'ConfigAttributes'}->{'SMRadius-Config-PODServer'}}) { foreach my $coaServerAttribute (@{$coaServer}) {
# Check for valid IP # Check for valid IP
if ($podServerAttribute =~ /^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) { if ($coaServerAttribute =~ /^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) {
my $podServer = $1; my $coaServer = $1;
# If we have a port, use it, otherwise use default 1700 # If we have a port, use it, otherwise use default 1700
my $podServerPort; my $coaServerPort;
if ($podServerAttribute =~ /:([0-9]+)$/) { if ($coaServerAttribute =~ /:([0-9]+)$/) {
$podServerPort = $1; $coaServerPort = $1;
} else { } else {
$podServerPort = 1700; $coaServerPort = 1700;
} }
$self->log(LOG_DEBUG,"[SMRADIUS] POST-ACCT: Trying PODServer => IP: '".$podServer."' Port: '".$podServerPort."'"); $self->log(LOG_DEBUG,"[SMRADIUS] POST-ACCT: Trying CoAServer => IP: '".$coaServer."' Port: '".$coaServerPort."'");
# Create socket to send packet out on # Create socket to send packet out on
my $podServerTimeout = "10"; # 10 second timeout my $coaServerTimeout = "10"; # 10 second timeout
my $podSock = IO::Socket::INET->new( my $coaSock = IO::Socket::INET->new(
PeerAddr => $podServer, PeerAddr => $coaServer,
PeerPort => $podServerPort, PeerPort => $coaServerPort,
Type => SOCK_DGRAM, Type => SOCK_DGRAM,
Proto => 'udp', Proto => 'udp',
TimeOut => $podServerTimeout, TimeOut => $coaServerTimeout,
); );
if (!$podSock) { if (!$coaSock) {
$self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to create socket to send POD on"); $self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to create socket to send POD on");
next; next;
} }
# Check if we sent the packet... # Check if we sent the packet...
if (!$podSock->send($response)) { if (!$coaSock->send($response)) {
$self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to send data on socket"); $self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to send data on socket");
next; next;
} }
# Once sent, we need to get a response back # Once sent, we need to get a response back
my $sh = IO::Select->new($podSock); my $sh = IO::Select->new($coaSock);
if (!$sh) { if (!$sh) {
$self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to select data on socket"); $self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to select data on socket");
next; next;
} }
if (!$sh->can_read($podServerTimeout)) { if (!$sh->can_read($coaServerTimeout)) {
$self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to receive data on socket"); $self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Failed to receive data on socket");
next; next;
} }
my $data; my $data;
$podSock->recv($data, 65536); $coaSock->recv($data, 65536);
if (!$data) { if (!$data) {
$self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Receive data failed"); $self->log(LOG_ERR,"[SMRADIUS] POST-ACCT: Receive data failed");
$logReason = "POD Failure"; $logReason = "CoA Failure";
} else { } else {
$logReason = "User POD"; $logReason = "User POD";
} }
...@@ -996,11 +1008,11 @@ sub process_request { ...@@ -996,11 +1008,11 @@ sub process_request {
#my @stuff = unpack('C C n a16 a*', $data); #my @stuff = unpack('C C n a16 a*', $data);
#$self->log(LOG_DEBUG,"STUFF: ".Dumper(\@stuff)); #$self->log(LOG_DEBUG,"STUFF: ".Dumper(\@stuff));
} else { } else {
$self->log(LOG_DEBUG,"[SMRADIUS] Invalid POD Server value: '".$podServerAttribute."'"); $self->log(LOG_DEBUG,"[SMRADIUS] Invalid CoA Server value: '".$coaServerAttribute."'");
} }
} }
} else { } else {
$self->log(LOG_DEBUG,"[SMRADIUS] SMRadius-Config-PODServer is not defined"); $self->log(LOG_DEBUG,"[SMRADIUS] SMRadius-Config-CoAServer is not defined");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment