~ubuntu-branches/ubuntu/trusty/dante/trusty-proposed

« back to all changes in this revision

Viewing changes to include/socks.h

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Bridgett
  • Date: 2002-04-07 12:45:55 UTC
  • Revision ID: james.westby@ubuntu.com-20020407124555-qke8rt2tdor0naz2
Tags: upstream-1.1.11.12p1
ImportĀ upstreamĀ versionĀ 1.1.11.12p1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1997, 1998, 1999, 2000, 2001
 
3
 *      Inferno Nettverk A/S, Norway.  All rights reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 * 1. The above copyright notice, this list of conditions and the following
 
9
 *    disclaimer must appear in all copies of the software, derivative works
 
10
 *    or modified versions, and any portions thereof, aswell as in all
 
11
 *    supporting documentation.
 
12
 * 2. All advertising materials mentioning features or use of this software
 
13
 *    must display the following acknowledgement:
 
14
 *      This product includes software developed by
 
15
 *      Inferno Nettverk A/S, Norway.
 
16
 * 3. The name of the author may not be used to endorse or promote products
 
17
 *    derived from this software without specific prior written permission.
 
18
 *
 
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 
20
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
21
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
22
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 
23
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
24
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 *
 
30
 * Inferno Nettverk A/S requests users of this software to return to
 
31
 *
 
32
 *  Software Distribution Coordinator  or  sdc@inet.no
 
33
 *  Inferno Nettverk A/S
 
34
 *  Oslo Research Park
 
35
 *  Gaustadallļæ½en 21
 
36
 *  NO-0349 Oslo
 
37
 *  Norway
 
38
 *
 
39
 * any improvements or extensions that they make and grant Inferno Nettverk A/S
 
40
 * the rights to redistribute these changes.
 
41
 *
 
42
 */
 
43
 
 
44
/* $Id: socks.h,v 1.164 2001/10/06 12:37:11 karls Exp $ */
 
45
 
 
46
#ifndef _SOCKS_H_
 
47
#define _SOCKS_H_
 
48
#endif  /* ! _SOCKS_H_ */
 
49
 
 
50
#ifdef lint
 
51
extern const int lintnoloop_socks_h;
 
52
#else
 
53
#define lintnoloop_socks_h 0
 
54
#endif
 
55
 
 
56
#ifndef HAVE_OSF_OLDSTYLE
 
57
#define HAVE_OSF_OLDSTYLE 0
 
58
#endif  /* !HAVE_OSF_OLDSTYLE */
 
59
 
 
60
#if SOCKSLIBRARY_DYNAMIC
 
61
 
 
62
#ifdef accept
 
63
#undef accept
 
64
#endif  /* accept */
 
65
#if HAVE_EXTRA_OSF_SYMBOLS
 
66
#define accept(s, addr, addrlen)                        sys_Eaccept(s, addr, addrlen)
 
67
#else
 
68
#define accept(s, addr, addrlen)                        sys_accept(s, addr, addrlen)
 
69
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
70
 
 
71
#ifdef bind
 
72
#undef bind
 
73
#endif  /* bind */
 
74
#define bind(s, name, namelen)                  sys_bind(s, name, namelen)
 
75
 
 
76
#ifdef bindresvport
 
77
#undef bindresvport
 
78
#endif  /* bindresvport */
 
79
#define bindresvport(sd, sin)                           sys_bindresvport(sd, sin)
 
80
 
 
81
#ifdef connect
 
82
#undef connect
 
83
#endif  /* connect */
 
84
#define connect(s, name, namelen)               sys_connect(s, name, namelen)
 
85
 
 
86
#ifdef gethostbyname
 
87
#undef gethostbyname
 
88
#endif  /* gethostbyname */
 
89
#if HAVE_GETHOSTBYNAME2
 
90
/*
 
91
 * a little tricky ... we need it to be at the bottom of the stack,
 
92
 * like a syscall.
 
93
*/
 
94
#define gethostbyname(name)                             sys_gethostbyname2(name, AF_INET)
 
95
#else
 
