-
Notifications
You must be signed in to change notification settings - Fork 4
/
dag.h
106 lines (84 loc) · 2.4 KB
/
dag.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Authors:
* Alexander Aring <alex.aring@gmail.com>
*
* This software is Copyright 2019 by the above mentioned author(s),
* All Rights Reserved.
*
* The license which is distributed with this software in the file COPYRIGHT
* applies to this software. If your distribution is missing this file, you
* may request it from <alex.aring@gmail.com>.
*/
#ifndef __RPLD_DAG_H__
#define __RPLD_DAG_H__
#include <stdint.h>
#include <string.h>
#include <ev.h>
#include "buffer.h"
#include "list.h"
struct peer {
struct in6_addr addr;
uint16_t rank;
struct list list;
};
struct child {
struct in6_addr addr;
struct in6_addr from;
struct list list;
};
struct dag_daoack {
uint8_t dsn;
struct list list;
};
struct dag {
uint8_t version;
/* trigger */
uint8_t dtsn;
/* if changed */
uint8_t dsn;
struct in6_addr dodagid;
struct in6_prefix dest;
uint16_t my_rank;
struct peer *parent;
/* routable self address */
struct in6_addr self;
/* routable childs, if .head NULL -> leaf */
struct list_head childs;
ev_tstamp trickle_t;
ev_timer trickle_w;
/* iface which dag belongs to */
const struct iface *iface;
/* rpl instance which dag belongs to */
const struct rpl *rpl;
/* TODO dodagid is optional so move it to instance?
*
* No idea how it works when it's not given. We don't
* support it.
*/
struct list_head pending_acks;
struct list list;
};
struct rpl {
uint8_t instance_id;
/* set of dags, unique key is dodagid */
struct list_head dags;
struct list list;
};
struct dag *dag_create(struct iface *iface, uint8_t instanceid,
const struct in6_addr *dodagid, ev_tstamp trickle_t,
uint16_t my_rank, uint8_t version,
const struct in6_prefix *dest);
void dag_free(struct dag *dag);
void dag_build_dio(struct dag *dag, struct safe_buffer *sb);
struct dag *dag_lookup(const struct iface *iface, uint8_t instance_id,
const struct in6_addr *dodagid);
void dag_process_dio(struct dag *dag);
struct peer *dag_peer_create(const struct in6_addr *addr);
void dag_build_dao(struct dag *dag, struct safe_buffer *sb);
void dag_build_dao_ack(struct dag *dag, struct safe_buffer *sb);
void dag_build_dis(struct safe_buffer *sb);
struct child *dag_lookup_child_or_create(struct dag *dag,
const struct in6_addr *addr,
const struct in6_addr *from);
bool dag_is_peer(const struct peer *peer, const struct in6_addr *addr);
#endif /* __RPLD_DAG_H__ */