X-Git-Url: http://git.onelab.eu/?p=distributedratelimiting.git;a=blobdiff_plain;f=drl%2Fulogd_DRL.c;fp=drl%2Fulogd_DRL.c;h=70f096b61aff5402262dde57388d2e11d7becf60;hp=f7b027256901326322647c007087b9982b726cb8;hb=845a86c2059f50aef544fffde2534064d4048ed4;hpb=89df43dd6b8cb8df82cfbf395b923014d2826b5a diff --git a/drl/ulogd_DRL.c b/drl/ulogd_DRL.c index f7b0272..70f096b 100644 --- a/drl/ulogd_DRL.c +++ b/drl/ulogd_DRL.c @@ -124,8 +124,16 @@ * Add the config options for DRL. */ -static config_entry_t create_htb = { +static config_entry_t bind_addr = { .next = NULL, + .key = "bind_addr", + .type = CONFIG_TYPE_STRING, + .options = CONFIG_OPT_NONE, + .u = { .string = "AUTO" }, +}; + +static config_entry_t create_htb = { + .next = &bind_addr, .key = "create_htb", .type = CONFIG_TYPE_INT, .options = CONFIG_OPT_NONE, @@ -1526,15 +1534,20 @@ static int init_drl(void) { pthread_rwlock_init(&limiter.limiter_lock,NULL); /* determine our local IP by iterating through interfaces */ - limiter.ip = get_local_ip(); - if (limiter.ip == NULL) { - printlog(LOG_CRITICAL, "ulogd_DRL unable to aquire local IP address, not registering.\n"); - return false; + if (strncmp(bind_addr.u.string, "AUTO", 4)) { + limiter.ip = bind_addr.u.string; + } else { + limiter.ip = get_local_ip(); + if (limiter.ip == NULL) { + printlog(LOG_CRITICAL, "ulogd_DRL unable to aquire local IP address, not registering.\n"); + return false; + } } limiter.localaddr = inet_addr(limiter.ip); limiter.port = htons(LIMITER_LISTEN_PORT); limiter.udp_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (limiter.udp_socket < 0) { + perror("socket()"); printlog(LOG_CRITICAL, "Failed to create UDP socket().\n"); return false; } @@ -1545,6 +1558,7 @@ static int init_drl(void) { server_address.sin_port = limiter.port; if (bind(limiter.udp_socket, (struct sockaddr *) &server_address, sizeof(server_address)) < 0) { + perror("bind()"); printlog(LOG_CRITICAL, "Failed to bind UDP socket.\n"); return false; }