NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
PIM_Print.c
1/************************************************************************************
2* Copyright (C) 2023 *
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
20static int counter[50];
21
22static print_tree(NETSIM_ID r, NETSIM_ID b, int l1, int l2, int c1, int c2,FILE* fp)
23{
24 fprintf(fp, "%d,%d,%d,%d,%d,%d\n",
25 r, b,
26 50 + 80 * c1, 50 + 80 * l1,
27 50 + 80 * c2, 50 + 80 * l2);
28 fflush(fp);
29}
30
31void print_rpt(NETSIM_ID d, ptrPIM_GROUP group, int level, int count,FILE* fp)
32{
33 UINT c = group->count;
34 fprintf(stderr, "%d,%d,%d,%d\n", d, c, level, count);
35 if (!c)
36 return;
37 NETSIM_ID* cid = calloc(c, sizeof* cid);
38 NETSIM_ID* cin = calloc(c, sizeof* cin);
39 NETSIM_ID f;
40 UINT i;
41 for (i = 0; i < c; i++)
42 {
43 NETSIM_ID l = fn_NetSim_Stack_GetConnectedDevice(d,
44 group->ifid[i],
45 &cid[i],
46 &f);
47 print_tree(d, cid[i], level, level + 1, count, counter[level + 1], fp);
48 cin[i] = counter[level + 1];
49 counter[level + 1]++;
50 }
51
52 for (i = 0; i < c; i++)
53 {
54 ptrPIM_GROUP g = pim_find_group(cid[i], group->groupAddress);
55 print_rpt(cid[i], g, level + 1, cin[i], fp);
56 }
57}
58
59void print_RPT_Tree(NETSIM_ID rp, ptrPIM_GROUP group)
60{
61 int level = 0;
62 int count = 0;
63
64 fprintf(stderr, "\n");
65 memset(counter, 0, 50 * sizeof* counter);
66 FILE* fp = fopen("points.txt", "w");
67 print_rpt(rp, group, level, count,fp);
68 fclose(fp);
69 _getch();
70}