00001 00002 /* 00003 * The olsr.org Optimized Link-State Routing daemon(olsrd) 00004 * Copyright (c) 2004-2009, the olsr.org team - see HISTORY file 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * * Neither the name of olsr.org, olsrd nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * Visit http://www.olsr.org for more information. 00035 * 00036 * If you find this software useful feel free to make a donation 00037 * to the project. For more information see the website or contact 00038 * the copyright holders. 00039 * 00040 */ 00041 00042 00043 /* 00044 * olsr.org olsr daemon security plugin 00045 */ 00046 00047 #ifndef _OLSRD_SECURE_MSG 00048 #define _OLSRD_SECURE_MSG 00049 00050 00051 #include <sys/types.h> 00052 #include <sys/socket.h> 00053 #include <netinet/in.h> 00054 #include <arpa/inet.h> 00055 #include <stdio.h> 00056 00057 #include "olsr_types.h" 00058 #include "interfaces.h" 00059 00060 /* The type of message you will use */ 00061 #define MESSAGE_TYPE 10 00062 00063 /* The type of messages we will receive - can be set to promiscuous */ 00064 #define PARSER_TYPE MESSAGE_TYPE 00065 00066 #define TYPE_CHALLENGE 11 00067 #define TYPE_CRESPONSE 12 00068 #define TYPE_RRESPONSE 13 00069 00070 00071 extern char keyfile[FILENAME_MAX + 1]; 00072 00073 00074 #ifdef USE_OPENSSL 00075 #define SIGSIZE 20 00076 #else 00077 #define SIGSIZE 16 00078 #endif 00079 00080 /**************************************************************************** 00081 * PACKET SECTION * 00082 ****************************************************************************/ 00083 00084 struct sig_msg { 00085 uint8_t type; 00086 uint8_t algorithm; 00087 uint16_t reserved; 00088 00089 time_t timestamp; 00090 uint8_t signature[SIGSIZE]; 00091 }; 00092 00093 /* 00094 * OLSR message (several can exist in one OLSR packet) 00095 */ 00096 00097 struct s_olsrmsg { 00098 uint8_t olsr_msgtype; 00099 uint8_t olsr_vtime; 00100 uint16_t olsr_msgsize; 00101 uint32_t originator; 00102 uint8_t ttl; 00103 uint8_t hopcnt; 00104 uint16_t seqno; 00105 00106 /* YOUR PACKET GOES HERE */ 00107 struct sig_msg sig; 00108 00109 }; 00110 00111 00112 /* 00113 * Challenge response messages 00114 */ 00115 00116 struct challengemsg { 00117 uint8_t olsr_msgtype; 00118 uint8_t olsr_vtime; 00119 uint16_t olsr_msgsize; 00120 uint32_t originator; 00121 uint8_t ttl; 00122 uint8_t hopcnt; 00123 uint16_t seqno; 00124 00125 uint32_t destination; 00126 uint32_t challenge; 00127 00128 uint8_t signature[SIGSIZE]; 00129 00130 }; 00131 00132 00133 00134 struct c_respmsg { 00135 uint8_t olsr_msgtype; 00136 uint8_t olsr_vtime; 00137 uint16_t olsr_msgsize; 00138 uint32_t originator; 00139 uint8_t ttl; 00140 uint8_t hopcnt; 00141 uint16_t seqno; 00142 00143 uint32_t destination; 00144 uint32_t challenge; 00145 time_t timestamp; 00146 00147 uint8_t res_sig[SIGSIZE]; 00148 00149 uint8_t signature[SIGSIZE]; 00150 }; 00151 00152 00153 struct r_respmsg { 00154 uint8_t olsr_msgtype; 00155 uint8_t olsr_vtime; 00156 uint16_t olsr_msgsize; 00157 uint32_t originator; 00158 uint8_t ttl; 00159 uint8_t hopcnt; 00160 uint16_t seqno; 00161 00162 uint32_t destination; 00163 time_t timestamp; 00164 00165 uint8_t res_sig[SIGSIZE]; 00166 00167 uint8_t signature[SIGSIZE]; 00168 }; 00169 00170 00171 /* 00172 *IPv6 00173 */ 00174 00175 struct s_olsrmsg6 { 00176 uint8_t olsr_msgtype; 00177 uint8_t olsr_vtime; 00178 uint16_t olsr_msgsize; 00179 struct in6_addr originator; 00180 uint8_t ttl; 00181 uint8_t hopcnt; 00182 uint16_t seqno; 00183 00184 /* YOUR PACKET GOES HERE */ 00185 struct sig_msg sig; 00186 }; 00187 00188 /* 00189 * Generic OLSR packet - DO NOT ALTER 00190 */ 00191 00192 struct s_olsr { 00193 uint16_t olsr_packlen; /* packet length */ 00194 uint16_t olsr_seqno; 00195 struct s_olsrmsg olsr_msg[1]; /* variable messages */ 00196 }; 00197 00198 00199 struct s_olsr6 { 00200 uint16_t olsr_packlen; /* packet length */ 00201 uint16_t olsr_seqno; 00202 struct s_olsrmsg6 olsr_msg[1]; /* variable messages */ 00203 }; 00204 00205 00206 #endif 00207 00208 /* 00209 * Local Variables: 00210 * c-basic-offset: 2 00211 * indent-tabs-mode: nil 00212 * End: 00213 */
1.6.3