2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation.
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
24 #include "sockaddr-util.h"
29 * This declaration is entirely private; nothing but xfer_dest_directtcp_connect() references
33 GType xfer_dest_directtcp_connect_get_type(void);
34 #define XFER_DEST_DIRECTTCP_CONNECT_TYPE (xfer_dest_directtcp_connect_get_type())
35 #define XFER_DEST_DIRECTTCP_CONNECT(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_directtcp_connect_get_type(), XferDestDirectTCPConnect)
36 #define XFER_DEST_DIRECTTCP_CONNECT_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_directtcp_connect_get_type(), XferDestDirectTCPConnect const)
37 #define XFER_DEST_DIRECTTCP_CONNECT_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_dest_directtcp_connect_get_type(), XferDestDirectTCPConnectClass)
38 #define IS_XFER_DEST_DIRECTTCP_CONNECT(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_dest_directtcp_connect_get_type ())
39 #define XFER_DEST_DIRECTTCP_CONNECT_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_dest_directtcp_connect_get_type(), XferDestDirectTCPConnectClass)
41 static GObjectClass *parent_class = NULL;
44 * Main object structure
47 typedef struct XferDestDirectTCPConnect {
48 XferElement __parent__;
50 /* addresses to connect to (copied locally) */
52 } XferDestDirectTCPConnect;
59 XferElementClass __parent__;
60 } XferDestDirectTCPConnectClass;
70 XferDestDirectTCPConnect *self = (XferDestDirectTCPConnect *)elt;
72 g_assert(self->addrs && SU_GET_FAMILY(self->addrs) != 0);
73 elt->input_listen_addrs = self->addrs;
82 XferDestDirectTCPConnect *self = XFER_DEST_DIRECTTCP_CONNECT(obj_self);
89 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
94 XferDestDirectTCPConnectClass * selfc)
96 XferElementClass *klass = XFER_ELEMENT_CLASS(selfc);
97 GObjectClass *goc = G_OBJECT_CLASS(selfc);
98 static xfer_element_mech_pair_t mech_pairs[] = {
99 { XFER_MECH_DIRECTTCP_LISTEN, XFER_MECH_NONE, XFER_NROPS(0), XFER_NTHREADS(0) },
100 { XFER_MECH_NONE, XFER_MECH_NONE, XFER_NROPS(0), XFER_NTHREADS(0) },
103 klass->setup = setup_impl;
104 goc->finalize = finalize_impl;
106 klass->perl_class = "Amanda::Xfer::Dest::DirectTCPConnect";
107 klass->mech_pairs = mech_pairs;
109 parent_class = g_type_class_peek_parent(selfc);
113 xfer_dest_directtcp_connect_get_type (void)
115 static GType type = 0;
117 if G_UNLIKELY(type == 0) {
118 static const GTypeInfo info = {
119 sizeof (XferDestDirectTCPConnectClass),
120 (GBaseInitFunc) NULL,
121 (GBaseFinalizeFunc) NULL,
122 (GClassInitFunc) class_init,
123 (GClassFinalizeFunc) NULL,
124 NULL /* class_data */,
125 sizeof (XferDestDirectTCPConnect),
127 (GInstanceInitFunc) NULL,
131 type = g_type_register_static (XFER_ELEMENT_TYPE, "XferDestDirectTCPConnect", &info, 0);
137 /* create an element of this class; prototype is in xfer-element.h */
139 xfer_dest_directtcp_connect(
140 DirectTCPAddr *addrs)
142 XferDestDirectTCPConnect *self = (XferDestDirectTCPConnect *)
143 g_object_new(XFER_DEST_DIRECTTCP_CONNECT_TYPE, NULL);
144 XferElement *elt = XFER_ELEMENT(self);
147 g_assert(addrs != NULL);
149 for (i = 0; SU_GET_FAMILY(&addrs[i]) != 0; i++);
150 self->addrs = g_memdup(addrs, (i+1) * sizeof(*addrs));