blob: b48adb755d49689cc9941e1e2c3dc590aefa5bf6 [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
David Lamparter821df2c2015-09-15 01:53:09 -070023#include <zebra.h>
24
Userd0d79802010-08-05 13:26:25 -070025#include <sys/types.h>
26#include <sys/socket.h>
Everton Marques40765fe2009-09-30 17:10:11 -030027#include <string.h>
28
29#include "pim_igmp_join.h"
30
Userd0d79802010-08-05 13:26:25 -070031#ifndef SOL_IP
32#define SOL_IP IPPROTO_IP
33#endif
34
Everton Marques40765fe2009-09-30 17:10:11 -030035#ifndef MCAST_JOIN_SOURCE_GROUP
36#define MCAST_JOIN_SOURCE_GROUP 46
37struct group_source_req
38{
39 uint32_t gsr_interface;
40 struct sockaddr_storage gsr_group;
41 struct sockaddr_storage gsr_source;
42};
43#endif
44
45int pim_igmp_join_source(int fd, int ifindex,
46 struct in_addr group_addr,
47 struct in_addr source_addr)
48{
49 struct group_source_req req;
50 struct sockaddr_in *group_sa = (struct sockaddr_in *) &req.gsr_group;
51 struct sockaddr_in *source_sa = (struct sockaddr_in *) &req.gsr_source;
52
53 memset(group_sa, 0, sizeof(*group_sa));
54 group_sa->sin_family = AF_INET;
55 group_sa->sin_addr = group_addr;
56 group_sa->sin_port = htons(0);
57
58 memset(source_sa, 0, sizeof(*source_sa));
59 source_sa->sin_family = AF_INET;
60 source_sa->sin_addr = source_addr;
61 source_sa->sin_port = htons(0);
62
63 req.gsr_interface = ifindex;
64
65 return setsockopt(fd, SOL_IP, MCAST_JOIN_SOURCE_GROUP,
66 &req, sizeof(req));
67
68 return 0;
69}