Smart Home firewall
Profile-based Smart Home firewall
coap.h
Go to the documentation of this file.
1 
10 #ifndef _PROTOCOL_PARSERS_COAP_
11 #define _PROTOCOL_PARSERS_COAP_
12 
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <string.h>
17 #include <arpa/inet.h>
18 #include "http.h"
19 
20 
24 typedef enum
25 {
26  COAP_CON = 0,
27  COAP_NON = 1,
28  COAP_ACK = 2,
29  COAP_RST = 3
30 } coap_type_t;
31 
35 typedef enum
36 {
37  COAP_URI_PATH = 11,
38  COAP_URI_QUERY = 15
40 
44 typedef struct coap_message
45 {
46  coap_type_t type; // CoAP message type
47  http_method_t method; // CoAP method, analogous to HTTP
48  char *uri; // Message URI
49  uint16_t uri_len; // URI length
51 
52 
54 
56 
64 coap_message_t coap_parse_message(uint8_t *data, uint16_t length);
65 
66 
68 
74 void coap_free_message(coap_message_t message);
75 
76 
78 
85 
86 
87 #endif /* _PROTOCOL_PARSERS_COAP_ */
void coap_print_message(coap_message_t message)
Print a CoAP message.
Definition: coap.c:195
coap_message_t coap_parse_message(uint8_t *data, uint16_t length)
Parse a CoAP message.
Definition: coap.c:135
struct coap_message coap_message_t
Abstraction of a CoAP message.
coap_option_t
CoAP Option number.
Definition: coap.h:36
void coap_free_message(coap_message_t message)
Free the memory allocated for a CoAP message.
Definition: coap.c:157
coap_type_t
CoAP message type.
Definition: coap.h:25
HTTP message parser.
http_method_t
Definition: http.h:27
Abstraction of a CoAP message.
Definition: coap.h:45