src/tcpkali_iface.c
int
add_source_ip(struct addresses *addresses, const char *optarg) {
    struct addrinfo hints = {.ai_family = AF_UNSPEC,
                             .ai_socktype = SOCK_STREAM,
                             .ai_protocol = IPPROTO_TCP,
                             .ai_flags = AI_PASSIVE | AI_ADDRCONFIG};

    struct addrinfo *res;
    int err = getaddrinfo(optarg, NULL, &hints, &res);
    if(err != 0) {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(err));
        return -1;
    }

    /* Move all of the addresses into the separate storage */
    for(struct addrinfo *tmp = res; tmp; tmp = tmp->ai_next) {
        address_add(addresses, tmp->ai_addr);
        if(check_if_bindable_ip(&addresses->addrs[addresses->n_addrs - 1])
           < 0) {
            freeaddrinfo(res);
            return -1;
        }
    }

    freeaddrinfo(res);

    return 0;
}
/*
 * Parse the specified IP as it were a source IP, and add it to the list.
 */
Parse the specified IP as it were a source IP, and add it to the list.
Parse the specified IP as it were a source IP and add it to the list .
int
add_source_ip(struct addresses *addresses, const char *optarg) {
    struct addrinfo hints = {.ai_family = AF_UNSPEC,
                             .ai_socktype = SOCK_STREAM,
                             .ai_protocol = IPPROTO_TCP,
                             .ai_flags = AI_PASSIVE | AI_ADDRCONFIG};
    struct addrinfo *res;
    int err = getaddrinfo(optarg, NULL, &hints, &res);
    if(err != 0) {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(err));
        return -1;
    }
    for(struct addrinfo *tmp = res; tmp; tmp = tmp->ai_next) {
        address_add(addresses, tmp->ai_addr);
        if(check_if_bindable_ip(&addresses->addrs[addresses->n_addrs - 1])
           < 0) {
            freeaddrinfo(res);
            return -1;
        }
    }
    freeaddrinfo(res);
    return 0;
}
int add_source_ip ( struct addresses * addresses , const char * optarg ) { struct addrinfo hints = { . ai_family = AF_UNSPEC , . ai_socktype = SOCK_STREAM , . ai_protocol = IPPROTO_TCP , . ai_flags = AI_PASSIVE | AI_ADDRCONFIG } ; struct addrinfo * res ; int err = getaddrinfo ( optarg , NULL , & hints , & res ) ; if ( err != 0 ) { fprintf ( stderr , " \n " , gai_strerror ( err ) ) ; return -1 ; } for ( struct addrinfo * tmp = res ; tmp ; tmp = tmp -> ai_next ) { address_add ( addresses , tmp -> ai_addr ) ; if ( check_if_bindable_ip ( & addresses -> addrs [ addresses -> n_addrs - 1 ] ) < 0 ) { freeaddrinfo ( res ) ; return -1 ; } } freeaddrinfo ( res ) ; return 0 ; }
Parse the specified IP as it were a source IP, and add it to the list.
Parse the specified IP as it were a source IP and add it to the list .
/* Move all of the addresses into the separate storage */