96
#define gethostbyname(name)                             sys_gethostbyname(name)
 
97
#endif
 
98
 
 
99
#ifdef gethostbyname2
 
100
#undef gethostbyname2
 
101
#endif  /* gethostbyname2 */
 
102
#define gethostbyname2(name, af)                        sys_gethostbyname2(name, af)
 
103
 
 
104
#ifdef getpeername
 
105
#undef getpeername
 
106
#endif  /* getpeername */
 
107
#if HAVE_EXTRA_OSF_SYMBOLS
 
108
#define getpeername(s, name, namelen)   sys_Egetpeername(s, name, namelen)
 
109
#else
 
110
#define getpeername(s, name, namelen)   sys_getpeername(s, name, namelen)
 
111
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
112
 
 
113
#ifdef getsockname
 
114
#undef getsockname
 
115
#endif  /* getsockname */
 
116
#if HAVE_EXTRA_OSF_SYMBOLS
 
117
#define getsockname(s, name, namelen)   sys_Egetsockname(s, name, namelen)
 
118
#else
 
119
#define getsockname(s, name, namelen)   sys_getsockname(s, name, namelen)
 
120
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
121
 
 
122
#ifdef read
 
123
#undef read
 
124
#endif  /* read */
 
125
#define read(d, buf, nbytes)                            sys_read(d, buf, nbytes)
 
126
 
 
127
#ifdef readv
 
128
#undef readv
 
129
#endif  /* readv */
 
130
#if HAVE_EXTRA_OSF_SYMBOLS
 
131
#define readv(d, iov, iovcnt)                           sys_Ereadv(d, iov, iovcnt)
 
132
#else
 
133
#define readv(d, iov, iovcnt)                           sys_readv(d, iov, iovcnt)
 
134
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
135
 
 
136
#ifdef recv
 
137
#undef recv
 
138
#endif  /* recv */
 
139
#define recv(s, msg, len, flags)                        sys_recv(s, msg, len, flags)
 
140
 
 
141
#ifdef recvfrom
 
142
#undef recvfrom
 
143
#endif  /* recvfrom */
 
144
#if HAVE_EXTRA_OSF_SYMBOLS
 
145
#define recvfrom(s, buf, len, flags, from, fromlen)     \
 
146
                  sys_Erecvfrom(s, buf, len, flags, from, fromlen)
 
147
#else
 
148
#define recvfrom(s, buf, len, flags, from, fromlen)     \
 
149
                  sys_recvfrom(s, buf, len, flags, from, fromlen)
 
150
 
 
151
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
152
 
 
153
#ifdef recvmsg
 
154
#undef recvmsg
 
155
#endif  /* recvmsg */
 
156
#if HAVE_EXTRA_OSF_SYMBOLS
 
157
#define recvmsg(s, msg, flags)                  sys_Erecvmsg(s, msg, flags)
 
158
#else
 
159
#define recvmsg(s, msg, flags)                  sys_recvmsg(s, msg, flags)
 
160
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
161
 
 
162
#ifdef rresvport
 
163
#undef rresvport
 
164
#endif  /* rresvport */
 
165
#define rresvport(port)                                         sys_rresvport(port)
 
166
 
 
167
#ifdef sendto
 
168
#undef sendto
 
169
#endif  /* sendto */
 
170
#define sendto(s, msg, len, flags, to, tolen)   \
 
171
                  sys_sendto(s, msg, len, flags, to, tolen)
 
172
 
 
173
#ifdef write
 
174
#undef write
 
175
#endif  /* write */
 
176
#define write(d, buf, nbytes)                           sys_write(d, buf, nbytes)
 
177
 
 
178
#ifdef writev
 
179
#undef writev
 
180
#endif  /* writev */
 
181
#if HAVE_EXTRA_OSF_SYMBOLS
 
182
#define writev(d, iov, iovcnt)                  sys_Ewritev(d, iov, iovcnt)
 
183
#else
 
184
#define writev(d, iov, iovcnt)                  sys_writev(d, iov, iovcnt)
 
185
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
186
 
 
187
#ifdef send
 
188
#undef send
 
