Its so simple, but it doesn't work!

This is a discussion on Its so simple, but it doesn't work! within the FreeRADIUS Users forums, part of the Networking and Network Related category; Hi all, I was hoping someone could explain to me why this very basic radius client test program does not ...


Go Back   Usenet Forums > Networking and Network Related > FreeRADIUS Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-20-2005
Arun Mundray
 
Posts: n/a
Default Its so simple, but it doesn't work!

Hi all,

I was hoping someone could explain to me why this very basic radius client
test program does not work. It seems simple enough. Everything's fine
except, the password received by the server is always garbled. I'm using
rad_alloc to create and packet and librad_md5_calc to encrypt the vector.
Isn't that all there is to it? I'm at my wits end! What am I missing!! And
help would be very much appreciated.

regards,

Arun Mundray.

char secret[] = "smeg";
char password[] = "pig";
char username[] = "user1";
int main (int argc, char **argv)
{
int sockfd,x,i;
char *ppassword;
RADIUS_PACKET *ppacket = NULL;
VALUE_PAIR *vp1;
VALUE_PAIR *vp2;

ppacket = rad_alloc(1);
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
ppacket->sockfd = sockfd;
ppacket->src_ipaddr = 0;
ppacket->src_port = 0;
ppacket->dst_ipaddr = inet_addr("127.0.0.1");
ppacket->dst_port = 1812;

ppacket->id = getpid();
ppacket->code = PW_AUTHENTICATION_REQUEST;
ppacket->timestamp = 0;
ppacket->verified = 0; /* Not set. Returned packet*/
ppacket->data_len = 0; /* Not set. Returned packet*/
ppacket->data = NULL;

librad_md5_calc(ppacket->vector, ppacket->vector,
sizeof(ppacket->vector));

vp1 = (VALUE_PAIR *)malloc(sizeof(VALUE_PAIR));
vp2 = (VALUE_PAIR *)malloc(sizeof(VALUE_PAIR));
memset(vp1,0,sizeof(VALUE_PAIR));
memset(vp2,0,sizeof(VALUE_PAIR));

ppacket->vps = vp1;
vp1->next = vp2;
vp2->next = NULL;

strcpy(vp1->name,"User-Name");
vp1->attribute = PW_USER_NAME;
strcpy(vp1->strvalue,username);
vp1->operator = T_OP_EQ;
vp1->length = strlen(username);

strcpy(vp2->name,"User-Password");
vp2->attribute = PW_PASSWORD;
strcpy(vp2->strvalue, password);
vp2->length = strlen(password);
vp2->operator = T_OP_EQ;
rad_send(ppacket, NULL, secret);
close (ppacket->sockfd);
rad_free(&ppacket);
}




-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:54 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0