From f90514ac605769787800d97bbf00147b653e1735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Wed, 9 Jan 2008 11:36:16 +0000 Subject: [PATCH] dont require 'interface-address' to be specified for multicast output --- iptv_output.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/iptv_output.c b/iptv_output.c index 951f902e..ca119b1f 100644 --- a/iptv_output.c +++ b/iptv_output.c @@ -136,15 +136,20 @@ output_multicast_load(struct config_head *head) om = calloc(1, sizeof(output_multicast_t)); - if((b = config_get_str_sub(head, "interface-address", NULL)) == NULL) { - fprintf(stderr, "no interface address configured\n"); - goto err; - } - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_port = 0; - sin.sin_addr.s_addr = inet_addr(b); + om->om_fd = socket(AF_INET, SOCK_DGRAM, 0); + if((b = config_get_str_sub(head, "interface-address", NULL)) != NULL) { + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = inet_addr(b); + + if(bind(om->om_fd, (struct sockaddr *)&sin, sizeof(sin))==-1) { + fprintf(stderr, "cannot bind to %s\n", b); + goto err; + } + } + if((s = config_get_str_sub(head, "group-address", NULL)) == NULL) { fprintf(stderr, "no group address configured\n"); goto err; @@ -157,14 +162,6 @@ output_multicast_load(struct config_head *head) } om->om_dst.sin_port = htons(atoi(s)); - om->om_fd = socket(AF_INET, SOCK_DGRAM, 0); - - if(bind(om->om_fd, (struct sockaddr *)&sin, sizeof(sin))==-1) { - fprintf(stderr, "cannot bind to %s\n", b); - close(om->om_fd); - goto err; - } - if((s = config_get_str_sub(head, "ttl", NULL)) != NULL) ttl = atoi(s); @@ -194,6 +191,7 @@ output_multicast_load(struct config_head *head) return; err: + close(om->om_fd); free(om); }