blob: 7183997c51471b5bec7a42f23363c17c0a594b0d [file] [log] [blame]
Everton Marques40765fe2009-09-30 17:10:11 -03001/*
2 PIM for Quagga
3 Copyright (C) 2008 Everton da Silva Marques
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 MA 02110-1301 USA
19
20 $QuaggaId: $Format:%an, %ai, %h$ $
21*/
22
23#include <string.h>
24
25#include "pim_igmp_join.h"
26
27#ifndef MCAST_JOIN_SOURCE_GROUP
28#define MCAST_JOIN_SOURCE_GROUP 46
29struct group_source_req
30{
31 uint32_t gsr_interface;
32 struct sockaddr_storage gsr_group;
33 struct sockaddr_storage gsr_source;
34};
35#endif
36
37int pim_igmp_join_source(int fd, int ifindex,
38 struct in_addr group_addr,
39 struct in_addr source_addr)
40{
41 struct group_source_req req;
42 struct sockaddr_in *group_sa = (struct sockaddr_in *) &req.gsr_group;
43 struct sockaddr_in *source_sa = (struct sockaddr_in *) &req.gsr_source;
44
45 memset(group_sa, 0, sizeof(*group_sa));
46 group_sa->sin_family = AF_INET;
47 group_sa->sin_addr = group_addr;
48 group_sa->sin_port = htons(0);
49
50 memset(source_sa, 0, sizeof(*source_sa));
51 source_sa->sin_family = AF_INET;
52 source_sa->sin_addr = source_addr;
53 source_sa->sin_port = htons(0);
54
55 req.gsr_interface = ifindex;
56
57 return setsockopt(fd, SOL_IP, MCAST_JOIN_SOURCE_GROUP,
58 &req, sizeof(req));
59
60 return 0;
61}