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