Menu

Random addresses

2011-10-26
2025-11-23
  • Andrey Terentiew

    Hello.

    I had a necessity at each connection to product casual pair

    localip-remoteip. Unfortunately, the choice of the free pair (slot)

    addresses in pptpd in conducted linearly. I have made some changes to the

    code and at me all has earned as I want.

    Changes have concerned only to function slot_find_empty().

    int slot_find_empty()
     {
        int i;
        int count=0;
        int *index=NULL;
        for(i=0; i<slot_count; i++) {
            struct slot *slot = &slots[i];
            if (slot->pid == 0) {
                count++;
                index = (int*) realloc(index, count * sizeof(int));
                index[count-1] = i;
             }
        }
        if (count == 0) return -1;
        srand(count);
        i = index[rand()];
        free(index);
        return i;
     }
    

    It, of course, not the best variant. But if the given functionak is

    interesting to you, I can be engaged in finishing of this functional.

     
  • Andrey Terentiew

    There was an error at code transfer. I am sorry.

    srand(time(NULL));

    i=index;

     
  • Andrey Terentiew

    :( I am sorry.

    i-index[rand()%count];
    
     
  • Andrey Terentiew

    :'(

    i=index[rand()%count];
    
     
  • Joe Breath

    Joe Breath - 2025-01-24
    Post awaiting moderation.
  • Ferry Wall

    Ferry Wall - 2025-11-23

    I recently tried the Extreme Car Driving Simulator old version and it’s amazing! The game runs smoothly, the controls feel great, and it’s perfect for anyone who loves realistic car driving without any lag. Highly recommend checking it out!

     

Log in to post a comment.

MongoDB Logo MongoDB