]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_igmp_join.h
debian: add pkg-config to build-depends
[mirror_frr.git] / pimd / pim_igmp_join.h
CommitLineData
12e41d03
DL
1/*
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.
ac4d0be5 14
12e41d03
DL
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
12e41d03
DL
19*/
20
21#ifndef PIM_IGMP_JOIN_H
22#define PIM_IGMP_JOIN_H
23
5ef104fc 24/* required headers #include'd by caller */
12e41d03 25
5ef104fc
DL
26#ifndef SOL_IP
27#define SOL_IP IPPROTO_IP
28#endif
29
30#ifndef MCAST_JOIN_SOURCE_GROUP
31#define MCAST_JOIN_SOURCE_GROUP 46
ac4d0be5 32struct group_source_req {
33 uint32_t gsr_interface;
34 struct sockaddr_storage gsr_group;
35 struct sockaddr_storage gsr_source;
5ef104fc
DL
36};
37#endif
38
b892f1dd 39static int pim_igmp_join_source(int fd, ifindex_t ifindex,
5ef104fc
DL
40 struct in_addr group_addr,
41 struct in_addr source_addr)
42{
ac4d0be5 43 struct group_source_req req;
44 struct sockaddr_in group;
45 struct sockaddr_in source;
5ef104fc 46
ac4d0be5 47 memset(&req, 0, sizeof(req));
48 memset(&group, 0, sizeof(group));
49 group.sin_family = AF_INET;
50 group.sin_addr = group_addr;
51 group.sin_port = htons(0);
52 memcpy(&req.gsr_group, &group, sizeof(struct sockaddr_in));
5ef104fc 53
ac4d0be5 54 memset(&source, 0, sizeof(source));
55 source.sin_family = AF_INET;
56 source.sin_addr = source_addr;
57 source.sin_port = htons(0);
58 memcpy(&req.gsr_source, &source, sizeof(struct sockaddr_in));
5ef104fc 59
ac4d0be5 60 req.gsr_interface = ifindex;
5ef104fc 61
ac4d0be5 62 return setsockopt(fd, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &req,
63 sizeof(req));
5ef104fc 64
ac4d0be5 65 return 0;
5ef104fc 66}
12e41d03
DL
67
68#endif /* PIM_IGMP_JOIN_H */