189
#endif  /* send */
 
190
#define send(s, msg, len, flags)                        sys_send(s, msg, len, flags)
 
191
 
 
192
#ifdef sendmsg
 
193
#undef sendmsg
 
194
#endif  /* sendmsg */
 
195
#if HAVE_EXTRA_OSF_SYMBOLS
 
196
#define sendmsg(s, msg, flags)                  sys_Esendmsg(s, msg, flags)
 
197
#else
 
198
#define sendmsg(s, msg, flags)                  sys_sendmsg(s, msg, flags)
 
199
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
200
 
 
201
#endif /* SOCKSLIBRARY_DYNAMIC */
 
202
 
 
203
struct configstate_t {
 
204
        unsigned                                init:1;
 
205
        unsigned                                :0;
 
206
        struct sockaddr lastconnect;            /* address we last connected to.                */
 
207
        pid_t                                   pid;
 
208
        unsigned                                :0;
 
209
};
 
210
 
 
211
struct option_t {
 
212
        int                                     debug;
 
213
        char                                    *configfile;    /* name of current configfile.                          */
 
214
        unsigned                                lbuf:1;                 /* linebuffered output?                                                 */
 
215
        unsigned                                :0;
 
216
};
 
217
 
 
218
 
 
219
 
 
220
struct config_t {
 
221
        pid_t                                                           connectchild;                           /* connect process.             */
 
222
        int                                                             connect_s;                                      /* socket to child.             */
 
223
        char                                                            domain[MAXHOSTNAMELEN]; /* localdomain.                 */
 
224
        struct logtype_t                                log;                                                    /* where to log.                        */
 
225
        struct option_t                         option;                                         /* misc. options.                       */
 
226
        struct configstate_t                    state;
 
227
        int                                                             resolveprotocol;                        /* resolveprotocol.             */
 
228
        struct route_t                                  *route;                                         /* linked list of routes*/
 
229
};
 
230
 
 
231
struct childpacket_t {
 
232
   struct sockshost_t   src;
 
233
   struct sockshost_t   dst;
 
234
   struct socks_t       packet;
 
235
};
 
236
 
 
237
 
 
238
__BEGIN_DECLS
 
239
 
 
240
/*
 
241
 * libsocks function declarations
 
242
 */
 
243
 
 
244
void
 
245
clientinit __P((void));
 
246
/*
 
247
 * initialises clientstate, reads configfile, etc.
 
248
 */
 
249
 
 
250
 
 
251
#if !HAVE_OSF_OLDSTYLE
 
252
int Raccept __P((int, struct sockaddr *, socklen_t *));
 
253
int Rconnect __P((int, const struct sockaddr *, socklen_t));
 
254
int Rgetsockname __P((int, struct sockaddr *, socklen_t *));
 
255
int Rgetpeername __P((int, struct sockaddr *, socklen_t *));
 
256
ssize_t Rsendto __P((int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen));
 
257
ssize_t Rrecvfrom __P((int s, void *buf, size_t len, int flags, struct sockaddr * from, socklen_t *fromlen));
 
258
ssize_t Rsendmsg __P((int s, const struct msghdr *msg, int flags));
 
259
ssize_t Rrecvmsg __P((int s, struct msghdr *msg, int flags));
 
260
int Rbind __P((int, const struct sockaddr *, socklen_t));
 
261
#endif  /* !HAVE_OSF_OLDSTYLE */
 
262
 
 
263
int Rbindresvport __P((int, struct sockaddr_in *));
 
264
int Rrresvport __P((int *));
 
265
struct hostent *Rgethostbyname __P((const char *));
 
266
struct hostent *Rgethostbyname2 __P((const char *, int af));
 
267
ssize_t Rwrite __P((int d, const void *buf, size_t nbytes));
 
268
ssize_t Rwritev __P((int d, const struct iovec *iov, int iovcnt));
 
269
ssize_t Rsend __P((int s, const void *msg, size_t len, int flags));
 
270
ssize_t Rread __P((int d, void *buf, size_t nbytes));
 
