PageRenderTime 25ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/secure/src/secure_messages.h

https://bitbucket.org/clauz/olsrd-ccninfo
C Header | 201 lines | 100 code | 38 blank | 63 comment | 0 complexity | 7b57225825846607b159ca509dd8637a MD5 | raw file
  1. /*
  2. * Secure OLSR plugin
  3. * http://www.olsr.org
  4. *
  5. * Copyright (c) 2004, Andreas Tonnesen(andreto@olsr.org)
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or
  9. * without modification, are permitted provided that the following
  10. * conditions are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * * Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * * Neither the name of olsrd, olsr.org nor the names of its
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  30. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. */
  36. /*
  37. * olsr.org olsr daemon security plugin
  38. */
  39. #ifndef _OLSRD_SECURE_MSG
  40. #define _OLSRD_SECURE_MSG
  41. #include <sys/types.h>
  42. #include <sys/socket.h>
  43. #include <netinet/in.h>
  44. #include <arpa/inet.h>
  45. #include <sys/time.h>
  46. #include <time.h>
  47. #include <math.h>
  48. #include <stdio.h>
  49. #include "olsr_types.h"
  50. #include "interfaces.h"
  51. /* The type of message you will use */
  52. #define MESSAGE_TYPE 10
  53. /* The type of messages we will receive - can be set to promiscuous */
  54. #define PARSER_TYPE MESSAGE_TYPE
  55. #define TYPE_CHALLENGE 11
  56. #define TYPE_CRESPONSE 12
  57. #define TYPE_RRESPONSE 13
  58. extern char keyfile[FILENAME_MAX + 1];
  59. #ifdef USE_OPENSSL
  60. #define SIGSIZE 20
  61. #else
  62. #define SIGSIZE 16
  63. #endif
  64. /****************************************************************************
  65. * PACKET SECTION *
  66. ****************************************************************************/
  67. struct sig_msg {
  68. uint8_t type;
  69. uint8_t algorithm;
  70. uint16_t reserved;
  71. time_t timestamp;
  72. uint8_t signature[SIGSIZE];
  73. };
  74. /*
  75. * OLSR message (several can exist in one OLSR packet)
  76. */
  77. struct s_olsrmsg {
  78. uint8_t olsr_msgtype;
  79. uint8_t olsr_vtime;
  80. uint16_t olsr_msgsize;
  81. uint32_t originator;
  82. uint8_t ttl;
  83. uint8_t hopcnt;
  84. uint16_t seqno;
  85. /* YOUR PACKET GOES HERE */
  86. struct sig_msg sig;
  87. };
  88. /*
  89. * Challenge response messages
  90. */
  91. struct challengemsg {
  92. uint8_t olsr_msgtype;
  93. uint8_t olsr_vtime;
  94. uint16_t olsr_msgsize;
  95. uint32_t originator;
  96. uint8_t ttl;
  97. uint8_t hopcnt;
  98. uint16_t seqno;
  99. uint32_t destination;
  100. uint32_t challenge;
  101. uint8_t signature[SIGSIZE];
  102. };
  103. struct c_respmsg {
  104. uint8_t olsr_msgtype;
  105. uint8_t olsr_vtime;
  106. uint16_t olsr_msgsize;
  107. uint32_t originator;
  108. uint8_t ttl;
  109. uint8_t hopcnt;
  110. uint16_t seqno;
  111. uint32_t destination;
  112. uint32_t challenge;
  113. time_t timestamp;
  114. uint8_t res_sig[SIGSIZE];
  115. uint8_t signature[SIGSIZE];
  116. };
  117. struct r_respmsg {
  118. uint8_t olsr_msgtype;
  119. uint8_t olsr_vtime;
  120. uint16_t olsr_msgsize;
  121. uint32_t originator;
  122. uint8_t ttl;
  123. uint8_t hopcnt;
  124. uint16_t seqno;
  125. uint32_t destination;
  126. time_t timestamp;
  127. uint8_t res_sig[SIGSIZE];
  128. uint8_t signature[SIGSIZE];
  129. };
  130. /*
  131. *IPv6
  132. */
  133. struct s_olsrmsg6 {
  134. uint8_t olsr_msgtype;
  135. uint8_t olsr_vtime;
  136. uint16_t olsr_msgsize;
  137. struct in6_addr originator;
  138. uint8_t ttl;
  139. uint8_t hopcnt;
  140. uint16_t seqno;
  141. /* YOUR PACKET GOES HERE */
  142. struct sig_msg sig;
  143. };
  144. /*
  145. * Generic OLSR packet - DO NOT ALTER
  146. */
  147. struct s_olsr {
  148. uint16_t olsr_packlen; /* packet length */
  149. uint16_t olsr_seqno;
  150. struct s_olsrmsg olsr_msg[1]; /* variable messages */
  151. };
  152. struct s_olsr6 {
  153. uint16_t olsr_packlen; /* packet length */
  154. uint16_t olsr_seqno;
  155. struct s_olsrmsg6 olsr_msg[1]; /* variable messages */
  156. };
  157. #endif
  158. /*
  159. * Local Variables:
  160. * c-basic-offset: 2
  161. * indent-tabs-mode: nil
  162. * End:
  163. */