mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 22:13:52 +01:00
Four macros changed to static inline type functions and style fixes
This commit is contained in:
parent
2634b3c400
commit
85d8cd8e0a
@ -39,10 +39,10 @@
|
||||
#define DAO_ACK_D_LEN 24
|
||||
#define RPL_OPT_LEN 2
|
||||
#define RPL_OPT_DODAG_CONF_LEN 14
|
||||
#define RPL_OPT_PREFIX_INFO_LEN 30
|
||||
#define RPL_OPT_SOLICITED_INFO_LEN 19
|
||||
#define RPL_OPT_TARGET_LEN 18
|
||||
#define RPL_OPT_TRANSIT_LEN 4
|
||||
#define RPL_OPT_PREFIX_INFO_LEN 30
|
||||
#define RPL_OPT_SOLICITED_INFO_LEN 19
|
||||
#define RPL_OPT_TARGET_LEN 18
|
||||
#define RPL_OPT_TRANSIT_LEN 4
|
||||
|
||||
/* message options */
|
||||
#define RPL_OPT_PAD1 0
|
||||
@ -60,11 +60,27 @@
|
||||
#define RPL_COUNTER_MAX 255
|
||||
#define RPL_COUNTER_LOWER_REGION 127
|
||||
#define RPL_COUNTER_SEQ_WINDOW 16
|
||||
#define RPL_COUNTER_INIT RPL_COUNTER_MAX - RPL_COUNTER_SEQ_WINDOW + 1
|
||||
#define RPL_COUNTER_INCREMENT(counter) (counter > RPL_COUNTER_LOWER_REGION ? (counter == RPL_COUNTER_MAX ? counter=0 : ++counter) : (counter == RPL_COUNTER_LOWER_REGION ? counter=0 : ++counter))
|
||||
#define RPL_COUNTER_IS_INIT(counter) (counter > RPL_COUNTER_LOWER_REGION)
|
||||
#define RPL_COUNTER_GREATER_THAN_LOCAL(A,B) (((A<B) && (RPL_COUNTER_LOWER_REGION + 1 - B + A < RPL_COUNTER_SEQ_WINDOW)) || ((A > B) && (A-B < RPL_COUNTER_SEQ_WINDOW)))
|
||||
#define RPL_COUNTER_GREATER_THAN(A,B) ((A>RPL_COUNTER_LOWER_REGION) ? ((B > RPL_COUNTER_LOWER_REGION ) ? RPL_COUNTER_GREATER_THAN_LOCAL(A,B) : 0): (( B>RPL_COUNTER_LOWER_REGION ) ? 1: RPL_COUNTER_GREATER_THAN_LOCAL(A,B)))
|
||||
#define RPL_COUNTER_INIT (RPL_COUNTER_MAX - RPL_COUNTER_SEQ_WINDOW + 1)
|
||||
|
||||
static inline uint8_t RPL_COUNTER_INCREMENT(uint8_t counter)
|
||||
{
|
||||
return (counter > RPL_COUNTER_LOWER_REGION ? (counter == RPL_COUNTER_MAX ? counter=0 : ++counter) : (counter == RPL_COUNTER_LOWER_REGION ? counter=0 : ++counter));
|
||||
}
|
||||
|
||||
static inline bool RPL_COUNTER_IS_INIT(uint8_t counter)
|
||||
{
|
||||
return (counter > RPL_COUNTER_LOWER_REGION);
|
||||
}
|
||||
|
||||
static inline bool RPL_COUNTER_GREATER_THAN_LOCAL(uint8_t A,uint8_t B)
|
||||
{
|
||||
return (((A<B) && (RPL_COUNTER_LOWER_REGION + 1 - B + A < RPL_COUNTER_SEQ_WINDOW)) || ((A > B) && (A-B < RPL_COUNTER_SEQ_WINDOW)));
|
||||
}
|
||||
|
||||
static inline bool RPL_COUNTER_GREATER_THAN(uint8_t A,uint8_t B)
|
||||
{
|
||||
return ((A>RPL_COUNTER_LOWER_REGION) ? ((B > RPL_COUNTER_LOWER_REGION ) ? RPL_COUNTER_GREATER_THAN_LOCAL(A,B) : 0): (( B>RPL_COUNTER_LOWER_REGION ) ? 1: RPL_COUNTER_GREATER_THAN_LOCAL(A,B)));
|
||||
}
|
||||
|
||||
/* Node Status */
|
||||
#define NORMAL_NODE 0
|
||||
@ -117,4 +133,4 @@
|
||||
#define RPL_GROUNDED_SHIFT 7
|
||||
#define RPL_DEFAULT_OCP 0
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -62,16 +62,13 @@ struct __attribute__((packed)) dodag_id_t {
|
||||
};
|
||||
|
||||
/* RPL-Option Generic Format (RFC 6550 Fig. 19) */
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
}
|
||||
rpl_opt_t;
|
||||
} rpl_opt_t;
|
||||
|
||||
/* DODAG Configuration-Option (RFC 6550 Fig. 24) */
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
uint8_t flags_a_pcs;
|
||||
@ -84,44 +81,37 @@ typedef struct __attribute__((packed))
|
||||
uint8_t reserved;
|
||||
uint8_t default_lifetime;
|
||||
uint16_t lifetime_unit;
|
||||
}
|
||||
rpl_opt_dodag_conf_t;
|
||||
} rpl_opt_dodag_conf_t;
|
||||
|
||||
/* RPL Solicited Information Option (RFC 6550 Fig. 28) */
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
uint8_t rplinstanceid;
|
||||
uint8_t VID_Flags;
|
||||
ipv6_addr_t dodagid;
|
||||
uint8_t version;
|
||||
}
|
||||
rpl_opt_solicited_t;
|
||||
} rpl_opt_solicited_t;
|
||||
|
||||
/* RPL Target-Option (RFC 6550 Fig. 25) */
|
||||
/* TODO: ipv6_addr_t target may be replaced by a target prefix of variable length */
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
uint8_t flags;
|
||||
uint8_t prefix_length;
|
||||
ipv6_addr_t target;
|
||||
}
|
||||
rpl_opt_target_t;
|
||||
} rpl_opt_target_t;
|
||||
|
||||
/* RPL Transit-Option (RFC 6550 Fig. 26) */
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
uint8_t e_flags;
|
||||
uint8_t path_control;
|
||||
uint8_t path_sequence;
|
||||
uint8_t path_lifetime;
|
||||
}
|
||||
rpl_opt_transit_t;
|
||||
} rpl_opt_transit_t;
|
||||
|
||||
struct rpl_dodag_t;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user