Change NAS-IP-Address

Patrick Kowalik patrick at shoogee.com
Tue Mar 12 07:57:48 CET 2013


Hello everybody,
for my Case I needed to change one Octett of my NAS-IP-Address ( like 
from x.x.4.x to x.x.5.x )!
I don't really found an function to change only one octett from the 
NAS-IP-Address, so I did it with Bit-Shifting ;)
You could use the following Code Snipet in an C or C++ Module


My Code looks so:

VALUE_PAIR *vp;
vp = pairfind(request->packet->vps,1);
while(vp)
{
     // Default Operations to Change the NAS-IP-Addres on certain value
     // if (...)
     ...
     VALUE_PAIR *state;
     state = pairfind(request->packet->vps, 4);
     if(state != NULL)
     {
         int octett = 77;
         struct in_addr addr;
         addr.s_addr =    ((octett << 16) | (state->vp_ipaddr & 
0xff00ffff))        // Change the third octett from the NAS-IP-Address to 77
         state->data.ipaddr = addr;
     }
{

Greetz
Patrick


More information about the Freeradius-Devel mailing list