2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004-2009, the olsr.org team - see HISTORY file
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of olsr.org, olsrd nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * Visit http://www.olsr.org for more information.
35 * If you find this software useful feel free to make a donation
36 * to the project. For more information see the website or contact
37 * the copyright holders.
45 #define REMOVE_LOG_DEBUG
47 // Either #define or #undef the following line to include extra debugging
48 #undef INCLUDE_DEBUG_OUTPUT
50 #include "olsrd_plugin.h" /* union set_plugin_parameter_addon */
51 #include "duplicate_set.h"
52 //#include "socket_parser.h"
55 #define P2PD_MESSAGE_TYPE 132
56 #define PARSER_TYPE P2PD_MESSAGE_TYPE
57 #define P2PD_VALID_TIME 180 /* seconds */
59 /* P2PD plugin data */
60 #define PLUGIN_NAME "OLSRD P2PD plugin"
61 #define PLUGIN_NAME_SHORT "OLSRD P2PD"
62 #define PLUGIN_VERSION "0.1.0 (" __DATE__ " " __TIME__ ")"
63 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION
64 #define PLUGIN_INTERFACE_VERSION 5
65 #define IPHDR_FRAGMENT_MASK 0xC000
67 /* Forward declaration of OLSR interface type */
70 struct DupFilterEntry {
72 union olsr_ip_addr address;
80 union olsr_ip_addr address;
82 struct UdpDestPort * next;
86 extern int P2pdDuplicateTimeout;
87 extern int HighestSkfd;
88 extern fd_set InputSet;
89 extern struct UdpDestPort * UdpDestPortList;
90 extern struct DuplicateFilterEntry * FilterList;
92 void DoP2pd(int sd, void *x, unsigned int y);
93 void P2pdPError(const char *format, ...) __attribute__ ((format(printf, 1, 2)));
94 union olsr_ip_addr *MainAddressOf(union olsr_ip_addr *ip);
95 int InitP2pd(struct interface *skipThisIntf);
97 int SetP2pdTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused)));
98 int AddUdpDestPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused)));
99 bool InUdpDestPortList(int ip_version, union olsr_ip_addr *addr, uint16_t port);
100 int SetP2pdTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused)));
101 int SetP2pdUseHashFilter(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused)));
102 int SetP2pdUseTtlDecrement(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused)));
103 bool p2pd_message_seen(struct node **head, struct node **tail, union olsr_message *m);
104 void p2pd_store_message(struct node **head, struct node **tail, union olsr_message *m);
105 bool p2pd_is_duplicate_message(union olsr_message *msg);
107 void olsr_p2pd_gen(unsigned char *packet, int len);
109 /* Parser function to register with the scheduler */
110 bool olsr_parser(union olsr_message *, struct interface *, union olsr_ip_addr *);
117 * indent-tabs-mode: nil