diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-02 23:13:00 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-02 23:13:00 +0200 |
commit | 4a4482017978e360a0ae1ca7645e5e9e084c92b4 (patch) | |
tree | 2805b517bff7182ab3b180c6d68bca789df036ae /ffd/ffd.h | |
parent | e03169f8594f890162be16f72ea7000f802a252e (diff) | |
download | ffd-4a4482017978e360a0ae1ca7645e5e9e084c92b4.tar ffd-4a4482017978e360a0ae1ca7645e5e9e084c92b4.zip |
Add data structures to store announcements and partly implement updates
Diffstat (limited to 'ffd/ffd.h')
-rw-r--r-- | ffd/ffd.h | 62 |
1 files changed, 59 insertions, 3 deletions
@@ -41,13 +41,64 @@ #define FFD_IHU_INTERVAL (3*FFD_HELLO_INTERVAL) +typedef struct __attribute__((packed)) _ffd_node_id_t { + uint8_t id[8]; +} ffd_node_id_t; + + +#define FFD_NODE_ID_UNSPEC ((ffd_node_id_t){}) + + +static inline bool ffd_is_node_id_unspec(const ffd_node_id_t *node) { + const uint8_t *id = node->id; + + if (id[0]||id[1]||id[2]||id[3]||id[4]||id[5]||id[6]||id[7]) + return false; + else + return true; +} + +static inline bool ffd_are_node_ids_equal(const ffd_node_id_t *id1, const ffd_node_id_t *id2) { + const uint8_t *a = id1->id; + const uint8_t *b = id2->id; + + return (a[0]==b[0] && a[1]==b[1] && a[2]==b[2] && a[3]==b[3] + && a[4]==b[4] && a[5]==b[5] && a[6]==b[6] && a[7]==b[7]); +} + + +typedef struct _ffd_metric_seqno_t { + uint16_t metric; + uint16_t seqno; +} ffd_metric_seqno_t; + +#define FFD_IS_INFINITY(m) ((m).metric == 0xffff) + +typedef struct _ffd_nexthop_t { + struct _ffd_nexthop_t *next; + + struct timespec last_update; + eth_addr_t addr; + ffd_metric_seqno_t metric_seqno; +} ffd_nexthop_t; + typedef struct _ffd_announce_t { struct _ffd_announce_t *next; - uint8_t type; + ffd_node_id_t node; + uint16_t type; + uint16_t key; + uint16_t interval; + uint8_t len; + + ffd_metric_seqno_t feasability_distance; + + ffd_nexthop_t *selected; + ffd_nexthop_t *nexthop_list; + uint8_t data[]; -} ffd_announce_head_t; +} ffd_announce_t; typedef struct _ffd_neigh_t { struct _ffd_neigh_t *next; @@ -80,12 +131,17 @@ typedef struct _ffd_iface_t { extern const eth_addr_t ffd_addr; extern ffd_iface_t *iface_list; +extern ffd_announce_t *announce_list; extern int sockfd; extern struct timespec now; +ffd_metric_seqno_t ffd_announce_get_metric(const ffd_announce_t *announce); +ffd_announce_t* ffd_announce_new(); + void ffd_send_hellos(); -void ffd_send_announce_request(ffd_iface_t *iface, ffd_neigh_t *neigh, void *announce); +void ffd_send_update(ffd_iface_t *iface, ffd_neigh_t *neigh, const ffd_announce_t *announce); +void ffd_send_announce_request(ffd_iface_t *iface, ffd_neigh_t *neigh, ffd_node_id_t node, uint16_t type, uint16_t key); #endif /* _FFD_FFD_H_ */ |