271
ssize_t Rreadv __P((int d, const struct iovec *iov, int iovcnt));
 
272
ssize_t Rrecv __P((int s, void *msg, size_t len, int flags));
 
273
 
 
274
int SOCKSinit __P((char *));
 
275
int Rlisten __P((int, int));
 
276
int Rselect __P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
 
277
/*
 
278
 * unused functions needed to compile programs with support for other
 
279
 * socks implementations.
 
280
 */
 
281
 
 
282
 
 
283
int
 
284
udpsetup __P((int s, const struct sockaddr *to, int type));
 
285
/*
 
286
 * sets up udp relaying between address of "s" and "to" by connecting
 
287
 * to socksserver.
 
288
 * If relaying is already set up the function returns with success.
 
289
 * Type is the type of connection setup, SOCKS_SEND or SOCKS_RECV.
 
290
 * At the moment only SOCKS_SEND is supported.
 
291
 * Returns:
 
292
 *              On success: 0
 
293
 *              On failure: -1
 
294
 */
 
295
 
 
296
 
 
297
int
 
298
negotiate_method __P((int s, struct socks_t *packet));
 
299
/*
 
300
 * Negotiates a method to be used when talking with the server connected
 
301
 * to "s".  "packet" is the packet that will later be sent to server,
 
302
 * only the "auth" element in it will be set but other elements are needed
 
303
 * too.
 
304
 * Returns:
 
305
 *              On success: 0
 
306
 *              On failure: -1
 
307
 */
 
308
 
 
309
 
 
310
int
 
311
socks_sendrequest __P((int s, const struct request_t *request));
 
312
/*
 
313
 * Sends the request "request" to the socksserver connected to "s".
 
314
 * Returns:
 
315
 *              On success: 0
 
316
 *              On failure: -1
 
317
 */
 
318
 
 
319
int
 
320
socks_recvresponse __P((int s, struct response_t *response, int version));
 
321
/*
 
322
 * Receives a socks response from the "s".  "response" is filled in with
 
323
 * the data received.
 
324
 * "version" is the protocolversion negotiated.
 
325
 * Returns:
 
326
 *              On success: 0
 
327
 *              On failure: -1
 
328
 */
 
329
 
 
330
 
 
331
int
 
332
socks_negotiate __P((int s, int control, struct socks_t *packet,
 
333
                                                        struct route_t *route));
 
334
/*
 
335
 * "s" is the socket data will flow over.
 
336
 * "control" is the control connection to the socks server.
 
337
 * "packet" is a socks packet containing the request.
 
338
 *      "route" is the connected route.
 
339
 * Negotiates method and fills the response to the request into packet->res.
 
340
 * Returns:
 
341
 *              On success: 0 (server replied to our request).
 
342
 *              On failure: -1.
 
343
 */
 
344
 
 
345
 
 
346
 
 
347
struct route_t *
 
348
socks_nbconnectroute __P((int s, int control, struct socks_t *packet,
 
349
                                                                  const struct sockshost_t *src,
 
350
                                                                  const struct sockshost_t *dst));
 
351
/*
 
352
 * The non-blocking version of socks_connectroute(), only used by client.
 
353
 * Takes one additional argument, "s", which is the socket to connect
 
354
 * and not necessarily the same as "control" (msproxy case).
 
355
 */
 
356
 
 
357
void
 
358
socks_badroute __P((struct route_t *route));
 
359
/*
 
360
 * Marks route "route" as bad.
 
361
 */
 
362
 
 
363
int
 
364
recv_sockshost __P((int s, struct sockshost_t *host, int version,
 
365
                                                  struct authmethod_t *auth));
 
366
/*
 
367
 * Fills "host" based on data read from "s".  "version" is the version
 
368
 * the remote peer is expected to send data in.
 
369
 *
 
370
 * Returns:
 
371
 *              On success: 0
 
372
 *              On failure: -1
 
373
 */
 
374
 
 
375
 
 
376
        /*
 
377
         *  Misc. functions to help keep track of our connection(s) to the server.
 
378
         */
 
379
 
 
380
struct socksfd_t *
 
