rpl.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #ifndef _RPL_H_
  2. /*
  3. * NOTE: the contents of this file are an interpretation of RFC6550.
  4. * no copyright is asserted on this file, as it transcribes
  5. * a public specification.
  6. *
  7. */
  8. /*
  9. * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
  10. */
  11. #define ND_RPL_MESSAGE 155 /* 0x9B */
  12. enum ND_RPL_CODE {
  13. ND_RPL_DAG_IS=0x00,
  14. ND_RPL_DAG_IO=0x01,
  15. ND_RPL_DAO =0x02,
  16. ND_RPL_DAO_ACK=0x03,
  17. ND_RPL_SEC_DAG_IS = 0x80,
  18. ND_RPL_SEC_DAG_IO = 0x81,
  19. ND_RPL_SEC_DAG = 0x82,
  20. ND_RPL_SEC_DAG_ACK= 0x83,
  21. ND_RPL_SEC_CONSIST= 0x8A
  22. };
  23. enum ND_RPL_DIO_FLAGS {
  24. ND_RPL_DIO_GROUNDED = 0x80,
  25. ND_RPL_DIO_DATRIG = 0x40,
  26. ND_RPL_DIO_DASUPPORT= 0x20,
  27. ND_RPL_DIO_RES4 = 0x10,
  28. ND_RPL_DIO_RES3 = 0x08,
  29. ND_RPL_DIO_PRF_MASK = 0x07 /* 3-bit preference */
  30. };
  31. #define DAGID_LEN 16
  32. /* section 6 of draft-ietf-roll-rpl-19 */
  33. struct nd_rpl_security {
  34. uint8_t rpl_sec_t_reserved; /* bit 7 is T-bit */
  35. uint8_t rpl_sec_algo;
  36. uint16_t rpl_sec_kim_lvl_flags; /* bit 15/14, KIM */
  37. /* bit 10-8, LVL, bit 7-0 flags */
  38. uint32_t rpl_sec_counter;
  39. #if 0
  40. uint8_t rpl_sec_ki[0]; /* depends upon kim */
  41. #endif
  42. };
  43. /* section 6.2.1, DODAG Information Solication (DIS_IS) */
  44. struct nd_rpl_dis_is {
  45. uint8_t rpl_dis_flags;
  46. uint8_t rpl_dis_reserved;
  47. #if 0
  48. uint8_t rpl_dis_options[0];
  49. #endif
  50. };
  51. /* section 6.3.1, DODAG Information Object (DIO) */
  52. struct nd_rpl_dio {
  53. uint8_t rpl_instanceid;
  54. uint8_t rpl_version;
  55. uint16_t rpl_dagrank;
  56. uint8_t rpl_mopprf; /* bit 7=G, 5-3=MOP, 2-0=PRF */
  57. uint8_t rpl_dtsn; /* Dest. Advertisement Trigger Sequence Number */
  58. uint8_t rpl_flags; /* no flags defined yet */
  59. uint8_t rpl_resv1;
  60. uint8_t rpl_dagid[DAGID_LEN];
  61. };
  62. #define RPL_DIO_GROUND_FLAG 0x80
  63. #define RPL_DIO_MOP_SHIFT 3
  64. #define RPL_DIO_MOP_MASK (7 << RPL_DIO_MOP_SHIFT)
  65. #define RPL_DIO_PRF_SHIFT 0
  66. #define RPL_DIO_PRF_MASK (7 << RPL_DIO_PRF_SHIFT)
  67. #define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
  68. #define RPL_DIO_MOP(X) (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
  69. #define RPL_DIO_PRF(X) (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
  70. enum RPL_DIO_MOP {
  71. RPL_DIO_NONSTORING= 0x0,
  72. RPL_DIO_STORING = 0x1,
  73. RPL_DIO_NONSTORING_MULTICAST = 0x2,
  74. RPL_DIO_STORING_MULTICAST = 0x3
  75. };
  76. enum RPL_SUBOPT {
  77. RPL_OPT_PAD0 = 0,
  78. RPL_OPT_PADN = 1,
  79. RPL_DIO_METRICS = 2,
  80. RPL_DIO_ROUTINGINFO = 3,
  81. RPL_DIO_CONFIG = 4,
  82. RPL_DAO_RPLTARGET = 5,
  83. RPL_DAO_TRANSITINFO = 6,
  84. RPL_DIO_DESTPREFIX = 8,
  85. RPL_DAO_RPLTARGET_DESC=9
  86. };
  87. struct rpl_dio_genoption {
  88. uint8_t rpl_dio_type;
  89. uint8_t rpl_dio_len; /* suboption length, not including type/len */
  90. };
  91. #define RPL_DIO_GENOPTION_LEN 2
  92. #define RPL_DIO_LIFETIME_INFINITE 0xffffffff
  93. #define RPL_DIO_LIFETIME_DISCONNECT 0
  94. struct rpl_dio_destprefix {
  95. uint8_t rpl_dio_type;
  96. uint8_t rpl_dio_len;
  97. uint8_t rpl_dio_prefixlen; /* in bits */
  98. uint8_t rpl_dio_prf; /* flags, including Route Preference */
  99. uint32_t rpl_dio_prefixlifetime; /* in seconds */
  100. #if 0
  101. uint8_t rpl_dio_prefix[0]; /* variable number of bytes */
  102. #endif
  103. };
  104. /* section 6.4.1, DODAG Information Object (DIO) */
  105. struct nd_rpl_dao {
  106. uint8_t rpl_instanceid;
  107. uint8_t rpl_flags; /* bit 7=K, 6=D */
  108. uint8_t rpl_resv;
  109. uint8_t rpl_daoseq;
  110. uint8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
  111. };
  112. #define ND_RPL_DAO_MIN_LEN 4 /* length without DAGID */
  113. /* indicates if this DAO is to be acK'ed */
  114. #define RPL_DAO_K_SHIFT 7
  115. #define RPL_DAO_K_MASK (1 << RPL_DAO_K_SHIFT)
  116. #define RPL_DAO_K(X) (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
  117. /* indicates if the DAGID is present */
  118. #define RPL_DAO_D_SHIFT 6
  119. #define RPL_DAO_D_MASK (1 << RPL_DAO_D_SHIFT)
  120. #define RPL_DAO_D(X) (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
  121. struct rpl_dao_target {
  122. uint8_t rpl_dao_type;
  123. uint8_t rpl_dao_len;
  124. uint8_t rpl_dao_flags; /* unused */
  125. uint8_t rpl_dao_prefixlen; /* in bits */
  126. #if 0
  127. uint8_t rpl_dao_prefix[0]; /* variable number of bytes */
  128. #endif
  129. };
  130. /* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
  131. struct nd_rpl_daoack {
  132. uint8_t rpl_instanceid;
  133. uint8_t rpl_flags; /* bit 7=D */
  134. uint8_t rpl_daoseq;
  135. uint8_t rpl_status;
  136. uint8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
  137. };
  138. #define ND_RPL_DAOACK_MIN_LEN 4 /* length without DAGID */
  139. /* indicates if the DAGID is present */
  140. #define RPL_DAOACK_D_SHIFT 7
  141. #define RPL_DAOACK_D_MASK (1 << RPL_DAOACK_D_SHIFT)
  142. #define RPL_DAOACK_D(X) (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
  143. #define _RPL_H_
  144. #endif /* _RPL_H_ */
  145. /*
  146. * Local Variables:
  147. * c-basic-offset:4
  148. * c-style: whitesmith
  149. * End:
  150. */