collect.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef __COLLECT_H__
00061 #define __COLLECT_H__
00062
00063 #include "net/rime/announcement.h"
00064 #include "net/rime/runicast.h"
00065 #include "net/rime/neighbor-discovery.h"
00066 #include "net/rime/collect-neighbor.h"
00067 #include "net/packetqueue.h"
00068 #include "sys/ctimer.h"
00069 #include "lib/list.h"
00070
00071 #define COLLECT_PACKET_ID_BITS 8
00072
00073 #define COLLECT_ATTRIBUTES { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \
00074 { PACKETBUF_ATTR_EPACKET_ID, PACKETBUF_ATTR_BIT * COLLECT_PACKET_ID_BITS }, \
00075 { PACKETBUF_ATTR_PACKET_ID, PACKETBUF_ATTR_BIT * COLLECT_PACKET_ID_BITS }, \
00076 { PACKETBUF_ATTR_TTL, PACKETBUF_ATTR_BIT * 4 }, \
00077 { PACKETBUF_ATTR_HOPS, PACKETBUF_ATTR_BIT * 4 }, \
00078 { PACKETBUF_ATTR_MAX_REXMIT, PACKETBUF_ATTR_BIT * 5 }, \
00079 { PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_BIT }, \
00080 UNICAST_ATTRIBUTES
00081
00082 struct collect_callbacks {
00083 void (* recv)(const rimeaddr_t *originator, uint8_t seqno,
00084 uint8_t hops);
00085 };
00086
00087
00088
00089
00090 #ifndef COLLECT_CONF_ANNOUNCEMENTS
00091 #define COLLECT_ANNOUNCEMENTS 1
00092 #else
00093 #define COLLECT_ANNOUNCEMENTS COLLECT_CONF_ANNOUNCEMENTS
00094 #endif
00095
00096 struct collect_conn {
00097 struct unicast_conn unicast_conn;
00098 #if ! COLLECT_ANNOUNCEMENTS
00099 struct neighbor_discovery_conn neighbor_discovery_conn;
00100 #else
00101 struct announcement announcement;
00102 struct ctimer transmit_after_scan_timer;
00103 #endif
00104 const struct collect_callbacks *cb;
00105 struct ctimer retransmission_timer;
00106 LIST_STRUCT(send_queue_list);
00107 struct packetqueue send_queue;
00108 struct collect_neighbor_list neighbor_list;
00109
00110 struct ctimer keepalive_timer;
00111 clock_time_t keepalive_period;
00112
00113 struct ctimer proactive_probing_timer;
00114
00115 rimeaddr_t parent, current_parent;
00116 uint16_t rtmetric;
00117 uint8_t seqno;
00118 uint8_t sending, transmissions, max_rexmits;
00119 uint8_t eseqno;
00120 uint8_t is_router;
00121
00122 clock_time_t send_time;
00123 };
00124
00125 enum {
00126 COLLECT_NO_ROUTER,
00127 COLLECT_ROUTER,
00128 };
00129
00130 void collect_open(struct collect_conn *c, uint16_t channels,
00131 uint8_t is_router,
00132 const struct collect_callbacks *callbacks);
00133 void collect_close(struct collect_conn *c);
00134
00135 int collect_send(struct collect_conn *c, int rexmits);
00136
00137 void collect_set_sink(struct collect_conn *c, int should_be_sink);
00138
00139 int collect_depth(struct collect_conn *c);
00140 const rimeaddr_t *collect_parent(struct collect_conn *c);
00141
00142 void collect_set_keepalive(struct collect_conn *c, clock_time_t period);
00143
00144 void collect_print_stats(void);
00145
00146 #define COLLECT_MAX_DEPTH (COLLECT_LINK_ESTIMATE_UNIT * 64 - 1)
00147
00148 #endif
00149
00150