1 |
/* Copyright (C) 2003 Stephane Thiell |
2 |
* |
3 |
* This file is part of libopas (from pxys) |
4 |
* |
5 |
* This program is free software; you can redistribute it and/or |
6 |
* modify it under the terms of the GNU General Public License |
7 |
* as published by the Free Software Foundation; either version 2 |
8 |
* of the License, or (at your option) any later version. |
9 |
* |
10 |
* This program is distributed in the hope that it will be useful, |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
* GNU General Public License for more details. |
14 |
* |
15 |
* You should have received a copy of the GNU General Public License |
16 |
* along with this program; if not, write to the Free Software |
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
* |
19 |
* $Id: opas.h,v 1.1.1.1 2003/12/30 17:27:47 mbuna Exp $ |
20 |
*/ |
21 |
#ifndef INCLUDED_OPAS_OPAS_H |
22 |
#define INCLUDED_OPAS_OPAS_H |
23 |
|
24 |
#include <opas/opas_msg.h> |
25 |
#include <opas/opas_stdint.h> |
26 |
|
27 |
#include <sys/types.h> |
28 |
#include <sys/socket.h> |
29 |
#include <netinet/in.h> |
30 |
|
31 |
/* OPAS proxy types ... |
32 |
*/ |
33 |
enum opas_proxy_type_t |
34 |
{ |
35 |
OPAS_TYPE_UNKNOWN = 0, |
36 |
OPAS_PROXY_TYPE_WINGATE = 1, |
37 |
OPAS_PROXY_TYPE_SOCKS4 = 2, |
38 |
OPAS_PROXY_TYPE_SOCKS5 = 3, |
39 |
OPAS_PROXY_TYPE_HTTPPROXY = 4, |
40 |
OPAS_PROXY_TYPE_HTTPPOST = 5, |
41 |
OPAS_PROXY_TYPE_CISCOROUTER = 6, |
42 |
OPAS_PROXY_TYPE_IRCBOUNCER = 7 |
43 |
}; |
44 |
|
45 |
enum |
46 |
{ |
47 |
OPAS_FLAG_ERRO = 1 << 8, |
48 |
OPAS_FLAG_CACH = 1 << 9, |
49 |
OPAS_FLAG_PROX = 1 << 10, |
50 |
OPAS_FLAG_REPL = 1 << 11, |
51 |
OPAS_FLAG_UMSG = 1 << 12, |
52 |
OPAS_FLAG_IPV6 = 1 << 13, |
53 |
OPAS_FLAG_PING = 1 << 14, |
54 |
OPAS_FLAG_SERV = 1 << 15 |
55 |
}; |
56 |
|
57 |
enum |
58 |
{ |
59 |
OPAS_ERROR_UNKNOWN = 0, |
60 |
OPAS_ERROR_NETDOWN = 1, |
61 |
OPAS_ERROR_NETUNREACH = 2 |
62 |
}; |
63 |
|
64 |
typedef struct opas_session_s * opas_session_t; |
65 |
|
66 |
typedef void (*opas_send_func)(const void *data, uint32_t length, void *uptr); |
67 |
|
68 |
typedef void (*opas_query_callback)(struct opas_msg_query *queryp, |
69 |
void *context); |
70 |
typedef void (*opas_query6_callback)(struct opas_msg_query6 *queryp, |
71 |
void *context); |
72 |
typedef void (*opas_reply_noproxy_callback)(struct opas_msg_query *replyp, |
73 |
void *context); |
74 |
typedef void (*opas_reply6_noproxy_callback)(struct opas_msg_query6 *replyp, |
75 |
void *context); |
76 |
typedef void (*opas_reply_error_callback)(struct opas_msg_reply_error *replyp, |
77 |
void *context); |
78 |
typedef void (*opas_reply6_error_callback)(struct opas_msg_reply6_error *rp, |
79 |
void *context); |
80 |
typedef void (*opas_reply_proxy_callback)(struct opas_msg_reply_proxy *replyp, |
81 |
void *context); |
82 |
typedef void (*opas_reply6_proxy_callback)(struct opas_msg_reply6_proxy *rp, |
83 |
void *context); |
84 |
typedef void (*opas_msg_user_callback)(struct opas_msg_user_header *umsgp, |
85 |
void *data, |
86 |
void *context); |
87 |
|
88 |
struct opas_callbacks |
89 |
{ |
90 |
opas_send_func send_fun; |
91 |
opas_query_callback query_fun; |
92 |
opas_reply_noproxy_callback reply_noproxy_fun; |
93 |
opas_reply_proxy_callback reply_proxy_fun; |
94 |
opas_reply_error_callback reply_error_fun; |
95 |
opas_query6_callback query6_fun; |
96 |
opas_reply6_noproxy_callback reply6_noproxy_fun; |
97 |
opas_reply6_proxy_callback reply6_proxy_fun; |
98 |
opas_reply6_error_callback reply6_error_fun; |
99 |
opas_msg_user_callback msg_user_fun; |
100 |
}; |
101 |
|
102 |
#if defined(__cplusplus) |
103 |
extern "C" { |
104 |
#endif |
105 |
|
106 |
extern const char * opas_get_version(void); |
107 |
|
108 |
extern opas_session_t opas_open_session(const struct opas_callbacks *callbacks, |
109 |
void *context); |
110 |
|
111 |
extern void opas_close_session(opas_session_t session); |
112 |
|
113 |
extern void * opas_get_context(opas_session_t session); |
114 |
|
115 |
extern void opas_set_context(opas_session_t session, void *context); |
116 |
|
117 |
extern int opas_feed(opas_session_t session, void *data, uint32_t size); |
118 |
|
119 |
|
120 |
extern void opas_ping(opas_session_t session); |
121 |
|
122 |
extern void opas_query(opas_session_t session, const struct in_addr *addr, |
123 |
uint32_t user_data); |
124 |
|
125 |
extern void opas_query6(opas_session_t session, const struct in6_addr *addr, |
126 |
uint32_t user_data); |
127 |
|
128 |
extern void opas_reply_noproxy(opas_session_t session, |
129 |
struct opas_msg_query *queryp, int from_cache); |
130 |
|
131 |
extern void opas_reply6_noproxy(opas_session_t session, |
132 |
struct opas_msg_query6 *queryp, |
133 |
int from_cache); |
134 |
|
135 |
extern void opas_reply_proxy(opas_session_t session, |
136 |
struct opas_msg_query *queryp, int from_cache, |
137 |
time_t ts, uint16_t type, uint16_t port, |
138 |
const char *descr); |
139 |
|
140 |
extern void opas_reply6_proxy(opas_session_t session, |
141 |
struct opas_msg_query6 *queryp, int from_cache, |
142 |
time_t ts, uint16_t type, uint16_t port, |
143 |
const char *descr); |
144 |
|
145 |
extern void opas_reply_error(opas_session_t session, |
146 |
struct opas_msg_query *queryp, uint32_t error); |
147 |
|
148 |
extern void opas_reply6_error(opas_session_t session, |
149 |
struct opas_msg_query6 *queryp, uint32_t error); |
150 |
|
151 |
extern void opas_send_msg_user(opas_session_t session, const void *data, |
152 |
uint32_t data_length, int reply, |
153 |
uint32_t user_data); |
154 |
|
155 |
#if defined(__cplusplus) |
156 |
} |
157 |
#endif |
158 |
|
159 |
#endif /* INCLUDED_OPAS_OPAS_H */ |