NetSim Source Code Help
Loading...
Searching...
No Matches
Satellite_HDR.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2021 *
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_HDR.h"
26#include "Satellite_MAC.h"
27
29 NetSim_PACKET* packet)
30{
31 ptrSATELLITE_HDR hdr = calloc(1, sizeof * hdr);
32
34 packet->pstruMacData->Packet_MACProtocol = hdr;
35
36 if (isUT(d, in))
37 {
39 hdr->gwId = mac->gatewayId;
40 hdr->gwIf = mac->gatewayIf;
42 hdr->satelliteId = mac->satelliteId;
43 hdr->satelliteIf = mac->satelliteIf;
44 hdr->utId = d;
45 hdr->utIf = in;
46 }
47 else if (isGW(d, in))
48 {
50 hdr->gwId = d;
51 hdr->gwIf = in;
53 hdr->satelliteId = mac->satelliteId;
54 hdr->satelliteIf = mac->satelliteIf;
55 hdr->utId = packet->nReceiverId;
57 }
58 else
59 {
60 fnNetSimError("Unknown device type %d for %d:%d in function %s\n",
61 SATELLITE_DEVICETYPE_GET(d, in), d, in);
62 }
63}
64
66{
68}
69
71{
73 free(hdr);
74 packet->pstruMacData->Packet_MACProtocol = NULL;
75}
unsigned int NETSIM_ID
Definition: Animation.h:45
#define fnNetSimError(x,...)
Definition: Linux.h:56
#define free(p)
Definition: Memory.h:31
#define calloc(c, s)
Definition: Memory.h:29
@ LINKTYPE_FORWARD
Definition: Satellite.h:61
@ LINKTYPE_RETURN
Definition: Satellite.h:62
#define isGW(d, i)
Definition: Satellite.h:123
#define SATELLITE_GWMAC_GET(d, i)
Definition: Satellite.h:112
#define isUT(d, i)
Definition: Satellite.h:122
SATELLITE_DEVICETYPE SATELLITE_DEVICETYPE_GET(NETSIM_ID d, NETSIM_ID in)
#define SATELLITE_UTMAC_GET(d, i)
Definition: Satellite.h:110
ptrSATELLITE_HDR SATELLITE_HDR_GET(NetSim_PACKET *packet)
Definition: Satellite_HDR.c:65
void satellite_hdr_init(NETSIM_ID d, NETSIM_ID in, NetSim_PACKET *packet)
Definition: Satellite_HDR.c:28
void SATELLITE_HDR_REMOVE(NetSim_PACKET *packet)
Definition: Satellite_HDR.c:70
@ MAC_PROTOCOL_SATELLITE
Definition: Stack.h:234
NETSIM_ID fn_NetSim_Stack_GetConnectedInterface(NETSIM_ID devId, NETSIM_ID ifid, NETSIM_ID conId)
MAC_LAYER_PROTOCOL nMACProtocol
Definition: Packet.h:223
NETSIM_ID nReceiverId
Definition: Packet.h:266
struct stru_NetSim_Packet_MACLayer * pstruMacData
Definition: Packet.h:276
NETSIM_ID satelliteId
Definition: Satellite_HDR.h:43
NETSIM_ID satelliteIf
Definition: Satellite_HDR.h:44