NetSim Source Code Help
Loading...
Searching...
No Matches
CoAP.h
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: Siddharth Makadia *
12* *
13* ---------------------------------------------------------------------------------*/
14
15#include "main.h"
16#include "Stack.h"
17
18//CoAP Derived Protocol Parameters default values (in seconds)
19#define MAX_TRANSMIT_SPAN 45
20#define MAX_TRANSMIT_WAIT 93
21#define MAX_LATENCY 100
22#define PROCESSING_DELAY 2
23#define MAX_RTT 202
24#define EXCHANGE_LIFETIME 427
25#define NON_LIFETIME 145
26
27
28#define MESSAGE_SIZE_UPPER_BOUND 1152 //BYTES
29#define PAYLOAD_SIZE_UPPER_BOUND 1152 //BYTES
32
34
35
36/*
37A summary of the contents of the CoAP header as per RFC 7252 follows:
38
39 0 1 2 3
40 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
41 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 |Ver| T | TKL | Code | Message ID |
43 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 | Token (if any, TKL bytes) ...
45 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 | Options (if any) ...
47 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 |1 1 1 1 1 1 1 1| Payload (if any) ...
49 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50
51*/
52
53typedef enum
54{
60
61typedef enum
62{
69
70 unsigned int Request_messageID;
71 unsigned int Request_tokenValue;
72 unsigned int Response_messageID;
73 unsigned int Response_tokenValue;
74
75 unsigned int Response_Received;
76 unsigned int RequestACK_Received;
77 unsigned int Request_Received;
79
81 int _gz;
82
83};
85 unsigned int optionDelta : 4;
86 unsigned int optionLength : 4;
88};
90{
91 unsigned int Version : 2; // always 1
92 unsigned int Type : 2; // Confirmable (0), Non-confirmable (1), Acknowledgement (2), or Reset(3)
93 unsigned int TokenLength : 4; //length of tokenvalue field in bytes
94 unsigned int Code : 8; // request (0) , success response (2) , client error response (4) , server error response(5)
95 unsigned int MessageID : 16; //must be match for request and response ACK
96 unsigned int tokenvalue : 32; //must be a match for request and response message
98
99};
100
101
103
105
110int fn_NetSim_Application_COAP_Genrate_RequestPacket(ptrAPPLICATION_INFO appInfo, NETSIM_ID nSource, NETSIM_ID nDestination, double time, char* PacketType);
111int fn_NetSim_Application_COAP_Genrate_Packet(ptrAPPLICATION_INFO pstruappinfo, NETSIM_ID nSourceId, NETSIM_ID nDestinationId, double size, char* PacketType);
unsigned int NETSIM_ID
Definition: Animation.h:45
COAP_CODE
Definition: CoAP.h:62
@ SERVER_ERROR
Definition: CoAP.h:66
@ CLIENT_ERROR
Definition: CoAP.h:65
@ REQUEST
Definition: CoAP.h:63
@ RESPONSE
Definition: CoAP.h:64
int fn_NetSim_Application_COAP_Sent_ACK(ptrAPPLICATION_INFO pstruappinfo, NetSim_PACKET *pstruPacket)
Definition: CoAP.c:254
COAP_Header * fn_NetSim_Application_COAP_CopyHeader(COAP_Header *src)
Definition: CoAP.c:379
int fn_NetSim_Application_COAP_ProcessRequest(ptrAPPLICATION_INFO pstruappinfo, NetSim_PACKET *pstruPacket)
Definition: CoAP.c:210
int fn_NetSim_Application_StartCOAPAPP(ptrAPPLICATION_INFO appInfo, double time)
Definition: CoAP.c:170
int fn_NetSim_Application_COAP_Genrate_RequestPacket(ptrAPPLICATION_INFO appInfo, NETSIM_ID nSource, NETSIM_ID nDestination, double time, char *PacketType)
Definition: CoAP.c:284
COAP_TYPE
Definition: CoAP.h:54
@ NON_CONFIRMABLE
Definition: CoAP.h:56
@ RESET
Definition: CoAP.h:58
@ ACKNOWLEDGEMENT
Definition: CoAP.h:57
@ CONFIRMABLE
Definition: CoAP.h:55
COAP_Header * fn_NetSim_Application_COAP_GenrateHeader(APP_COAP_INFO *info)
Definition: CoAP.c:398
int fn_NetSim_Application_COAP_Genrate_Packet(ptrAPPLICATION_INFO pstruappinfo, NETSIM_ID nSourceId, NETSIM_ID nDestinationId, double size, char *PacketType)
Definition: CoAP.c:327
int fn_NetSim_Application_COAP_Start(ptrAPPLICATION_INFO appInfo, NetSim_EVENTDETAILS *pstruEventDetails)
Definition: CoAP.c:165
void fn_NetSim_Application_COAP_AppIn(ptrAPPLICATION_INFO pstruappinfo, NetSim_PACKET *pstruPacket)
Definition: CoAP.c:99
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
Structure to store the COAP application information.
Definition: Application.h:253
Structure to store application information.
Definition: Application.h:97
unsigned int Version
Definition: CoAP.h:91
unsigned int tokenvalue
Definition: CoAP.h:96
unsigned int Code
Definition: CoAP.h:94
unsigned int MessageID
Definition: CoAP.h:95
struct stru_NetSim_COAP_Options * Options
Definition: CoAP.h:97
unsigned int Type
Definition: CoAP.h:92
unsigned int TokenLength
Definition: CoAP.h:93
unsigned int optionLength
Definition: CoAP.h:86
unsigned int optionDelta
Definition: CoAP.h:85
unsigned int Response_tokenValue
Definition: CoAP.h:73
unsigned int Request_tokenValue
Definition: CoAP.h:71
unsigned int Request_messageID
Definition: CoAP.h:70
unsigned int Response_Received
Definition: CoAP.h:75
unsigned int RequestACK_Received
Definition: CoAP.h:76
unsigned int Request_Received
Definition: CoAP.h:77
unsigned int ResponseACK_Received
Definition: CoAP.h:78
unsigned int Response_messageID
Definition: CoAP.h:72