3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2004, Andreas Tonnesen(andreto@olsr.org)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of olsr.org, olsrd nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * Visit http://www.olsr.org for more information.
36 * If you find this software useful feel free to make a donation
37 * to the project. For more information see the website or contact
38 * the copyright holders.
42 #ifndef _OLSR_MSG_PARSER
43 #define _OLSR_MSG_PARSER
45 #include "olsr_protocol.h"
48 #define PROMISCUOUS 0xffffffff
50 /* Function returns false if the message should not be forwarded */
51 typedef bool parse_function(union olsr_message *, struct interface *, union olsr_ip_addr *);
53 struct parse_function_entry {
54 uint32_t type; /* If set to PROMISCUOUS all messages will be received */
55 parse_function *function;
56 struct parse_function_entry *next;
59 typedef char *preprocessor_function(char *packet, struct interface *, union olsr_ip_addr *, int *length);
61 struct preprocessor_function_entry {
62 preprocessor_function *function;
63 struct preprocessor_function_entry *next;
66 typedef void packetparser_function(struct olsr *olsr, struct interface *in_if, union olsr_ip_addr *from_addr);
68 struct packetparser_function_entry {
69 packetparser_function *function;
70 struct packetparser_function_entry *next;
73 void parser_set_disp_pack_in(bool);
75 void olsr_init_parser(void);
77 void olsr_destroy_parser(void);
79 void olsr_input(int fd, void *, unsigned int);
81 void olsr_input_hostemu(int fd, void *, unsigned int);
83 void olsr_parser_add_function(parse_function, uint32_t);
85 int olsr_parser_remove_function(parse_function, uint32_t);
87 void olsr_preprocessor_add_function(preprocessor_function);
89 int olsr_preprocessor_remove_function(preprocessor_function);
91 void olsr_packetparser_add_function(packetparser_function * function);
93 int olsr_packetparser_remove_function(packetparser_function * function);
95 void parse_packet(struct olsr *, int, struct interface *, union olsr_ip_addr *);