Date: Fri, 29 Jun 2001 11:54:24 -0500 From: Pete McKenna <pmckenna@qwest.net> To: freebsd-isp@FreeBSD.ORG Cc: pmckenna@oss.uswest.net Subject: troblue with libradius genrating acct start Message-ID: <20010629115423.B49160@otto.oss.qwest.net>
next in thread | raw e-mail | index | archive | help
Is anyone out there using libradius to send accounting records? If so I'd love some pointers. I can do the auth part just fine, but when I build and send an accounting start record the radius server crabs about it being non rfc compliant. get_radrequest: non-RFC packet from 204.147.85.81[2747] - acct-req (type 4), len = 116 Hex dump at 0x0x80b2900/0 for 116 bytes 0x0x80b2900: 0x0000| 04490074 2B4C47B5 2F7D0611 75B860C5| |.I.t+LG./}..u.`.| 0x0x80b2910: 0x0010| 6DE4CC81 0406CC93 55510506 00000004| |m.......UQ......| 0x0x80b2920: 0x0020| 3D060000 00001E0C 36313233 33313536| |=.......61233156| 0x0x80b2930: 0x0030| 38361F09 36343433 30313528 06000000| |86..6443015(....| 0x0x80b2940: 0x0040| 012D0600 00000106 06000000 02060600| |.-..............| 0x0x80b2950: 0x0050| 00000A07 06000000 01290600 00000020| |.........)..... | 0x0x80b2960: 0x0060| 156F7474 6F2E6F73 732E7573 77657374| |.otto.oss.uswest| 0x0x80b2970: 0x0070| 2E6E6574 ........ ........ ........| |.net||||||||||||| The main difference I see between this packet and a valid packet is the length of the first value, the NAS_IP_ADDRESS is 6 on good packets and much longer in the libradius generated one. I'm running Merit radius 3.6B on a 4.3 FreeBSD box for the server. The Client with libradius is also 4.3 The main question is, am I formating the NAS_IP_ADDRESS correctly ? I think I'm not. Any working examples would be greatly appreciated. Pete #include <stdio.h> #include <err.h> #include <radlib.h> #include <unistd.h> static void usage() { fprintf(stderr, "%s\n", "usage: radtest -u username -p password"); exit(1); } int main(argc, argv) char **argv; { struct rad_handle *radh = rad_auth_open(); struct rad_handle *rada = rad_acct_open(); char hostname[512]; char *username,*password; /* set these */ int code; int acct; int c; in_addr_t nas_ip_addr; struct in_addr s_nas_ip; nas_ip_addr = inet_addr("204.147.85.81"); s_nas_ip.s_addr = nas_ip_addr; printf("ipaddr: %lu\n%lu\n ", nas_ip_addr, s_nas_ip ); while( (c=getopt(argc, argv, "u:p:")) != -1) switch(c) { case 'u': username = optarg; break; case 'p': password = optarg; break; default: usage() ; } if (! radh) err(1, "rad_auth_open"); if (gethostname(hostname,512) < 0) err(1, "gethostname"); if (rad_config(radh,NULL) < 0) err(1, "rad_config"); if (rad_create_request(radh, RAD_ACCESS_REQUEST) < 0) err(1, "rad_create_request"); rad_put_string(radh,RAD_USER_NAME,username); rad_put_string(radh,RAD_USER_PASSWORD,password); rad_put_string(radh,RAD_NAS_IDENTIFIER,hostname); rad_put_int(radh,RAD_SERVICE_TYPE,RAD_LOGIN); switch(code = rad_send_request(radh)) { case RAD_ACCESS_ACCEPT: puts("accepted\n"); break; case RAD_ACCESS_REJECT: puts("rejected\n"); break; case RAD_ACCESS_CHALLENGE: puts("challenged\n"); break; case RAD_ACCOUNTING_RESPONSE: puts("acct accepted ?\n"); break; default: printf("unknown: %d\n", code); } /* rad_close(radh); */ /* acct stuff */ if (! rada) err(1, "rad_acct_open"); if (gethostname(hostname,512) < 0) err(1, "gethostname"); if (rad_config(rada,NULL) < 0) err(1, "rad_config"); if (rad_create_request(rada, RAD_ACCOUNTING_REQUEST) < 0) err(1, "rad_create_request"); /* JLG */ /* rad_put_addr(rada,RAD_NAS_IP_ADDRESS,81.85.147.204); */ rad_put_addr(rada,RAD_NAS_IP_ADDRESS, s_nas_ip); rad_put_int(rada,RAD_NAS_PORT,4); rad_put_int(rada,RAD_NAS_PORT_TYPE,0); printf("port type put: \n"); /* rad_put_string(rada,RAD_USER_NAME,username);*/ printf("username put: \n"); rad_put_string(rada,RAD_CALLED_STATION_ID,"6123315686"); rad_put_string(rada,RAD_CALLING_STATION_ID,"6443015"); rad_put_int(rada,RAD_ACCT_STATUS_TYPE,1); rad_put_int(rada,RAD_ACCT_AUTHENTIC,1); rad_put_int(rada,RAD_SERVICE_TYPE,2); rad_put_int(rada,RAD_SERVICE_TYPE,00000012); rad_put_int(rada,RAD_FRAMED_PROTOCOL,1); rad_put_int(rada,RAD_ACCT_DELAY_TIME,0); rad_put_string(rada,RAD_NAS_IDENTIFIER,hostname); switch(code = rad_send_request(rada)) { case RAD_ACCOUNTING_RESPONSE: puts("acct accepted \n"); break; } /* end acct stuff */ return 0; } -- Peter McKenna Qwest Internet Solutions pmckenna@qwest.net Main 612-664-4000 FAX 612-664-4770 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010629115423.B49160>