1 /*
2  * The olsr.org Optimized Link-State Routing daemon (olsrd)
3  *
4  * (c) by the OLSR project
5  *
6  * See our Git repository to find out who worked on this file
7  * and thus is a copyright holder on it.
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  *   notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above copyright
18  *   notice, this list of conditions and the following disclaimer in
19  *   the documentation and/or other materials provided with the
20  *   distribution.
21  * * Neither the name of olsr.org, olsrd nor the names of its
22  *   contributors may be used to endorse or promote products derived
23  *   from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  *
38  * Visit http://www.olsr.org for more information.
39  *
40  * If you find this software useful feel free to make a donation
41  * to the project. For more information see the website or contact
42  * the copyright holders.
43  *
44  */
45 
46 #ifndef _OLSR_HOST_SWITCH
47 #define _OLSR_HOST_SWITCH
48 
49 #include "olsr_types.h"
50 
51 #define OHS_TCP_PORT 10150
52 
53 #define OHS_VERSION "0.1"
54 
55 #define OHS_DEFAULT_OLSRD_PATH "./olsrd"
56 
57 #define OHS_OUT_OF_MEMORY(s) do { printf("ohsd: out of memory \"%s\"!\n", s); ohs_close(0); } while (0)
58 
59 #ifdef _WIN32
60 int __stdcall ohs_close(unsigned long signal) __attribute__ ((noreturn));
61 #else /* _WIN32 */
62 void ohs_close(int) __attribute__ ((noreturn));
63 #endif /* _WIN32 */
64 
65 struct ohs_ip_link {
66   union olsr_ip_addr dst;
67   uint8_t quality;                     /* 0 - 100 */
68   struct ohs_ip_link *next;
69 };
70 
71 struct ohs_connection {
72   union olsr_ip_addr ip_addr;
73   int socket;
74   uint32_t rx;
75   uint32_t tx;
76   uint32_t linkcnt;
77   struct ohs_ip_link *links;
78   struct ohs_connection *next;
79 };
80 
81 extern uint32_t logbits;
82 
83 extern struct ohs_connection *ohs_conns;
84 
85 #define LOG_DEFAULT 0x0
86 #define LOG_FORWARD 0x1
87 #define LOG_CONNECT 0x2
88 #define LOG_LINK    0x4
89 
90 #ifdef _WIN32
91 int __stdcall SignalHandler(unsigned long);
92 #else /* _WIN32 */
93 void ohs_close(int);
94 #endif /* _WIN32 */
95 
96 struct ohs_connection *get_client_by_addr(const union olsr_ip_addr *);
97 
98 int ohs_delete_connection(struct ohs_connection *);
99 
100 #endif /* _OLSR_HOST_SWITCH */
101 
102 /*
103  * Local Variables:
104  * c-basic-offset: 2
105  * indent-tabs-mode: nil
106  * End:
107  */
108