문제

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 !!

도움이 되었습니까?

해결책

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;

다른 팁

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top