Skip to content

Commit

Permalink
More replace vp->lvalue with vp->vp_*
Browse files Browse the repository at this point in the history
  • Loading branch information
aland committed Apr 17, 2007
1 parent bded7b6 commit 1b26bbb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/main/acct.c
Expand Up @@ -80,7 +80,7 @@ int rad_accounting(REQUEST *request)
vp = pairfind(request->config_items, PW_ACCT_TYPE);
if (vp) {
DEBUG2(" Found Acct-Type %s", vp->vp_strvalue);
acct_type = vp->lvalue;
acct_type = vp->vp_integer;
}
result = module_accounting(acct_type, request);
switch (result) {
Expand Down
28 changes: 14 additions & 14 deletions src/main/auth.c
Expand Up @@ -43,7 +43,7 @@ char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli) {
if ((cli = pairfind(request->packet->vps, PW_CALLING_STATION_ID)) == NULL)
do_cli = 0;
if ((pair = pairfind(request->packet->vps, PW_NAS_PORT)) != NULL)
port = pair->lvalue;
port = pair->vp_integer;

snprintf(buf, buflen, "from client %.128s port %u%s%.128s",
client_name_old(&request->packet->src_ipaddr), port,
Expand Down Expand Up @@ -162,7 +162,7 @@ static int rad_check_password(REQUEST *request)
*/
cur_config_item = request->config_items;
while(((auth_type_pair = pairfind(cur_config_item, PW_AUTH_TYPE))) != NULL) {
auth_type = auth_type_pair->lvalue;
auth_type = auth_type_pair->vp_integer;
auth_type_count++;

DEBUG2(" rad_check_password: Found Auth-Type %s",
Expand Down Expand Up @@ -394,7 +394,7 @@ int rad_postauth(REQUEST *request)
vp = pairfind(request->config_items, PW_POST_AUTH_TYPE);
if (vp) {
DEBUG2(" Found Post-Auth-Type %s", vp->vp_strvalue);
postauth_type = vp->lvalue;
postauth_type = vp->vp_integer;
}
result = module_post_auth(postauth_type, request);
switch (result) {
Expand Down Expand Up @@ -467,7 +467,7 @@ int rad_authenticate(REQUEST *request)
radlog(L_ERR|L_CONS, "Not enough memory");
exit(1);
}
tmp->lvalue = PW_AUTHTYPE_ACCEPT;
tmp->vp_integer = PW_AUTHTYPE_ACCEPT;
pairadd(&request->config_items, tmp);
break;
/*
Expand Down Expand Up @@ -567,7 +567,7 @@ int rad_authenticate(REQUEST *request)
tmp = pairfind(request->config_items, PW_AUTZ_TYPE);
if (tmp) {
DEBUG2(" Found Autz-Type %s", tmp->vp_strvalue);
autz_type = tmp->lvalue;
autz_type = tmp->vp_integer;
autz_retry = 1;
goto autz_redo;
}
Expand Down Expand Up @@ -659,32 +659,32 @@ int rad_authenticate(REQUEST *request)
tmp = pairfind(request->config_items, PW_SESSION_TYPE);
if (tmp) {
DEBUG2(" Found Session-Type %s", tmp->vp_strvalue);
session_type = tmp->lvalue;
session_type = tmp->vp_integer;
}

/*
* User authenticated O.K. Now we have to check
* for the Simultaneous-Use parameter.
*/
if (namepair &&
(r = module_checksimul(session_type, request, check_item->lvalue)) != 0) {
(r = module_checksimul(session_type, request, check_item->vp_integer)) != 0) {
char mpp_ok = 0;

if (r == 2){
/* Multilink attempt. Check if port-limit > simultaneous-use */
VALUE_PAIR *port_limit;

if ((port_limit = pairfind(request->reply->vps, PW_PORT_LIMIT)) != NULL &&
port_limit->lvalue > check_item->lvalue){
port_limit->vp_integer > check_item->vp_integer){
DEBUG2("main auth: MPP is OK");
mpp_ok = 1;
}
}
if (!mpp_ok){
if (check_item->lvalue > 1) {
if (check_item->vp_integer > 1) {
snprintf(umsg, sizeof(umsg),
"\r\nYou are already logged in %d times - access denied\r\n\n",
(int)check_item->lvalue);
(int)check_item->vp_integer);
user_msg = umsg;
} else {
user_msg = "\r\nYou are already logged in - access denied\r\n\n";
Expand All @@ -701,7 +701,7 @@ int rad_authenticate(REQUEST *request)
request->reply->vps = tmp;

snprintf(logstr, sizeof(logstr), "Multiple logins (max %d) %s",
check_item->lvalue,
check_item->vp_integer,
r == 2 ? "[MPP attempt]" : "");
rad_authlog(logstr, request, 1);

Expand Down Expand Up @@ -741,10 +741,10 @@ int rad_authenticate(REQUEST *request)
*/
if ((vpPortId = pairfind(request->packet->vps,
PW_NAS_PORT)) != NULL) {
unsigned long tvalue = ntohl(tmp->lvalue);
tmp->lvalue = htonl(tvalue + vpPortId->lvalue);
unsigned long tvalue = ntohl(tmp->vp_integer);
tmp->vp_integer = htonl(tvalue + vpPortId->vp_integer);
tmp->flags.addport = 0;
ip_ntoa(tmp->vp_strvalue, tmp->lvalue);
ip_ntoa(tmp->vp_strvalue, tmp->vp_integer);
} else {
DEBUG2("WARNING: No NAS-Port attribute in request. CANNOT return a Framed-IP-Address + NAS-Port.\n");
pairdelete(&request->reply->vps, PW_FRAMED_IP_ADDRESS);
Expand Down
18 changes: 8 additions & 10 deletions src/main/event.c
Expand Up @@ -97,8 +97,6 @@ static void snmp_inc_client_responses(RADCLIENT *client,
{
if (!mainconfig.do_snmp) return;

if (!client) return;

/*
* Update the SNMP statistics.
*
Expand All @@ -111,24 +109,24 @@ static void snmp_inc_client_responses(RADCLIENT *client,
case PW_AUTHENTICATION_ACK:
rad_snmp.auth.total_responses++;
rad_snmp.auth.total_access_accepts++;
client->auth->accepts++;
if (client) client->auth->accepts++;
break;

case PW_AUTHENTICATION_REJECT:
rad_snmp.auth.total_responses++;
rad_snmp.auth.total_access_rejects++;
client->auth->rejects++;
if (client) client->auth->rejects++;
break;

case PW_ACCESS_CHALLENGE:
rad_snmp.auth.total_responses++;
rad_snmp.auth.total_access_challenges++;
client->auth->challenges++;
if (client) client->auth->challenges++;
break;

case PW_ACCOUNTING_RESPONSE:
rad_snmp.acct.total_responses++;
client->auth->responses++;
if (client) client->auth->responses++;
break;

/*
Expand All @@ -138,7 +136,7 @@ static void snmp_inc_client_responses(RADCLIENT *client,
case 0:
if (request->packet->code == PW_AUTHENTICATION_REQUEST) {
rad_snmp.auth.total_bad_authenticators++;
client->auth->bad_authenticators++;
if (client) client->auth->bad_authenticators++;
}
break;

Expand Down Expand Up @@ -875,7 +873,7 @@ static int request_pre_handler(REQUEST *request)
vp = pairfind(request->config_items, PW_POST_PROXY_TYPE);
if (vp) {
DEBUG2(" Found Post-Proxy-Type %s", vp->vp_strvalue);
post_proxy_type = vp->lvalue;
post_proxy_type = vp->vp_integer;
}
rcode = module_post_proxy(post_proxy_type, request);

Expand Down Expand Up @@ -1135,7 +1133,7 @@ static int successfully_proxied_request(REQUEST *request)
vp = pairfind(request->config_items, PW_PRE_PROXY_TYPE);
if (vp) {
DEBUG2(" Found Pre-Proxy-Type %s", vp->vp_strvalue);
pre_proxy_type = vp->lvalue;
pre_proxy_type = vp->vp_integer;
}
rcode = module_pre_proxy(pre_proxy_type, request);
switch (rcode) {
Expand Down Expand Up @@ -1235,7 +1233,7 @@ static void request_post_handler(REQUEST *request)

if ((request->reply->code == 0) &&
((vp = pairfind(request->config_items, PW_AUTH_TYPE)) != NULL) &&
(vp->lvalue == PW_AUTHTYPE_REJECT)) {
(vp->vp_integer == PW_AUTHTYPE_REJECT)) {
request->reply->code = PW_AUTHENTICATION_REJECT;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/listen.c
Expand Up @@ -1008,7 +1008,7 @@ static int detail_recv(rad_listen_t *listener,
rad_assert(vp != NULL);
}
if (data->timestamp != 0) {
vp->lvalue += time(NULL) - data->timestamp;
vp->vp_integer += time(NULL) - data->timestamp;
}

/*
Expand All @@ -1022,7 +1022,7 @@ static int detail_recv(rad_listen_t *listener,
vp = pairfind(packet->vps, PW_PACKET_SRC_IP_ADDRESS);
if (vp) {
packet->src_ipaddr.af = AF_INET;
packet->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
packet->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
} else {
vp = pairfind(packet->vps, PW_PACKET_SRC_IPV6_ADDRESS);
if (vp) {
Expand All @@ -1035,7 +1035,7 @@ static int detail_recv(rad_listen_t *listener,
vp = pairfind(packet->vps, PW_PACKET_DST_IP_ADDRESS);
if (vp) {
packet->dst_ipaddr.af = AF_INET;
packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
} else {
vp = pairfind(packet->vps, PW_PACKET_DST_IPV6_ADDRESS);
if (vp) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/radclient.c
Expand Up @@ -230,16 +230,16 @@ static radclient_t *radclient_init(const char *filename)
* the attributes read from the file.
*/
case PW_PACKET_TYPE:
radclient->request->code = vp->lvalue;
radclient->request->code = vp->vp_integer;
break;

case PW_PACKET_DST_PORT:
radclient->request->dst_port = (vp->lvalue & 0xffff);
radclient->request->dst_port = (vp->vp_integer & 0xffff);
break;

case PW_PACKET_DST_IP_ADDRESS:
radclient->request->dst_ipaddr.af = AF_INET;
radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
break;

case PW_PACKET_DST_IPV6_ADDRESS:
Expand All @@ -248,12 +248,12 @@ static radclient_t *radclient_init(const char *filename)
break;

case PW_PACKET_SRC_PORT:
radclient->request->src_port = (vp->lvalue & 0xffff);
radclient->request->src_port = (vp->vp_integer & 0xffff);
break;

case PW_PACKET_SRC_IP_ADDRESS:
radclient->request->src_ipaddr.af = AF_INET;
radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
break;

case PW_PACKET_SRC_IPV6_ADDRESS:
Expand Down
7 changes: 4 additions & 3 deletions src/main/session.c
Expand Up @@ -26,8 +26,9 @@ RCSID("$Id$")
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>

#include <signal.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif

/*
* End a session by faking a Stop packet to all accounting modules.
Expand Down Expand Up @@ -55,8 +56,8 @@ int session_zap(REQUEST *request, uint32_t nasaddr, unsigned int port,
vp->e = v; \
pairadd(&(stopreq->packet->vps), vp); \
} while(0)
#define INTPAIR(n,v) PAIR(n,v,PW_TYPE_INTEGER,lvalue)
#define IPPAIR(n,v) PAIR(n,v,PW_TYPE_IPADDR,lvalue)
#define INTPAIR(n,v) PAIR(n,v,PW_TYPE_INTEGER,vp_integer)
#define IPPAIR(n,v) PAIR(n,v,PW_TYPE_IPADDR,vp_ipaddr)
#define STRINGPAIR(n,v) do { \
if(!(vp = paircreate(n, PW_TYPE_STRING))) { \
radlog(L_ERR|L_CONS, "no memory"); \
Expand Down
6 changes: 5 additions & 1 deletion src/main/valuepair.c
Expand Up @@ -189,9 +189,13 @@ int radius_compare_vps(REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
(char *)check->vp_strvalue);
}
break;
case PW_TYPE_BYTE:
case PW_TYPE_SHORT:
case PW_TYPE_INTEGER:
ret = vp->vp_integer - check->vp_integer;
break;
case PW_TYPE_DATE:
ret = vp->lvalue - check->lvalue;
ret = vp->vp_date - check->vp_date;
break;
case PW_TYPE_IPADDR:
ret = ntohl(vp->vp_ipaddr) - ntohl(check->vp_ipaddr);
Expand Down
8 changes: 4 additions & 4 deletions src/main/xlat.c
Expand Up @@ -255,25 +255,25 @@ static int xlat_packet(void *instance, REQUEST *request,
return 0;
}
localvp.attribute = da->attr;
localvp.lvalue = packet->src_ipaddr.ipaddr.ip4addr.s_addr;
localvp.vp_ipaddr = packet->src_ipaddr.ipaddr.ip4addr.s_addr;
break;

case PW_PACKET_DST_IP_ADDRESS:
if (packet->dst_ipaddr.af != AF_INET) {
return 0;
}
localvp.attribute = da->attr;
localvp.lvalue = packet->dst_ipaddr.ipaddr.ip4addr.s_addr;
localvp.vp_ipaddr = packet->dst_ipaddr.ipaddr.ip4addr.s_addr;
break;

case PW_PACKET_SRC_PORT:
localvp.attribute = da->attr;
localvp.lvalue = packet->src_port;
localvp.vp_integer = packet->src_port;
break;

case PW_PACKET_DST_PORT:
localvp.attribute = da->attr;
localvp.lvalue = packet->dst_port;
localvp.vp_integer = packet->dst_port;
break;

case PW_PACKET_AUTHENTICATION_VECTOR:
Expand Down

0 comments on commit 1b26bbb

Please sign in to comment.