NetSim Source Code Help
Loading...
Searching...
No Matches
PIM_Group.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14
15#include "main.h"
16#include "List.h"
17#include "IP.h"
18#include "PIM_SM.h"
19
21{
22 ptrPIM_GROUP gr = GET_PIM_VAR(d)->groupList;
23 while (gr)
24 {
25 if (!IP_COMPARE(gr->groupAddress, addr))
26 return gr;
28 }
29 return NULL;
30}
31
33{
34 ptrPIM_VAR pim = GET_PIM_VAR(d);
36 NETSIM_ID in;
37 pim->groupCount++;
38 gr->groupId = pim->groupCount;
39 gr->groupAddress = IP_COPY(addr);
40 gr->RP = IP_COPY(RP);
42 PIM_GROUP_ADD(&pim->groupList, gr);
43 return gr;
44}
45
46
48{
49 UINT c;
50 for (c = 0; c < g->count; c++)
51 if (g->ifid[c] == i)
52 return true;
53 return false;
54}
55
57{
58 if (is_if_already_presen(g, i))
59 return; //Already present
60
61 if (g->count)
62 g->ifid = realloc(g->ifid, (g->count + 1) * sizeof* g->ifid);
63 else
64 g->ifid = calloc(1, sizeof* g->ifid);
65
66 g->ifid[g->count] = i;
67 g->count++;
68}
69
unsigned int NETSIM_ID
Definition: Animation.h:45
NETSIM_IPAddress IP_COPY(NETSIM_IPAddress ip)
#define IP_COMPARE(ip1, ip2)
Definition: IP_Addressing.h:67
#define c
#define UINT
Definition: Linux.h:38
#define realloc(p, s)
Definition: Memory.h:32
#define calloc(c, s)
Definition: Memory.h:29
void pim_add_interface_to_group(NETSIM_ID d, NETSIM_ID i, ptrPIM_GROUP g)
Definition: PIM_Group.c:56
static bool is_if_already_presen(ptrPIM_GROUP g, NETSIM_ID i)
Definition: PIM_Group.c:47
ptrPIM_GROUP create_group(NETSIM_ID d, NETSIM_IPAddress addr, NETSIM_IPAddress RP)
Definition: PIM_Group.c:32
ptrPIM_GROUP pim_find_group(NETSIM_ID d, NETSIM_IPAddress addr)
Definition: PIM_Group.c:20
#define GET_PIM_VAR(d)
Definition: PIM_SM.h:226
#define PIM_GROUP_ADD(l, m)
Definition: PIM_SM.h:200
#define PIM_GROUP_NEXT(gr)
Definition: PIM_SM.h:199
#define PIM_GROUP_ALLOC()
Definition: PIM_SM.h:198
NETSIM_ID fn_NetSim_Stack_GetDeviceId_asIP(NETSIM_IPAddress ip, NETSIM_ID *nInterfaceId)
NETSIM_IPAddress RP
Definition: PIM_SM.h:186
UINT count
Definition: PIM_SM.h:193
NETSIM_ID RPId
Definition: PIM_SM.h:187
NETSIM_ID * ifid
Definition: PIM_SM.h:194
NETSIM_ID groupId
Definition: PIM_SM.h:184
NETSIM_IPAddress groupAddress
Definition: PIM_SM.h:185
UINT groupCount
Definition: PIM_SM.h:211
ptrPIM_GROUP groupList
Definition: PIM_SM.h:212