radius: corrected the byte ordering of NAS_IP_ADDRESS

This commit is contained in:
Nikos Mavrogiannopoulos
2015-05-11 14:26:49 +02:00
parent 43d174980d
commit 9a05edd2ec
2 changed files with 14 additions and 10 deletions
+7 -5
View File
@@ -121,12 +121,14 @@ static void append_acct_standard(rc_handle *rh, const common_auth_info_st *ai, V
}
if (ai->our_ip[0] != 0) {
struct sockaddr_storage st;
struct in_addr in;
struct in6_addr in6;
if (inet_pton(AF_INET, ai->our_ip, &st) != 0) {
rc_avpair_add(rh, send, PW_NAS_IP_ADDRESS, (char*)&st, sizeof(struct in_addr), 0);
} else if (inet_pton(AF_INET6, ai->our_ip, &st) != 0) {
rc_avpair_add(rh, send, PW_NAS_IPV6_ADDRESS, (char*)&st, sizeof(struct in6_addr), 0);
if (inet_pton(AF_INET, ai->our_ip, &in) != 0) {
in.s_addr = ntohl(in.s_addr);
rc_avpair_add(rh, send, PW_NAS_IP_ADDRESS, (char*)&in, sizeof(struct in_addr), 0);
} else if (inet_pton(AF_INET6, ai->our_ip, &in6) != 0) {
rc_avpair_add(rh, send, PW_NAS_IPV6_ADDRESS, (char*)&in6, sizeof(struct in6_addr), 0);
}
}
+7 -5
View File
@@ -212,12 +212,14 @@ static int radius_auth_pass(void *ctx, const char *pass, unsigned pass_len)
}
if (pctx->our_ip[0] != 0) {
struct sockaddr_storage st;
struct in_addr in;
struct in6_addr in6;
if (inet_pton(AF_INET, pctx->our_ip, &st) != 0) {
rc_avpair_add(rh, &send, PW_NAS_IP_ADDRESS, (char*)&st, sizeof(struct in_addr), 0);
} else if (inet_pton(AF_INET6, pctx->our_ip, &st) != 0) {
rc_avpair_add(rh, &send, PW_NAS_IPV6_ADDRESS, (char*)&st, sizeof(struct in6_addr), 0);
if (inet_pton(AF_INET, pctx->our_ip, &in) != 0) {
in.s_addr = ntohl(in.s_addr);
rc_avpair_add(rh, &send, PW_NAS_IP_ADDRESS, (char*)&in, sizeof(struct in_addr), 0);
} else if (inet_pton(AF_INET6, pctx->our_ip, &in6) != 0) {
rc_avpair_add(rh, &send, PW_NAS_IPV6_ADDRESS, (char*)&in6, sizeof(struct in6_addr), 0);
}
}