This commit is contained in:
gonzalef 2020-03-24 15:39:31 +01:00
parent 4ebed74a15
commit f4d3dcbd6d
4 changed files with 9 additions and 9 deletions

View File

@ -21,11 +21,11 @@ cmd_token parse_cmd() {
token.type = NETWORK_STATE_REQ; token.type = NETWORK_STATE_REQ;
else if(strcmp("node state", arg) == 0) else if(strcmp("node state", arg) == 0)
token.type = NODE_STATE_REQ; token.type = NODE_STATE_REQ;
} else if(strcmp("send", cmd) == 0) { } else if(strcmp("post", cmd) == 0) {
token.type = SEND; token.type = POST;
//arg[192] = 0; //arg[192] = 0;
strcpy(token.arg, arg); strcpy(token.arg, arg);
} }
return token; return token;
} }

View File

@ -2,7 +2,7 @@
#include <string.h> #include <string.h>
typedef enum cmd_type { typedef enum cmd_type {
NEIGHBOUR_REQ, NETWORK_STATE_REQ, NODE_STATE_REQ, SEND, ERROR NEIGHBOUR_REQ, NETWORK_STATE_REQ, NODE_STATE_REQ, POST, ERROR
} cmd_type; } cmd_type;
typedef struct cmd_token { typedef struct cmd_token {
@ -11,4 +11,4 @@ typedef struct cmd_token {
} cmd_token; } cmd_token;
// retourne le type de commande à exécuter // retourne le type de commande à exécuter
cmd_token parse_cmd(); cmd_token parse_cmd();

4
tlv.c
View File

@ -12,11 +12,11 @@ int build_tlv(tlv *tlv, cmd_token token) {
case NODE_STATE_REQ: case NODE_STATE_REQ:
// a remplir // a remplir
break; break;
case SEND: case POST:
// a remplir // a remplir
break; break;
case ERROR: case ERROR:
printf("Wrong format, use 'req {neighbour | network state | node state}' or 'send {message}'"); printf("Wrong format, use 'req {neighbour | network state | node state}' or 'post {message}'");
break; break;
} }
} }

4
tlv.h
View File

@ -20,7 +20,7 @@ typedef struct pad1 {
typedef struct padn { typedef struct padn {
unsigned char type; unsigned char type;
unsigned char length; unsigned char length;
char *mbz; char mbz[256];
} padn; } padn;
// 2 octets // 2 octets
@ -73,7 +73,7 @@ typedef struct node_state {
long node_id; long node_id;
short seqno; short seqno;
char node_hash[16]; char node_hash[16];
char *data; char data[192];
} node_state; } node_state;
// 2 octets min, 258 ocets max (unsigned char 0 -> 255) // 2 octets min, 258 ocets max (unsigned char 0 -> 255)