back to topotato report
topotato coverage report
Current view: top level - pimd - pim_igmp_join.h (source / functions) Hit Total Coverage
Test: test_pim_cbsr.py::PIMCandidateBSRTest Lines: 0 19 0.0 %
Date: 2023-02-16 02:09:14 Functions: 0 1 0.0 %

          Line data    Source code
       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.
      14             :  *
      15             :  * You should have received a copy of the GNU General Public License along
      16             :  * with this program; see the file COPYING; if not, write to the Free Software
      17             :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
      18             :  */
      19             : 
      20             : #ifndef PIM_IGMP_JOIN_H
      21             : #define PIM_IGMP_JOIN_H
      22             : 
      23             : /* required headers #include'd by caller */
      24             : 
      25             : #ifndef SOL_IP
      26             : #define SOL_IP IPPROTO_IP
      27             : #endif
      28             : 
      29             : #ifndef MCAST_JOIN_GROUP
      30             : #define MCAST_JOIN_GROUP 42
      31             : #endif
      32             : 
      33             : #ifndef MCAST_JOIN_SOURCE_GROUP
      34             : #define MCAST_JOIN_SOURCE_GROUP 46
      35             : struct group_source_req {
      36             :         uint32_t gsr_interface;
      37             :         struct sockaddr_storage gsr_group;
      38             :         struct sockaddr_storage gsr_source;
      39             : };
      40             : #endif
      41             : 
      42           0 : static inline int pim_igmp_join_source(int fd, ifindex_t ifindex,
      43             :                                        struct in_addr group_addr,
      44             :                                        struct in_addr source_addr)
      45             : {
      46           0 :         struct group_source_req req;
      47           0 :         struct sockaddr_in group;
      48           0 :         struct sockaddr_in source;
      49             : 
      50           0 :         memset(&req, 0, sizeof(req));
      51           0 :         memset(&group, 0, sizeof(group));
      52           0 :         group.sin_family = AF_INET;
      53           0 :         group.sin_addr = group_addr;
      54           0 :         group.sin_port = htons(0);
      55           0 :         memcpy(&req.gsr_group, &group, sizeof(struct sockaddr_in));
      56             : 
      57           0 :         memset(&source, 0, sizeof(source));
      58           0 :         source.sin_family = AF_INET;
      59           0 :         source.sin_addr = source_addr;
      60           0 :         source.sin_port = htons(0);
      61           0 :         memcpy(&req.gsr_source, &source, sizeof(struct sockaddr_in));
      62             : 
      63           0 :         req.gsr_interface = ifindex;
      64             : 
      65           0 :         if (source_addr.s_addr == INADDR_ANY)
      66           0 :                 return setsockopt(fd, SOL_IP, MCAST_JOIN_GROUP, &req,
      67             :                                   sizeof(req));
      68             :         else
      69           0 :                 return setsockopt(fd, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &req,
      70             :                                   sizeof(req));
      71             : }
      72             : 
      73             : #endif /* PIM_IGMP_JOIN_H */

Generated by: LCOV version v1.16-topotato