1 | /* |
---|
2 | * linc-private.h: This file is part of the linc library. |
---|
3 | * |
---|
4 | * Authors: |
---|
5 | * Elliot Lee (sopwith@redhat.com) |
---|
6 | * Michael Meeks (michael@ximian.com) |
---|
7 | * Mark McLouglin (mark@skynet.ie) & others |
---|
8 | * |
---|
9 | * Copyright 2001, Red Hat, Inc., Ximian, Inc., |
---|
10 | * Sun Microsystems, Inc. |
---|
11 | */ |
---|
12 | #ifndef _LINC_PRIVATE_H_ |
---|
13 | #define _LINC_PRIVATE_H_ |
---|
14 | |
---|
15 | #include "config.h" |
---|
16 | #include <linc/linc.h> |
---|
17 | |
---|
18 | #ifdef LINC_SSL_SUPPORT |
---|
19 | |
---|
20 | #include <openssl/ssl.h> |
---|
21 | #include <openssl/bio.h> |
---|
22 | extern SSL_METHOD *linc_ssl_method; |
---|
23 | extern SSL_CTX *linc_ssl_ctx; |
---|
24 | |
---|
25 | #endif /* LINC_SSL_SUPPORT */ |
---|
26 | |
---|
27 | /* |
---|
28 | * Really raw internals, exported for the tests |
---|
29 | */ |
---|
30 | |
---|
31 | struct _LINCServerPrivate { |
---|
32 | int fd; |
---|
33 | GMutex *mutex; |
---|
34 | LincWatch *tag; |
---|
35 | GSList *connections; |
---|
36 | }; |
---|
37 | |
---|
38 | struct _LINCWriteOpts { |
---|
39 | gboolean block_on_write; |
---|
40 | }; |
---|
41 | |
---|
42 | struct _LINCConnectionPrivate { |
---|
43 | #ifdef LINC_SSL_SUPPORT |
---|
44 | SSL *ssl; |
---|
45 | #endif |
---|
46 | LincWatch *tag; |
---|
47 | int fd; |
---|
48 | |
---|
49 | gulong max_buffer_bytes; |
---|
50 | gulong write_queue_bytes; |
---|
51 | GList *write_queue; |
---|
52 | }; |
---|
53 | |
---|
54 | typedef struct { |
---|
55 | GSource source; |
---|
56 | |
---|
57 | GIOChannel *channel; |
---|
58 | GPollFD pollfd; |
---|
59 | GIOCondition condition; |
---|
60 | GIOFunc callback; |
---|
61 | } LincUnixWatch; |
---|
62 | |
---|
63 | struct _LincWatch { |
---|
64 | GSource *main_source; |
---|
65 | GSource *linc_source; |
---|
66 | }; |
---|
67 | |
---|
68 | #define LINC_ERR_CONDS (G_IO_ERR|G_IO_HUP|G_IO_NVAL) |
---|
69 | #define LINC_IN_CONDS (G_IO_PRI|G_IO_IN) |
---|
70 | |
---|
71 | #define LINC_CLOSE(fd) while (close (fd) < 0 && errno == EINTR) |
---|
72 | |
---|
73 | const char *linc_get_local_hostname (void); |
---|
74 | |
---|
75 | struct sockaddr *linc_protocol_get_sockaddr (const LINCProtocolInfo *proto, |
---|
76 | const char *hostname, |
---|
77 | const char *service, |
---|
78 | LincSockLen *saddr_len); |
---|
79 | |
---|
80 | gboolean linc_protocol_get_sockinfo (const LINCProtocolInfo *proto, |
---|
81 | const struct sockaddr *saddr, |
---|
82 | gchar **hostname, |
---|
83 | gchar **service); |
---|
84 | |
---|
85 | gboolean linc_protocol_is_local (const LINCProtocolInfo *proto, |
---|
86 | const struct sockaddr *saddr, |
---|
87 | LincSockLen saddr_len); |
---|
88 | |
---|
89 | void linc_protocol_destroy_cnx (const LINCProtocolInfo *proto, |
---|
90 | int fd, |
---|
91 | const char *host, |
---|
92 | const char *service); |
---|
93 | |
---|
94 | void linc_protocol_destroy_addr (const LINCProtocolInfo *proto, |
---|
95 | int fd, |
---|
96 | struct sockaddr *saddr); |
---|
97 | |
---|
98 | LincWatch *linc_io_add_watch_fd (int fd, |
---|
99 | GIOCondition condition, |
---|
100 | GIOFunc func, |
---|
101 | gpointer user_data); |
---|
102 | |
---|
103 | void linc_watch_set_condition (LincWatch *w, |
---|
104 | GIOCondition condition); |
---|
105 | |
---|
106 | GMainContext *linc_main_get_context (void); |
---|
107 | |
---|
108 | #endif /* _LINC_PRIVATE_H */ |
---|