rendered paste bodyint radiusrun (int **data) {
// unsigned char buffer[MAX_RADIUS_PACKET_LEN];
unsigned char *buffer = (unsigned char *) malloc(MAX_RADIUS_PACKET_LEN+1);
unsigned char *packet;
packet = buffer;
struct sockaddr_in * fromaddr;
int pfd;
int size;
fd_set set;
struct timeval timeout;
int nfd;
time_t next = 0;
char saddr[32];
pfd = create_udp_socket(radiusa_listen_port);
for (;;) {
FD_ZERO(&set);
FD_SET(pfd, &set);
do {
nfd = select(pfd + 1, &set, NULL, NULL, &timeout);
} while (nfd < 0 && errno == EINTR);
if (nfd < 0) {
error("select 1");
}
if (FD_ISSET(pfd, &set)) {
if ((size = read_packet2(pfd, buffer, fromaddr))) {
struct sockaddr_in *fin;
fin = (struct sockaddr_in *) &fromaddr;
struct in_addr sourceip = fin->sin_addr;
strcpy(saddr,inet_ntoa(sourceip));
printf ("Got radius packet from %s, port %d\n",saddr, fin->sin_port);
#ifdef DEBUG
printf("Parsing a radius packet of size: %d\n", size) ;
#endif
decode_radius_data(packet, size, data);
}
}
}
return 0 ;
}