381
socks_addaddr __P((unsigned int clientfd, struct socksfd_t *socksaddress));
 
382
/*
 
383
 * "clientfd" is associated with the structure "socksfd".
 
384
 * The function duplicates all arguments in it's own form and does
 
385
 * not access the memory referenced by them afterwards.
 
386
 *
 
387
 * The function checks the state of all filedescriptors on each call and
 
388
 * removes those that are no longer open.
 
389
 *
 
390
 * Returns:
 
391
 *              On success: pointer to the added socksfd_t structure.
 
392
 *              On failure: exits.  (memory exhausted and process grew descriptor size.)
 
393
 *
 
394
 */
 
395
 
 
396
struct socksfd_t *
 
397
socks_getaddr __P((unsigned int fd));
 
398
/*
 
399
 * Returns:
 
400
 *              On success:  the socketaddress associated with filedescriptor "fd".
 
401
 *              On failure:      NULL.  (no socketaddress associated with "fd").
 
402
 */
 
403
 
 
404
 
 
405
void
 
406
socks_rmaddr __P((unsigned int s));
 
407
/*
 
408
 * removes the association for the socket "s", also closes the server
 
409
 * connection.  If "s" is not registered the request is ignored.
 
410
 */
 
411
 
 
412
struct socksfd_t *
 
413
socksfddup __P((const struct socksfd_t *old, struct socksfd_t *new));
 
414
/*
 
415
 * Duplicates "old", in "new".
 
416
 * Returns:
 
417
 *              On success: "new".
 
418
 *              On failure: NULL (resource shortage).
 
419
 */
 
420
 
 
421
 
 
422
int
 
423
socks_addrcontrol __P((const struct sockaddr *local,
 
424
                                                          const struct sockaddr *remote));
 
425
/*
 
426
 * Goes through all addresses registered and tries to find one where
 
427
 * the control socket has a local address of "local" and peer address
 
428
 * of "remote".  If either of "local" or "remote" is NULL, that
 
429
 * endpoint is not checked against.
 
430
 *      Returns:
 
431
 *              On success: the descriptor the socksfd struct was registered with.
 
432
 *              On failure: -1
 
433
 */
 
434
 
 
435
int
 
436
socks_addrmatch __P((const struct sockaddr *local,
 
437
                                                        const struct sockaddr *remote,
 
438
                                                        const struct socksstate_t *state));
 
439
/*
 
440
 * Goes through all addresses registered and tries to find one where
 
441
 * all arguments match.
 
442
 * Arguments that are NULL or have "illegal" values are ignored.
 
443
 * Returns:
 
444
 *              On success: the descriptor the socksfd with matching arguments was
 
445
 *                registered with (>= 0).
 
446
 *              On failure: -1.
 
447
 */
 
448
 
 
449
 
 
450
int
 
451
socks_isaddr __P((unsigned int fd));
 
452
/*
 
453
 * Returns true if there is a address registered for the socket "fd", false
 
454
 * otherwise.
 
455
 */
 
456
 
 
457
 
 
458
int
 
459
socks_addrisok __P((unsigned int s));
 
460
/*
 
461
 * Compares the current address of "s" to the registered address.
 
462
 * If there is a mismatch, the function will try to correct it if possible.
 
463
 * Returns:
 
464
 *              If current address found to match registered: true.
 
465
 *              Else: false.
 
466
 */
 
467
 
 
468
int
 
469
socks_addfd __P((unsigned int fd));
 
470
/*
 
471
 * adds the filedescriptor "fd" to an internal table.
 
472
 * If it is already in the table the  request is ignored.
 
473
 * Returns:
 
474
 *              On success: 0
 
475
 *              On failure: -1
 
476
 */
 
477
 
 
478
int
 
479
socks_isfd __P((unsigned int fd));
 
480
/*
 
481
 * returns 1 if "fd" is a filedescriptor in our internal table, 0 if not.
 
482
 */
 
483
 
 
484
void
 
485
socks_rmfd __P((unsigned int fd));
 
486
/*
 
487
 * removes the filedescriptor "fd" from our internal table.
 
488
 */
 
