All pastes #120757 Raw Edit

Something

public text v1 · immutable
·published 2006-08-07 15:19 UTC
rendered paste body
int radiusrun (int **data) {
    // unsigned char buffer[MAX_RADIUS_PACKET_LEN];
    unsigned char *buffer = (unsigned char *) malloc(MAX_RADIUS_PACKET_LEN+1);
    struct sockaddr_in *fromaddr;
    int  pfd;
    int  size;
    fd_set set;
    struct timeval timeout;
    int nfd;
    time_t next = 0;
    char saddr[32];

    timeout.tv_sec = 1;
    timeout.tv_usec = 0 ;

    pfd = create_udp_socket(radiusa_listen_port);

    if( pfd < 0 ) {
       printf("create socket failed %s\n", strerro(errno) ) ;
       return -1 ;
    }

    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)))  {
 
                printf ("Got radius packet from %s, port %d\n", inet_ntoa(fromaddr->sin_addr, fin->sin_port);
#ifdef DEBUG
                printf("Parsing a radius packet of size: %d\n", size) ;
#endif
                decode_radius_data(packet, size, data);
            }
        }
    }
    return 0 ;
}