#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "coap.h"
Go to the source code of this file.
Data Structures | |
struct | content_type_t |
Macros | |
#define | FLAGS_BLOCK 0x01 |
#define | min(a, b) ((a) < (b) ? (a) : (b)) |
#define | HANDLE_BLOCK1(Pdu) |
#define | BUFSIZE 40 |
Typedefs | |
typedef unsigned char | method_t |
Functions | |
static void | set_timeout (coap_tick_t *timer, const unsigned int seconds) |
int | append_to_output (const unsigned char *data, size_t len) |
void | close_output () |
coap_pdu_t * | new_ack (coap_context_t *ctx, coap_queue_t *node) |
coap_pdu_t * | new_response (coap_context_t *ctx, coap_queue_t *node, unsigned int code) |
coap_pdu_t * | coap_new_request (coap_context_t *ctx, method_t m, coap_list_t *options) |
coap_tid_t | clear_obs (coap_context_t *ctx, const coap_address_t *remote) |
int | resolve_address (const str *server, struct sockaddr *dst) |
static coap_opt_t * | get_block (coap_pdu_t *pdu, coap_opt_iterator_t *opt_iter) |
int | check_token (coap_pdu_t *received) |
void | message_handler (struct coap_context_t *ctx, const coap_address_t *remote, coap_pdu_t *sent, coap_pdu_t *received, const coap_tid_t id) |
void | usage (const char *program, const char *version) |
int | join (coap_context_t *ctx, char *group_name) |
int | order_opts (void *a, void *b) |
coap_list_t * | new_option_node (unsigned short key, unsigned int length, unsigned char *data) |
void | cmdline_content_type (char *arg, unsigned short key) |
void | cmdline_uri (char *arg) |
int | cmdline_blocksize (char *arg) |
void | set_blocksize () |
void | cmdline_subscribe (char *arg) |
int | cmdline_proxy (char *arg) |
void | cmdline_token (char *arg) |
void | cmdline_option (char *arg) |
int | check_segment (const unsigned char *s, size_t length) |
Runs through the given path (or query) segment and checks if percent-encodings are correct. More... | |
void | decode_segment (const unsigned char *seg, size_t length, unsigned char *buf) |
Decodes percent-encoded characters while copying the string seg of size length to buf . More... | |
int | cmdline_input (char *text, str *buf) |
int | cmdline_input_from_file (char *filename, str *buf) |
method_t | cmdline_method (char *arg) |
coap_context_t * | get_context (const char *node, const char *port) |
int | main (int argc, char **argv) |
Variables | |
int | flags = 0 |
static unsigned char | _token_data [8] |
str | the_token = { 0, _token_data } |
static coap_list_t * | optlist = NULL |
static coap_uri_t | uri |
static str | proxy = { 0, NULL } |
static unsigned short | proxy_port = COAP_DEFAULT_PORT |
static int | ready = 0 |
static str | output_file = { 0, NULL } |
static FILE * | file = NULL |
static str | payload = { 0, NULL } |
unsigned char | msgtype = COAP_MESSAGE_CON |
method_t | method = 1 |
coap_block_t | block = { .num = 0, .m = 0, .szx = 6 } |
unsigned int | wait_seconds = 90 |
coap_tick_t | max_wait |
unsigned int | obs_seconds = 30 |
coap_tick_t | obs_wait = 0 |
#define BUFSIZE 40 |
#define HANDLE_BLOCK1 | ( | Pdu | ) |
int append_to_output | ( | const unsigned char * | data, |
size_t | len | ||
) |
int check_segment | ( | const unsigned char * | s, |
size_t | length | ||
) |
|
inline |
coap_tid_t clear_obs | ( | coap_context_t * | ctx, |
const coap_address_t * | remote | ||
) |
void cmdline_content_type | ( | char * | arg, |
unsigned short | key | ||
) |
coap_pdu_t* coap_new_request | ( | coap_context_t * | ctx, |
method_t | m, | ||
coap_list_t * | options | ||
) |
void decode_segment | ( | const unsigned char * | seg, |
size_t | length, | ||
unsigned char * | buf | ||
) |
Decodes percent-encoded characters while copying the string seg
of size length
to buf
.
The caller of this function must ensure that the percent-encodings are correct (i.e. the character '' is always followed by two hex digits. and that buf
provides sufficient space to hold the result. This function is supposed to be called by make_decoded_option() only.
seg | The segment to decode and copy. |
length | Length of seg . |
buf | The result buffer. |
|
inlinestatic |
coap_context_t* get_context | ( | const char * | node, |
const char * | port | ||
) |
int join | ( | coap_context_t * | ctx, |
char * | group_name | ||
) |
void message_handler | ( | struct coap_context_t * | ctx, |
const coap_address_t * | remote, | ||
coap_pdu_t * | sent, | ||
coap_pdu_t * | received, | ||
const coap_tid_t | id | ||
) |
coap_pdu_t* new_ack | ( | coap_context_t * | ctx, |
coap_queue_t * | node | ||
) |
coap_list_t* new_option_node | ( | unsigned short | key, |
unsigned int | length, | ||
unsigned char * | data | ||
) |
coap_pdu_t* new_response | ( | coap_context_t * | ctx, |
coap_queue_t * | node, | ||
unsigned int | code | ||
) |
int resolve_address | ( | const str * | server, |
struct sockaddr * | dst | ||
) |
|
inlinestatic |
coap_block_t block = { .num = 0, .m = 0, .szx = 6 } |
unsigned char msgtype = COAP_MESSAGE_CON |
|
static |
|
static |
str the_token = { 0, _token_data } |
|
static |