489
 
 
490
 
 
491
int
 
492
fdisopen __P((int fd));
 
493
/*
 
494
 * returns 1 if the filedescriptor "fd" currently references a open object.
 
495
 * returns 0 otherwise.
 
496
 */
 
497
 
 
498
 
 
499
int
 
500
clientmethod_uname __P((int s, const struct sockshost_t *host, int version));
 
501
/*
 
502
 * Enters username/password negotiation with the socksserver connected to
 
503
 * the socket "s".
 
504
 * "host" gives the name of the server.
 
505
 * "version" gives the socksversion established to use.
 
506
 * Returns:
 
507
 *              On success: 0
 
508
 *              On failure: whatever the remote socksserver returned as status.
 
509
 */
 
510
 
 
511
 
 
512
char *
 
513
socks_getusername __P((const struct sockshost_t *host, char *buf,
 
514
                                                          size_t buflen));
 
515
/*
 
516
 * Tries to determine the username of the current user, to be used
 
517
 * when negotiating with the server "host".
 
518
 * The NUL-terminated username is written to "buf", which is of size
 
519
 * "buflen".
 
520
 * Returns:
 
521
 *              On success: pointer to "buf" with the username.
 
522
 *              On failure: NULL.
 
523
 */
 
524
 
 
525
char *
 
526
socks_getpassword __P((const struct sockshost_t *host, const char *user,
 
527
                                                          char *buf, size_t buflen));
 
528
/*
 
529
 * Tries to determine the password of user "user", to be used
 
530
 * when negotiating with the server "host".
 
531
 * The NUL-terminated password is written to "buf", which is of length
 
532
 * "buflen"
 
533
 * Returns:
 
534
 *              On success: pointer to "buf" with the password.
 
535
 *              On failure: NULL.
 
536
 */
 
537
 
 
538
 
 
539
int
 
540
serverreplyisok __P((int version, int reply, struct route_t *route));
 
541
/*
 
542
 * "replycode" is the reply code returned by a socksserver of version
 
543
 * "version".
 
544
 * "route" is the route that was used for the socksserver.  If
 
545
 * the errorcode indicates a serverfailure, it might be "badrouted".
 
546
 * Returns true if the reply indicates request succeeded, false otherwise
 
547
 * and sets errno accordingly.
 
548
 */
 
549
 
 
550
int
 
551
msproxy_negotiate __P((int s, int control, struct socks_t *packet));
 
552
/*
 
553
 * Negotiates with the msproxy server connected to "control".
 
554
 * "s" gives the socket to be used for dataflow.
 
555
 * "packet" contains the request and on return from the function
 
556
 * contains the response.
 
557
 * Returns:
 
558
 *              On success: 0 (server replied to our request).
 
559
 *              On failure: -1
 
560
 */
 
561
 
 
562
 
 
563
int
 
564
send_msprequest __P((int s, struct msproxy_state_t *state,
 
565
                                                  struct msproxy_request_t *packet));
 
566
/*
 
567
 * Sends a msproxy request to "s".
 
568
 * "state" is the current state of the connection to "s",
 
569
 * "packet" is the request to send.
 
570
 */
 
571
 
 
572
int
 
573
recv_mspresponse __P((int s, struct msproxy_state_t *state,
 
574
                                                  struct msproxy_response_t *packet));
 
575
/*
 
576
 * Receives a msproxy response from "s".
 
577
 * "state" is the current state of the connection to "s",
 
578
 * "packet" is the memory the response is read into.
 
579
 */
 
580
 
 
581
int
 
582
msproxy_sigio __P((int s));
 
583
/*
 
584
 * Must be called on sockets where we expect the connection to be forwarded
 
585
 * by the msproxy server.
 
586
 * "s" is the socket and must have been added with socks_addaddr() beforehand.
 
587
 * Returns:
 
588
 *              On success: 0
 
589
 *              On failure: -1
 
590
 */
 
591
 
 
592
int
 
593
msproxy_init __P((void));
 
