Added new structures for the messages, the neighbours, and broke line
feed for a comment
This commit is contained in:
parent
35d50d178a
commit
fafebaa32f
12
src/node.c
12
src/node.c
@ -7,9 +7,10 @@ packet listen_for_packets(){
|
||||
|
||||
}
|
||||
|
||||
// We need to make sure the TLV announces a length that will no go onto
|
||||
// another tlv, as we might end up reading bullshit.
|
||||
int validate_tlvs(union tlv tlv_to_validate){
|
||||
// We need to make sure the TLV announces a length that will no go onto
|
||||
// another tlv, as we might end up reading bullshit.
|
||||
|
||||
}
|
||||
|
||||
void work_with_tlvs(struct tlvs_list receivied_tlvs){
|
||||
@ -17,7 +18,7 @@ void work_with_tlvs(struct tlvs_list receivied_tlvs){
|
||||
// For every TLV,
|
||||
// We make sure the TLV is legal.
|
||||
if(!validate_tlvs(tlv)){
|
||||
perror(">> Invalid TLV receivied, is will be ignored.");
|
||||
perror(">> Invalid TLV receivied, it will be ignored.");
|
||||
}
|
||||
|
||||
// Switch
|
||||
@ -52,11 +53,14 @@ void work_with_tlvs(struct tlvs_list receivied_tlvs){
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
int continue = 1;
|
||||
|
||||
while(CONTINUE){
|
||||
while(continue){
|
||||
|
||||
// We create the neighbourhood table
|
||||
neighbour_peer neighbour_list[NEIGHBOUR_MAX];
|
||||
// We create the message table
|
||||
|
||||
// We create our own message.
|
||||
|
||||
// Listen for incoming packets
|
||||
|
34
src/node.h
34
src/node.h
@ -3,6 +3,40 @@
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
// The node ID
|
||||
#define NODE_ID 203242402519736214145149136169422092269247115186189140178187251487819615911212154252117172522111472481308026129190139512419121015210238252292031613214452118122204415160254
|
||||
|
||||
// The number of neighbours
|
||||
// The neighbour table has 15 entries
|
||||
#define NEIGHBOUR_MAX 15
|
||||
|
||||
/* la table de voisins, qui est indexée par adresses de socket (des paires (IP, Port)),
|
||||
* et dont chaque entrée contient un booléen indiquant si le pair est permanent
|
||||
* (configuré au lancement) ou transitoire, et la date de dernière réception d’un
|
||||
* paquet de la part de ce pair ;
|
||||
*/
|
||||
typedef struct neighbour_peer {
|
||||
struct in6_addr ip;
|
||||
short port;
|
||||
char is_temporary;
|
||||
struct timeval last_seen;
|
||||
} neighbour_peer;
|
||||
|
||||
// The strucuture to hold the messages
|
||||
/* It's a list of triplets, (Li,Si,Di)
|
||||
* Li : The Node ID of the publisher 64 bits
|
||||
* Si : the sequence number 16 bits
|
||||
* Di : the data of the message 192 bytes
|
||||
*/
|
||||
|
||||
typedef struct message {
|
||||
long node_id_publisher;
|
||||
short seqno;
|
||||
char *data;
|
||||
} message;
|
||||
|
||||
// TODO
|
||||
|
||||
// fonctions signatures
|
||||
void listen_for_packets();
|
||||
|
||||
|
@ -10,7 +10,8 @@ cmd_token parse_cmd() {
|
||||
if(fgets(buf, 198, stdin) == NULL)
|
||||
return token;
|
||||
|
||||
// cmd sera le premier mot rencontré et arg la suite de mots après celui ci, si les deux variables ne sont pas remplies alors il y a une erreur
|
||||
// cmd sera le premier mot rencontré et arg la suite de mots après celui ci,
|
||||
// si les deux variables ne sont pas remplies alors il y a une erreur
|
||||
if(sscanf(buf, "%s %[^\t\n]", cmd, arg) != 2)
|
||||
return token;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user