Question

if (rc_avpair_add(rh, &send, PW_USER_PASSWORD, passwd, -1, 0) == NULL)
                return ERROR_RC;

        if (rc_avpair_add(rh, &send, PW_NAS_PORT_TYPE, nas_port_type, -1, 0) == NULL)
                return ERROR_RC;

        if (rc_avpair_add(rh, &send, PW_FRAMED_IP_ADDRESS,"172.17.14.90", -1, 0) == NULL)
                return ERROR_RC;

above is my part of code "radexample.c Which used for generating a " radius request" I want to pass Framed IP with it also. my issue is here PW_USER_PASSWORD sends the correct value as it is a "string" type. but PW_FRAMED_IP_ADDRESS sends wrong value as its type is "ip" and I am sending string value.. If I pass "ip" in forth arg. rc_avpair_add gives error of type conversion !!

Was it helpful?

Solution

PW_FRAMED_IP_ADDRESS wants an int for the fourth argument.

The easiest method is:

uint32_t framed_addr = 0;
inet_pton(AF_INET, "172.17.14.90", &framed_addr);
framed_addr = htonl(framed_addr); //network order
if (rc_avpair_add(rh, &send, PW_FRAMED_IP_ADDRESS,&framed_addr, -1, 0) == NULL)
            return ERROR_RC;

OTHER TIPS

I'm not sure, but Framed-IP-Address is not string attribute. Here is more detail. Maybe

unsigned int ip=(unsigned int)inet_addr("172.17.14.90");
if (rc_avpair_add(rh, &send, PW_FRAMED_IP_ADDRESS, &ip, sizeof(ip), 0) == NULL)

helps you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top