2 * Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 N Mathlida Ave, Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
22 #ifndef DIRECTTCP_CONNECTION_H
23 #define DIRECTTCP_CONNECTION_H
26 #include <glib-object.h>
28 GType directtcp_connection_get_type (void);
29 #define TYPE_DIRECTTCP_CONNECTION (directtcp_connection_get_type())
30 #define DIRECTTCP_CONNECTION(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_get_type(), DirectTCPConnection)
31 #define IS_DIRECTTCP_CONNECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), directtcp_connection_get_type ())
32 #define DIRECTTCP_CONNECTION_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), directtcp_connection_get_type(), DirectTCPConnectionClass)
35 * Parent class for connections
38 typedef struct DirectTCPConnection {
42 } DirectTCPConnection;
44 typedef struct DirectTCPConnectionClass_ {
45 GObjectClass __parent__;
47 /* The DirectTCPConnection object allows a particular connection to "span"
48 * multiple devices -- the caller gets the connection from one device,
49 * reads or writes as desired, then creates a new device and passes the
50 * connection to that device. If the new device cannot use the old
51 * connection, then it generates a suitable error message.
54 /* call this to close the connection (even if the Device that created
55 * it is long gone). Note that this will be called automatically by
56 * finalize, but it is a programming error to allow this to happen as
57 * any error will be fatal.
60 * @returns: error message on error, NULL for no error (caller should
61 * free the error message)
63 char *(* close)(struct DirectTCPConnection *self);
64 } DirectTCPConnectionClass;
68 char *directtcp_connection_close(
69 DirectTCPConnection *self);
72 * A simple connection subclass containing a local TCP socket, useful for testing
75 #define TYPE_DIRECTTCP_CONNECTION_SOCKET (directtcp_connection_socket_get_type())
76 #define DIRECTTCP_CONNECTION_SOCKET(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocket)
77 #define DIRECTTCP_CONNECTION_SOCKET_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocket const)
78 #define DIRECTTCP_CONNECTION_SOCKET_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), directtcp_connection_socket_get_type(), DirectTCPConnectionSocketClass)
79 #define IS_DIRECTTCP_CONNECTION_SOCKET(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), directtcp_connection_socket_get_type ())
80 #define DIRECTTCP_CONNECTION_SOCKET_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocketClass)
81 GType directtcp_connection_socket_get_type(void);
83 typedef struct DirectTCPConnectionSocket_ {
84 DirectTCPConnection __parent__;
86 } DirectTCPConnectionSocket;
88 typedef struct DirectTCPConnectionSocketClass_ {
89 DirectTCPConnectionClass __parent__;
90 } DirectTCPConnectionSocketClass;
94 DirectTCPConnectionSocket *directtcp_connection_socket_new(int socket);
96 #endif /* DIRECTTCP_CONNECTION_H */