NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Component 11/Satellite/Satellite_Helper.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* This source code is licensed per the NetSim license agreement. *
12* *
13* No portion of this source code may be used as the basis for a derivative work, *
14* or used, for any purpose other than its intended use per the NetSim license *
15* agreement. *
16* *
17* This source code and the algorithms contained within it are confidential trade *
18* secrets of TETCOS and may not be used as the basis for any other software, *
19* hardware, product or service. *
20* *
21* Author: Shashi Kant Suman *
22* *
23* ----------------------------------------------------------------------------------*/
24#include "main.h"
25#include "SATELLITE.h"
26#include "Satellite_MAC.h"
27
28void satellite_ut_set_gateway(ptrSATELLITE_UT_MAC utMac)
29{
30 if (!utMac->szGatewayName)
31 {
32 fnNetSimError("Gateway is not setup for UT %d-%d.\n"
33 "Press any key to terminate simulation.\n",
34 utMac->utId, utMac->utIf);
35 int c = _getch();
36 exit(c);
37 }
38
39 utMac->gatewayId = fn_NetSim_Stack_GetDeviceId_asName(utMac->szGatewayName);
40 if (!utMac->gatewayId)
41 {
42 fnNetSimError("Gateway is not correctly setup for UT %d-%d.\n"
43 "Gateway = %s is not an gateway device\n"
44 "Press any key to terminate simulation.\n",
45 utMac->utId, utMac->utIf, utMac->szGatewayName);
46 int c = _getch();
47 exit(c);
48 }
49
50 utMac->gatewayIf = fn_NetSim_Stack_GetConnectedInterface(utMac->utId, utMac->utIf,
51 utMac->gatewayId);
52 if (!utMac->gatewayIf)
53 {
54 fnNetSimError("%s Gateway is not connected to UT %d-%d.\n"
55 "Press any key to terminate simulation.\n",
56 utMac->szGatewayName, utMac->utId, utMac->utIf);
57 int c = _getch();
58 exit(c);
59 }
60
61 if (DEVICE_MACLAYER(utMac->gatewayId, utMac->gatewayIf)->nMacProtocolId != MAC_PROTOCOL_SATELLITE)
62 {
63 fnNetSimError("Gateway %s not running satellite protocol.\n"
64 "Press any key to terminate simulation.\n",
65 utMac->szGatewayName);
66 int c = _getch();
67 exit(c);
68 }
69
70 ptrSATELLITE_PROTODATA pd = DEVICE_MACVAR(utMac->gatewayId, utMac->gatewayIf);
71 if (pd->deviceType != SATELLITE_DEVICETYPE_SATELLITE_GATEWAY)
72 {
73 fnNetSimError("Gateway %s is not a satellite gateway device.\n"
74 "Press any key to terminate simulation.\n",
75 utMac->szGatewayName);
76 int c = _getch();
77 exit(c);
78 }
79}
80
81bool isSatelliteInterface(NETSIM_ID d, NETSIM_ID in)
82{
83 if (!DEVICE_INTERFACE(d, in))
84 return false;
85 if (!DEVICE_INTERFACE(d, in)->pstruMACLayer)
86 return false;
87 if (DEVICE_MACLAYER(d, in)->nMacProtocolId == MAC_PROTOCOL_SATELLITE)
88 return true;
89 return false;
90}