594
/*
 
595
 * inits things for using a msproxyserver.
 
596
 *              On success: 0
 
597
 *              On failure: -1
 
598
 */
 
599
 
 
600
int
 
601
httpproxy_negotiate __P((int control, struct socks_t *packet));
 
602
/*
 
603
 * Negotiates a method to be used when talking with the server connected
 
604
 * to "s".  "packet" is the packet that will later be sent to server.
 
605
 * packet->res.reply will be set depending on the result of negotiation.
 
606
 * Returns:
 
607
 *              On success: 0 (server replied to our request).
 
608
 *              On failure: -1.
 
609
 */
 
610
 
 
611
#if DIAGNOSTIC
 
612
void
 
613
cc_socksfdv(int sig);
 
614
/*
 
615
 * consistencycheck on socksfdv.
 
616
 */
 
617
#endif
 
618
 
 
619
 
 
620
#if SOCKSLIBRARY_DYNAMIC
 
621
 
 
622
int sys_rresvport __P((int *));
 
623
int sys_bindresvport __P((int, struct sockaddr_in *));
 
624
 
 
625
HAVE_PROT_READ_0 sys_read
 
626
__P((HAVE_PROT_READ_1, HAVE_PROT_READ_2, HAVE_PROT_READ_3));
 
627
HAVE_PROT_READV_0 sys_readv
 
628
__P((HAVE_PROT_READV_1, HAVE_PROT_READV_2, HAVE_PROT_READV_3));
 
629
HAVE_PROT_RECV_0 sys_recv
 
630
__P((HAVE_PROT_RECV_1, HAVE_PROT_RECV_2, HAVE_PROT_RECV_3, HAVE_PROT_RECV_4));
 
631
HAVE_PROT_RECVMSG_0 sys_recvmsg
 
632
__P((HAVE_PROT_RECVMSG_1, HAVE_PROT_RECVMSG_2, HAVE_PROT_RECVMSG_3));
 
633
HAVE_PROT_SEND_0 sys_send
 
634
__P((HAVE_PROT_SEND_1 , HAVE_PROT_SEND_2, HAVE_PROT_SEND_3, HAVE_PROT_SEND_4));
 
635
HAVE_PROT_WRITE_0 sys_write
 
636
__P((HAVE_PROT_WRITE_1, HAVE_PROT_WRITE_2, HAVE_PROT_WRITE_3));
 
637
 
 
638
#if HAVE_OSF_OLDSTYLE
 
639
int sys_accept __P((int, struct sockaddr *, int *));
 
640
#else
 
641
HAVE_PROT_ACCEPT_0 sys_accept
 
642
__P((HAVE_PROT_ACCEPT_1, HAVE_PROT_ACCEPT_2, HAVE_PROT_ACCEPT_3));
 
643
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
644
 
 
645
#if HAVE_OSF_OLDSTYLE
 
646
int sys_bind __P((int, const struct sockaddr *, int));
 
647
#else
 
648
HAVE_PROT_BIND_0 sys_bind
 
649
__P((HAVE_PROT_BIND_1, HAVE_PROT_BIND_2, HAVE_PROT_BIND_3));
 
650
#endif /* !HAVE_OSF_OLDSTYLE */
 
651
 
 
652
#if HAVE_OSF_OLDSTYLE
 
653
int sys_connect __P((int, const struct sockaddr *, int));
 
654
#else
 
655
HAVE_PROT_CONNECT_0 sys_connect
 
656
__P((HAVE_PROT_CONNECT_1, HAVE_PROT_CONNECT_2, HAVE_PROT_CONNECT_3));
 
657
#endif  /* HAVE_OSF_OLDSTYLE */
 
658
 
 
659
#if HAVE_OSF_OLDSTYLE
 
660
int sys_getpeername __P((int, struct sockaddr *, int *));
 
661
#else
 
662
HAVE_PROT_GETPEERNAME_0 sys_getpeername
 
663
__P((HAVE_PROT_GETPEERNAME_1, HAVE_PROT_GETPEERNAME_2, HAVE_PROT_GETPEERNAME_3));
 
