NetSim Source Code Help
Loading...
Searching...
No Matches
UDP.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
25#include "main.h"
26#include "UDP.h"
27
28/**
29 This function is called by NetworkStack.dll, whenever the event gets triggered
30 inside the NetworkStack.dll for the Transport layer UDP protocol
31*/
33{
34 nEventType=pstruEventDetails->nEventType; /* Get the EventType from Event details */
35
36 /*Check event type*/
37 switch(nEventType)
38 {
40 /* Send the user datagram */
42 break;
44 /* Receive the user datagram */
46 break;
47 default:
48 fnNetSimError("UDP-- Unknown event type for UDP protocol\n");
49 break;
50 }
51 return 0;
52}
53
54/********************************************************************************/
55/* The Following functions are present in the libUDP.lib. */
56/* so NetworkStack.dll can not call libUDP.lib, NetworkStack.dll is calling */
57/* libUDP.dll. From libUDP.dll, libUDP.lib functions are called. */
58/********************************************************************************/
59/**
60 This function is called by NetworkStack.dll, while configuring the device
61 TRANSPORT layer for UDP protocol.
62*/
63_declspec(dllexport) int fn_NetSim_UDP_Configure(void** var)
64{
65 return fn_NetSim_UDP_Configure_F(var);
66}
67
68/**
69 This functon initializes the UDP parameters.
70*/
72{
73 return fn_NetSim_UDP_Init_F();
74}
75/**
76 This function is called by NetworkStack.dll, once simulation end to free the
77 allocated memory for the network.
78*/
80{
82 return 0;
83}
84
85/************************************************************************************/
86/* This function will return the string to wrie packet trace heading */
87/************************************************************************************/
88/**
89 This function will return the string to wrie packet trace heading
90*/
92{
93 return "";
94}
95
96/************************************************************************************/
97/* This function will return the string to wrie packet trace */
98/************************************************************************************/
99_declspec(dllexport) int fn_NetSim_UDP_WritePacketTrace(NetSim_PACKET* pstruPacket,char** ppszTrace)
100{
101 pstruPacket;
102 ppszTrace;
103 return 1;
104}
105/**
106 This function is called by NetworkStack.dll, while writing the evnt trace
107 to get the sub event as a string.
108*/
109_declspec(dllexport) char *fn_NetSim_UDP_Trace(int nSubEvent)
110{
111 return (fn_NetSim_UDP_Trace_F(nSubEvent));
112}
113
115{
116 return fn_NetSim_UDP_FreePacket_F(pstruPacket);
117}
118/**
119 This function is called by NetworkStack.dll, to free the packet of UDP protocol
120*/
121_declspec(dllexport) int fn_NetSim_UDP_CopyPacket(NetSim_PACKET* pstruDestPacket,NetSim_PACKET* pstruSrcPacket)
122{
123 return fn_NetSim_UDP_CopyPacket_F(pstruDestPacket,pstruSrcPacket);
124}
125/** This function write the Metrics in Metrics.txt */
126_declspec(dllexport) int fn_NetSim_UDP_Metrics(PMETRICSWRITER metricsWriter)
127{
128 return fn_NetSim_UDP_Metrics_F(metricsWriter);
129}
#define _declspec(dllexport)
This function is used to trigger the update.
Definition: Linux.h:41
#define fnNetSimError(x,...)
Definition: Linux.h:56
void * PMETRICSWRITER
Definition: MetricsWriter.h:27
int fn_NetSim_UDP_Receive_User_Datagram()
int fn_NetSim_UDP_Send_User_Datagram()
EXPORTED EVENT_TYPE nEventType
Definition: Stack.h:839
@ TRANSPORT_IN_EVENT
Definition: Stack.h:111
@ TRANSPORT_OUT_EVENT
Definition: Stack.h:110
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
int fn_NetSim_UDP_FreePacket(NetSim_PACKET *pstruPacket)
Function to free the allocated memory for the UDP packet.
Definition: UDP.c:114
int fn_NetSim_UDP_CopyPacket(NetSim_PACKET *pstruDestPacket, NetSim_PACKET *pstruSrcPacket)
Function to copy the UDP packet from source to destination.
Definition: UDP.c:121
int fn_NetSim_UDP_WritePacketTrace(NetSim_PACKET *pstruPacket, char **ppszTrace)
Definition: UDP.c:99
int fn_NetSim_UDP_Run()
Definition: UDP.c:32
int fn_NetSim_UDP_Init()
Definition: UDP.c:71
int fn_NetSim_UDP_Metrics(PMETRICSWRITER metricsWriter)
Function to write UDP Metrics into Metrics.txt.
Definition: UDP.c:126
int fn_NetSim_UDP_Finish()
Function to free the UDP protocol variable and Unload the primitives.
Definition: UDP.c:79
int fn_NetSim_UDP_Configure(void **var)
Definition: UDP.c:63
char * fn_NetSim_UDP_ConfigPacketTrace()
Definition: UDP.c:91
char * fn_NetSim_UDP_Trace(int nSubEvent)
Return the subevent name with respect to the subevent number for writting event trace.
Definition: UDP.c:109
int fn_NetSim_UDP_Metrics_F(PMETRICSWRITER metricsWriter)
int fn_NetSim_UDP_FreePacket_F(NetSim_PACKET *)
int fn_NetSim_UDP_Configure_F(void **var)
int fn_NetSim_UDP_CopyPacket_F(NetSim_PACKET *, NetSim_PACKET *)
char * fn_NetSim_UDP_Trace_F(int nSubEvent)
int fn_NetSim_UDP_Init_F()
int fn_NetSim_UDP_Finish_F()
EVENT_TYPE nEventType
Definition: Stack.h:747