source: src/router/services/services/igmp.c @ 12003

Last change on this file since 12003 was 12003, checked in by BrainSlayer, 4 years ago

correct wan interface

File size: 3.5 KB
Line 
1/*
2 * igmp.c
3 *
4 * Copyright (C) 2007 Sebastian Gottschall <gottschall@dd-wrt.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 *
20 * $Id:
21 */
22#ifdef HAVE_MULTICAST
23#include <stdlib.h>
24#include <bcmnvram.h>
25#include <shutils.h>
26#include <utils.h>
27#include <syslog.h>
28#include <signal.h>
29
30void stop_igmp_proxy( void );
31void start_igmp_proxy( void )
32{
33    int ret = 0;
34    pid_t pid;
35    char name[80], *next, *svbuf;
36    char *argv[] = { "igmprt", NULL };
37
38    stop_igmp_proxy(  );
39    int ifcount = 0;
40
41/*
42    if (nvram_match("dtag_vlan8","1"))
43        {
44        FILE *fp = fopen( "/tmp/igmpproxy_tv.conf", "wb" );
45        fprintf( fp, "quickleave\nphyint %s upstream  ratelimit 0  threshold 1\n",nvram_safe_get( "tvnicfrom" ) );
46        fprintf( fp, "phyint %s downstream  ratelimit 0  threshold 1\n",nvram_safe_get( "lan_ifname"));
47        char ifnames[256];
48        getIfLists( ifnames, 256 );
49        foreach( name, ifnames, next )
50        {
51            if (!nvram_match("tvnicfrom",name) && !nvram_match("lan_ifname",name))
52                fprintf( fp, "phyint %s disabled\n", name );
53        }
54        fprintf( fp, "phyint lo disabled\n" );
55        fclose(fp);
56        eval("igmprt","-c","/tmp/igmpproxy_tv.conf");
57        return;
58        }*/
59    FILE *fp = fopen( "/tmp/igmpproxy.conf", "wb" );
60
61    if (nvram_match("dtag_vlan8","1"))
62        {
63        fprintf( fp, "quickleave\nphyint %s upstream  ratelimit 0  threshold 1\n",nvram_safe_get( "tvnicfrom" ) );
64        }
65        else
66        {
67        fprintf( fp, "quickleave\nphyint %s upstream  ratelimit 0  threshold 1\n",get_wan_face() );
68        }
69    if( nvram_match( "block_multicast", "0" ) )
70    {
71        fprintf( fp, "phyint %s downstream  ratelimit 0  threshold 1\n",
72                 nvram_safe_get( "lan_ifname" ) );
73        ifcount++;
74    }
75    else
76    {
77        fprintf( fp, "phyint %s disabled\n"
78                 "phyint %s:0 disabled\n", nvram_safe_get( "lan_ifname" ),
79                 nvram_safe_get( "lan_ifname" ) );
80    }
81    char ifnames[256];
82
83    getIfLists( ifnames, 256 );
84    foreach( name, ifnames, next )
85    {
86        if( strcmp( get_wan_face(  ), name )
87            && strcmp( nvram_safe_get( "lan_ifname" ), name ) )
88        {
89            if( nvram_nmatch( "0", "%s_bridged", name )
90                && nvram_nmatch( "1", "%s_multicast", name ) )
91            {
92                fprintf( fp,
93                         "phyint %s downstream  ratelimit 0  threshold 1\n",
94                         name );
95                ifcount++;
96            }
97            else
98                fprintf( fp, "phyint %s disabled\n", name );
99        }
100    }
101    fprintf( fp, "phyint lo disabled\n" );
102    fclose( fp );
103    if( nvram_match( "wan_proto", "disabled" ) )        // todo: add upstream
104        // config
105    {
106        // ret = _evalpid (igmp_proxybr_argv, NULL, 0, &pid);
107        return;
108    }
109    else
110    {
111        if( ifcount )
112        {
113            ret = _evalpid( argv, NULL, 0, &pid );
114            dd_syslog( LOG_INFO,
115                       "igmprt : multicast daemon successfully started\n" );
116        }
117    }
118
119    cprintf( "done\n" );
120    return;
121}
122
123void stop_igmp_proxy( void )
124{
125    int ret = 0;
126
127    if( pidof( "igmprt" ) > 0 )
128    {
129        syslog( LOG_INFO,
130                "igmprt : multicast daemon successfully stopped\n" );
131        ret = killall( "igmprt", SIGKILL );
132    }
133    cprintf( "done\n" );
134    return;
135}
136#endif
Note: See TracBrowser for help on using the repository browser.