NetSim Source Code Help
Loading...
Searching...
No Matches
Channel.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#include "main.h"
15#include "IEEE1609.h"
16
17void Init_Channel_Switching(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
18{
19 memset(pstruEventDetails, 0, sizeof* pstruEventDetails);
20 pstruEventDetails->nDeviceId = ndeviceId;
23 pstruEventDetails->nInterfaceId = nInterfaceId;
25 pstruEventDetails->nSubEventType = CHANNEL_SWITCH_END;
27 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.prevChannel = IEEE1609_ChannelType_SCH;
28}
29
31{
32 double t;
34 memcpy(&pevent, pstruEventDetails, sizeof pevent);
35
36 switch (GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.prevChannel)
37 {
39 t = GET_IEEE1609_CURR_MAC_VAR->dCCH_Time;
40 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.channel_type = IEEE1609_ChannelType_CCH;
41 break;
43 t = GET_IEEE1609_CURR_MAC_VAR->dSCH_Time;
44 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.channel_type = IEEE1609_ChannelType_SCH;
45 break;
46 default:
47 fnNetSimError("Unknown channel type %d for IEEE1609 protocol\n",
48 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.prevChannel);
49 break;
50 }
51 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.dStartTime = pstruEventDetails->dEventTime;
53 pstruEventDetails->nSubEventType = CHANNEL_SWITCH_START;
56
57 //restore
58 memcpy(pstruEventDetails, &pevent, sizeof* pstruEventDetails);
60}
61
63{
65 pstruEventDetails->nSubEventType = CHANNEL_SWITCH_END;
67 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.prevChannel =
68 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.channel_type;
69 GET_IEEE1609_CURR_MAC_VAR->CHANNEL_INFO.channel_type = IEEE1609_ChannelType_GUARD;
70}
unsigned int NETSIM_ID
Definition: Animation.h:45
void fn_NetSim_IEEE1609_ChannelSwitch_Start()
Definition: Channel.c:62
void Init_Channel_Switching(NETSIM_ID ndeviceId, NETSIM_ID nInterfaceId)
Definition: Channel.c:17
void fn_NetSim_IEEE1609_ChannelSwitch_End()
Definition: Channel.c:30
void restart_transmission()
Definition: IEEE1609.c:161
@ IEEE1609_ChannelType_GUARD
@ IEEE1609_ChannelType_CCH
@ IEEE1609_ChannelType_SCH
#define GET_IEEE1609_CURR_MAC_VAR
#define fnNetSimError(x,...)
Definition: Linux.h:56
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
@ MAC_PROTOCOL_IEEE1609
Definition: Stack.h:230
@ TIMER_EVENT
Definition: Stack.h:114
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
EVENT_TYPE nEventType
Definition: Stack.h:747
NETSIM_ID nProtocolId
Definition: Stack.h:748
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
NETSIM_ID nInterfaceId
Definition: Stack.h:751