664
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
665
 
 
666
#if HAVE_OSF_OLDSTYLE
 
667
int sys_getsockname __P((int, struct sockaddr *, int *));
 
668
#else
 
669
HAVE_PROT_GETSOCKNAME_0 sys_getsockname
 
670
__P((HAVE_PROT_GETSOCKNAME_1, HAVE_PROT_GETSOCKNAME_2, HAVE_PROT_GETSOCKNAME_3));
 
671
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
672
 
 
673
#if HAVE_OSF_OLDSTYLE
 
674
int sys_recvfrom __P((int, void*, int, int, struct sockaddr *, int *));
 
675
#else
 
676
HAVE_PROT_RECVFROM_0 sys_recvfrom
 
677
__P((HAVE_PROT_RECVFROM_1, HAVE_PROT_RECVFROM_2, HAVE_PROT_RECVFROM_3, HAVE_PROT_RECVFROM_4, HAVE_PROT_RECVFROM_5, HAVE_PROT_RECVFROM_6));
 
678
#endif
 
679
 
 
680
#if HAVE_OSF_OLDSTYLE
 
681
ssize_t sys_writev __P((int, const struct iovec *, int));
 
682
#else
 
683
HAVE_PROT_WRITEV_0 sys_writev
 
684
__P((HAVE_PROT_WRITEV_1, HAVE_PROT_WRITEV_2, HAVE_PROT_WRITEV_3));
 
685
#endif
 
686
 
 
687
#if HAVE_OSF_OLDSTYLE
 
688
ssize_t sys_sendmsg __P((int, struct msghdr *, int));
 
689
#else
 
690
HAVE_PROT_SENDMSG_0 sys_sendmsg
 
691
__P((HAVE_PROT_SENDMSG_1, HAVE_PROT_SENDMSG_2, HAVE_PROT_SENDMSG_3));
 
692
#endif
 
693
 
 
694
#if HAVE_OSF_OLDSTYLE
 
695
int sys_sendto __P((int, const void *, int, int, const struct sockaddr *, socklen_t));
 
696
#else
 
697
HAVE_PROT_SENDTO_0 sys_sendto
 
698
__P((HAVE_PROT_SENDTO_1, HAVE_PROT_SENDTO_2, HAVE_PROT_SENDTO_3, HAVE_PROT_SENDTO_4, HAVE_PROT_SENDTO_5, HAVE_PROT_SENDTO_6));
 
699
#endif /* !HAVE_OSF_OLDSTYLE */
 
700
 
 
701
#if HAVE_EXTRA_OSF_SYMBOLS
 
702
int sys_Eaccept __P((int, struct sockaddr *, socklen_t *));
 
703
int sys_Egetpeername __P((int, struct sockaddr *, socklen_t *));
 
704
int sys_Egetsockname __P((int, struct sockaddr *, socklen_t *));
 
705
ssize_t sys_Ereadv __P((int, const struct iovec *, int));
 
706
int sys_Erecvfrom __P((int, void *, size_t, int, struct sockaddr *, size_t *));
 
707
ssize_t sys_Erecvmsg __P((int, struct msghdr *, int));
 
708
ssize_t sys_Esendmsg __P((int, const struct msghdr *, int));
 
709
ssize_t sys_Ewritev __P((int, const struct iovec *, int));
 
710
 
 
711
int sys_naccept __P((int, struct sockaddr *, socklen_t *));
 
712
int sys_ngetpeername __P((int, struct sockaddr *, socklen_t *));
 
713
int sys_ngetsockname __P((int, struct sockaddr *, socklen_t *));
 
714
int sys_nrecvfrom __P((int, void *, size_t, int, struct sockaddr *, size_t *));
 
715
ssize_t sys_nrecvmsg __P((int, struct msghdr *, int));
 
716
ssize_t sys_nsendmsg __P((int, const struct msghdr *, int));
 
717
 
 
718
#endif  /* HAVE_EXTRA_OSF_SYMBOLS */
 
719
 
 
720
#endif /* SOCKSLIBRARY_DYNAMIC */
 
721
 
 
722
__END_DECLS