1
/* Generated by GOB (v2.0.15) (do not edit directly) */
3
/* End world hunger, donate to the World Food Programme, http://www.wfp.org */
5
#define GOB_VERSION_MAJOR 2
6
#define GOB_VERSION_MINOR 0
7
#define GOB_VERSION_PATCHLEVEL 15
9
#define selfp (self->_priv)
13
#include "lm-host-private.h"
16
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
17
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
18
#else /* ! G_LIKELY */
19
#define ___GOB_LIKELY(expr) (expr)
20
#define ___GOB_UNLIKELY(expr) (expr)
23
#line 51 "src/lm-host.gob"
27
#include <sys/types.h>
28
#include <sys/socket.h>
30
#include <glib/gi18n.h>
32
#include "lm-applet.h"
34
#ifndef HAVE_REENTRANT_RESOLVER
35
G_LOCK_DEFINE_STATIC(resolver);
39
#define MIN_TIMEOUT 100
40
#define DEFAULT_TIMEOUT 1000
43
/* self casting macros */
44
#define SELF(x) LM_HOST(x)
45
#define SELF_CONST(x) LM_HOST_CONST(x)
46
#define IS_SELF(x) LM_IS_HOST(x)
47
#define TYPE_SELF LM_TYPE_HOST
48
#define SELF_CLASS(x) LM_HOST_CLASS(x)
50
#define SELF_GET_CLASS(x) LM_HOST_GET_CLASS(x)
54
typedef LMHostClass SelfClass;
56
/* here are local prototypes */
57
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
58
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
59
#line 0 "src/lm-host.gob"
60
static void lm_host_init (LMHost * o);
62
#line 0 "src/lm-host.gob"
63
static void lm_host_class_init (LMHostClass * c);
65
#line 147 "src/lm-host.gob"
66
static void lm_host_set_error (LMHost * self, Error error, const char * format, ...) G_GNUC_PRINTF(3, 4);
68
#line 166 "src/lm-host.gob"
69
static void lm_host_clear_error (LMHost * self, Error error);
71
#line 180 "src/lm-host.gob"
72
static void lm_host_constructor (LMHost * self);
74
#line 191 "src/lm-host.gob"
75
static void lm_host_finalize (LMHost * self);
77
#line 203 "src/lm-host.gob"
78
static void lm_host_resolve (LMHost * self);
80
#line 214 "src/lm-host.gob"
81
static gpointer lm_host_resolve_thread_cb (gpointer data);
83
#line 327 "src/lm-host.gob"
84
static void lm_host_install_resolve_timeout (LMHost * self, int delay);
86
#line 334 "src/lm-host.gob"
87
static gboolean lm_host_resolve_timeout_cb (gpointer data);
89
#line 345 "src/lm-host.gob"
90
static void lm_host_send_echo_request (LMHost * self);
92
#line 388 "src/lm-host.gob"
93
static void lm_host_delay_changed_h (GObject * object, GParamSpec * pspec, gpointer user_data);
95
#line 401 "src/lm-host.gob"
96
static void lm_host_install_send_timeout (LMHost * self);
98
#line 412 "src/lm-host.gob"
99
static gboolean lm_host_send_timeout_cb (gpointer data);
100
#line 101 "lm-host.c"
101
#line 422 "src/lm-host.gob"
102
static gboolean lm_host_dead_timeout_cb (gpointer data);
103
#line 104 "lm-host.c"
116
/* pointer to the class of our parent */
117
static GObjectClass *parent_class = NULL;
119
/* Short form macros */
120
#define self_get_resolving lm_host_get_resolving
121
#define self_set_resolving lm_host_set_resolving
122
#define self_get_alive lm_host_get_alive
123
#define self_set_alive lm_host_set_alive
124
#define self_get_roundtrip_time lm_host_get_roundtrip_time
125
#define self_set_roundtrip_time lm_host_set_roundtrip_time
126
#define self_get_error lm_host_get_error
127
#define self_set_error lm_host_set_error
128
#define self_clear_error lm_host_clear_error
129
#define self_resolve lm_host_resolve
130
#define self_resolve_thread_cb lm_host_resolve_thread_cb
131
#define self_install_resolve_timeout lm_host_install_resolve_timeout
132
#define self_resolve_timeout_cb lm_host_resolve_timeout_cb
133
#define self_send_echo_request lm_host_send_echo_request
134
#define self_delay_changed_h lm_host_delay_changed_h
135
#define self_install_send_timeout lm_host_install_send_timeout
136
#define self_send_timeout_cb lm_host_send_timeout_cb
137
#define self_dead_timeout_cb lm_host_dead_timeout_cb
138
#define self_reply_received lm_host_reply_received
140
lm_host_get_type (void)
142
static GType type = 0;
144
if ___GOB_UNLIKELY(type == 0) {
145
static const GTypeInfo info = {
146
sizeof (LMHostClass),
147
(GBaseInitFunc) NULL,
148
(GBaseFinalizeFunc) NULL,
149
(GClassInitFunc) lm_host_class_init,
150
(GClassFinalizeFunc) NULL,
151
NULL /* class_data */,
154
(GInstanceInitFunc) lm_host_init,
158
type = g_type_register_static (G_TYPE_OBJECT, "LMHost", &info, (GTypeFlags)G_TYPE_FLAG_ABSTRACT);
164
/* a macro for creating a new object of our type */
165
#define GET_NEW ((LMHost *)g_object_new(lm_host_get_type(), NULL))
167
/* a function for creating a new object of our type */
169
static LMHost * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
171
GET_NEW_VARG (const char *first, ...)
175
va_start (ap, first);
176
ret = (LMHost *)g_object_new_valist (lm_host_get_type (), first, ap);
183
___constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
185
#define __GOB_FUNCTION__ "LM:Host::constructor"
188
obj_self = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_properties);
189
self = LM_HOST (obj_self);
190
#line 180 "src/lm-host.gob"
191
lm_host_constructor (self);
192
#line 193 "lm-host.c"
195
#undef __GOB_FUNCTION__
199
___finalize(GObject *obj_self)
201
#define __GOB_FUNCTION__ "LM:Host::finalize"
202
LMHost *self G_GNUC_UNUSED = LM_HOST (obj_self);
203
gpointer priv G_GNUC_UNUSED = self->_priv;
204
#line 191 "src/lm-host.gob"
205
lm_host_finalize (self);
206
#line 207 "lm-host.c"
207
if(G_OBJECT_CLASS(parent_class)->finalize) \
208
(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
209
#line 75 "src/lm-host.gob"
210
if(self->name) { g_free ((gpointer) self->name); self->name = NULL; }
211
#line 212 "lm-host.c"
212
#line 78 "src/lm-host.gob"
213
if(self->_priv->addrinfo) { freeaddrinfo ((gpointer) self->_priv->addrinfo); self->_priv->addrinfo = NULL; }
214
#line 215 "lm-host.c"
215
#line 84 "src/lm-host.gob"
216
if(self->ip) { g_free ((gpointer) self->ip); self->ip = NULL; }
217
#line 218 "lm-host.c"
218
#define errors (self->_priv->errors)
221
#line 127 "src/lm-host.gob"
225
for (i = 0; i < G_N_ELEMENTS(VAR); i++)
228
#line 229 "lm-host.c"
229
memset(&errors, 0, sizeof(errors));
233
#undef __GOB_FUNCTION__
236
lm_host_init (LMHost * o G_GNUC_UNUSED)
238
#define __GOB_FUNCTION__ "LM:Host::init"
239
o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,LM_TYPE_HOST,LMHostPrivate);
241
#undef __GOB_FUNCTION__
243
lm_host_class_init (LMHostClass * c G_GNUC_UNUSED)
245
#define __GOB_FUNCTION__ "LM:Host::class_init"
246
GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
248
g_type_class_add_private(c,sizeof(LMHostPrivate));
250
parent_class = g_type_class_ref (G_TYPE_OBJECT);
252
g_object_class->constructor = ___constructor;
253
g_object_class->finalize = ___finalize;
254
g_object_class->get_property = ___object_get_property;
255
g_object_class->set_property = ___object_set_property;
257
GParamSpec *param_spec;
259
param_spec = g_param_spec_pointer
260
("applet" /* name */,
263
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
264
g_object_class_install_property (g_object_class,
267
param_spec = g_param_spec_string
271
NULL /* default_value */,
272
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
273
g_object_class_install_property (g_object_class,
276
param_spec = g_param_spec_boolean
277
("resolving" /* name */,
280
FALSE /* default_value */,
281
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
282
g_object_class_install_property (g_object_class,
285
param_spec = g_param_spec_string
289
NULL /* default_value */,
290
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
291
g_object_class_install_property (g_object_class,
294
param_spec = g_param_spec_boolean
298
FALSE /* default_value */,
299
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
300
g_object_class_install_property (g_object_class,
303
param_spec = g_param_spec_int64
304
("roundtrip_time" /* name */,
307
G_MININT64 /* minimum */,
308
G_MAXINT64 /* maximum */,
309
0 /* default_value */,
310
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
311
g_object_class_install_property (g_object_class,
314
param_spec = g_param_spec_string
318
NULL /* default_value */,
319
(GParamFlags)(G_PARAM_READABLE));
320
g_object_class_install_property (g_object_class,
325
#undef __GOB_FUNCTION__
328
___object_set_property (GObject *object,
330
const GValue *VAL G_GNUC_UNUSED,
331
GParamSpec *pspec G_GNUC_UNUSED)
332
#define __GOB_FUNCTION__ "LM:Host::set_property"
334
LMHost *self G_GNUC_UNUSED;
336
self = LM_HOST (object);
338
switch (property_id) {
341
#line 73 "src/lm-host.gob"
342
self->applet = g_value_get_pointer (VAL);
343
#line 344 "lm-host.c"
348
#line 76 "src/lm-host.gob"
349
{ char *old = self->name; self->name = g_value_dup_string (VAL); g_free (old); }
350
#line 351 "lm-host.c"
355
#line 82 "src/lm-host.gob"
356
self->resolving = g_value_get_boolean (VAL);
357
#line 358 "lm-host.c"
362
#line 85 "src/lm-host.gob"
363
{ char *old = self->ip; self->ip = g_value_dup_string (VAL); g_free (old); }
364
#line 365 "lm-host.c"
369
#line 93 "src/lm-host.gob"
370
self->alive = g_value_get_boolean (VAL);
371
#line 372 "lm-host.c"
374
case PROP_ROUNDTRIP_TIME:
376
#line 104 "src/lm-host.gob"
378
self->last_received_ticks = lm_get_ticks();
379
lm_source_clear(&selfp->dead_timeout_id);
381
self->roundtrip_time = g_value_get_int64(VAL);
382
if (self->roundtrip_time > selfp->max_roundtrip_time)
383
selfp->max_roundtrip_time = self->roundtrip_time;
385
self_set_alive(self, TRUE);
387
#line 388 "lm-host.c"
391
/* Apparently in g++ this is needed, glib is b0rk */
392
#ifndef __PRETTY_FUNCTION__
394
# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
396
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
400
#undef __GOB_FUNCTION__
403
___object_get_property (GObject *object,
405
GValue *VAL G_GNUC_UNUSED,
406
GParamSpec *pspec G_GNUC_UNUSED)
407
#define __GOB_FUNCTION__ "LM:Host::get_property"
409
LMHost *self G_GNUC_UNUSED;
411
self = LM_HOST (object);
413
switch (property_id) {
416
#line 73 "src/lm-host.gob"
417
g_value_set_pointer (VAL, self->applet);
418
#line 419 "lm-host.c"
423
#line 76 "src/lm-host.gob"
424
g_value_set_string (VAL, self->name);
425
#line 426 "lm-host.c"
430
#line 82 "src/lm-host.gob"
431
g_value_set_boolean (VAL, self->resolving);
432
#line 433 "lm-host.c"
437
#line 85 "src/lm-host.gob"
438
g_value_set_string (VAL, self->ip);
439
#line 440 "lm-host.c"
444
#line 93 "src/lm-host.gob"
445
g_value_set_boolean (VAL, self->alive);
446
#line 447 "lm-host.c"
449
case PROP_ROUNDTRIP_TIME:
451
#line 115 "src/lm-host.gob"
453
g_value_set_int64(VAL, self->roundtrip_time);
455
#line 456 "lm-host.c"
460
#line 121 "src/lm-host.gob"
462
g_value_set_string(VAL, self_get_error(self));
464
#line 465 "lm-host.c"
468
/* Apparently in g++ this is needed, glib is b0rk */
469
#ifndef __PRETTY_FUNCTION__
471
# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
473
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
477
#undef __GOB_FUNCTION__
481
#line 82 "src/lm-host.gob"
483
lm_host_get_resolving (LMHost * self)
485
#line 486 "lm-host.c"
486
#define __GOB_FUNCTION__ "LM:Host::get_resolving"
488
#line 82 "src/lm-host.gob"
489
gboolean val; g_object_get (G_OBJECT (self), "resolving", &val, NULL); return val;
491
#line 492 "lm-host.c"
492
#undef __GOB_FUNCTION__
494
#line 82 "src/lm-host.gob"
496
lm_host_set_resolving (LMHost * self, gboolean val)
498
#line 499 "lm-host.c"
499
#define __GOB_FUNCTION__ "LM:Host::set_resolving"
501
#line 82 "src/lm-host.gob"
502
g_object_set (G_OBJECT (self), "resolving", val, NULL);
504
#line 505 "lm-host.c"
505
#undef __GOB_FUNCTION__
507
#line 93 "src/lm-host.gob"
509
lm_host_get_alive (LMHost * self)
511
#line 512 "lm-host.c"
512
#define __GOB_FUNCTION__ "LM:Host::get_alive"
514
#line 93 "src/lm-host.gob"
515
gboolean val; g_object_get (G_OBJECT (self), "alive", &val, NULL); return val;
517
#line 518 "lm-host.c"
518
#undef __GOB_FUNCTION__
520
#line 93 "src/lm-host.gob"
522
lm_host_set_alive (LMHost * self, gboolean val)
524
#line 525 "lm-host.c"
525
#define __GOB_FUNCTION__ "LM:Host::set_alive"
527
#line 93 "src/lm-host.gob"
528
g_object_set (G_OBJECT (self), "alive", val, NULL);
530
#line 531 "lm-host.c"
531
#undef __GOB_FUNCTION__
533
#line 115 "src/lm-host.gob"
535
lm_host_get_roundtrip_time (LMHost * self)
537
#line 538 "lm-host.c"
538
#define __GOB_FUNCTION__ "LM:Host::get_roundtrip_time"
540
#line 102 "src/lm-host.gob"
541
LMTimeSpan val; g_object_get (G_OBJECT (self), "roundtrip_time", &val, NULL); return val;
543
#line 544 "lm-host.c"
544
#undef __GOB_FUNCTION__
546
#line 104 "src/lm-host.gob"
548
lm_host_set_roundtrip_time (LMHost * self, LMTimeSpan val)
550
#line 551 "lm-host.c"
551
#define __GOB_FUNCTION__ "LM:Host::set_roundtrip_time"
553
#line 102 "src/lm-host.gob"
554
g_object_set (G_OBJECT (self), "roundtrip_time", val, NULL);
556
#line 557 "lm-host.c"
557
#undef __GOB_FUNCTION__
559
#line 134 "src/lm-host.gob"
561
lm_host_get_error (LMHost * self)
563
#line 564 "lm-host.c"
564
#define __GOB_FUNCTION__ "LM:Host::get_error"
565
#line 134 "src/lm-host.gob"
566
g_return_val_if_fail (self != NULL, (const char * )0);
567
#line 134 "src/lm-host.gob"
568
g_return_val_if_fail (LM_IS_HOST (self), (const char * )0);
569
#line 570 "lm-host.c"
571
#line 136 "src/lm-host.gob"
575
for (i = 0; i < G_N_ELEMENTS(selfp->errors); i++)
576
if (selfp->errors[i])
577
return selfp->errors[i];
581
#line 582 "lm-host.c"
582
#undef __GOB_FUNCTION__
584
#line 147 "src/lm-host.gob"
586
lm_host_set_error (LMHost * self, Error error, const char * format, ...)
588
#line 589 "lm-host.c"
589
#define __GOB_FUNCTION__ "LM:Host::set_error"
590
#line 147 "src/lm-host.gob"
591
g_return_if_fail (self != NULL);
592
#line 147 "src/lm-host.gob"
593
g_return_if_fail (LM_IS_HOST (self));
594
#line 147 "src/lm-host.gob"
595
g_return_if_fail (format != NULL);
596
#line 597 "lm-host.c"
598
#line 149 "src/lm-host.gob"
603
va_start(args, format);
604
msg = g_strdup_vprintf(format, args);
607
g_free(selfp->errors[error]);
608
selfp->errors[error] = msg;
610
lm_source_clear(&selfp->dead_timeout_id);
611
self_set_alive(self, FALSE);
613
g_object_notify(G_OBJECT(self), "error");
615
#line 616 "lm-host.c"
616
#undef __GOB_FUNCTION__
618
#line 166 "src/lm-host.gob"
620
lm_host_clear_error (LMHost * self, Error error)
622
#line 623 "lm-host.c"
623
#define __GOB_FUNCTION__ "LM:Host::clear_error"
624
#line 166 "src/lm-host.gob"
625
g_return_if_fail (self != NULL);
626
#line 166 "src/lm-host.gob"
627
g_return_if_fail (LM_IS_HOST (self));
628
#line 629 "lm-host.c"
630
#line 168 "src/lm-host.gob"
632
if (! selfp->errors[error])
635
g_free(selfp->errors[error]);
636
selfp->errors[error] = NULL;
638
g_object_notify(G_OBJECT(self), "error");
640
#line 641 "lm-host.c"
641
#undef __GOB_FUNCTION__
643
#line 180 "src/lm-host.gob"
645
lm_host_constructor (LMHost * self)
647
#line 648 "lm-host.c"
648
#define __GOB_FUNCTION__ "LM:Host::constructor"
650
#line 181 "src/lm-host.gob"
652
selfp->host_id = lm_shell_allocate_host_id(lm_shell, self);
654
lm_g_object_connect(self, self->applet,
655
"signal::notify::delay", self_delay_changed_h, self,
660
#line 661 "lm-host.c"
661
#undef __GOB_FUNCTION__
663
#line 191 "src/lm-host.gob"
665
lm_host_finalize (LMHost * self)
667
#line 668 "lm-host.c"
668
#define __GOB_FUNCTION__ "LM:Host::finalize"
670
#line 192 "src/lm-host.gob"
672
if (selfp->resolve_timeout_id)
673
g_source_remove(selfp->resolve_timeout_id);
674
if (selfp->send_timeout_id)
675
g_source_remove(selfp->send_timeout_id);
676
if (selfp->dead_timeout_id)
677
g_source_remove(selfp->dead_timeout_id);
679
lm_shell_deallocate_host_id(lm_shell, selfp->host_id);
681
#line 682 "lm-host.c"
682
#undef __GOB_FUNCTION__
684
#line 203 "src/lm-host.gob"
686
lm_host_resolve (LMHost * self)
688
#line 689 "lm-host.c"
689
#define __GOB_FUNCTION__ "LM:Host::resolve"
690
#line 203 "src/lm-host.gob"
691
g_return_if_fail (self != NULL);
692
#line 203 "src/lm-host.gob"
693
g_return_if_fail (LM_IS_HOST (self));
694
#line 695 "lm-host.c"
696
#line 205 "src/lm-host.gob"
698
g_return_if_fail(self->resolving == FALSE);
700
self_set_resolving(self, TRUE);
703
lm_thread_create(self_resolve_thread_cb, self);
705
#line 706 "lm-host.c"
706
#undef __GOB_FUNCTION__
708
#line 214 "src/lm-host.gob"
710
lm_host_resolve_thread_cb (gpointer data)
712
#line 713 "lm-host.c"
713
#define __GOB_FUNCTION__ "LM:Host::resolve_thread_cb"
715
#line 216 "src/lm-host.gob"
718
struct addrinfo hints;
719
struct addrinfo *addrinfo;
723
memset(&hints, 0, sizeof(hints));
725
hints.ai_family = PF_UNSPEC;
727
hints.ai_family = PF_INET;
728
#endif /* WITH_IPV6 */
729
hints.ai_socktype = SOCK_RAW;
731
#ifndef HAVE_REENTRANT_RESOLVER
734
status = getaddrinfo(self->name, NULL, &hints, &addrinfo);
735
#ifndef HAVE_REENTRANT_RESOLVER
741
char buf[NI_MAXHOST];
744
#ifndef HAVE_REENTRANT_RESOLVER
747
name_status = getnameinfo(addrinfo->ai_addr,
748
addrinfo->ai_addrlen,
754
#ifndef HAVE_REENTRANT_RESOLVER
758
if (name_status == 0)
766
self_set_resolving(self, FALSE);
769
freeaddrinfo(selfp->addrinfo);
770
selfp->addrinfo = addrinfo;
773
self->ip = g_strdup(ip);
774
g_object_notify(G_OBJECT(self), "ip");
778
selfp->sock = lm_shell_get_socket(lm_shell, selfp->addrinfo->ai_family);
781
if (! selfp->sock->init_error)
783
/* complete success */
784
self_clear_error(self, ERROR_RESOLVE);
786
if (! selfp->send_timeout_id)
788
self_send_echo_request(self); /* send first packet */
789
self_install_send_timeout(self); /* install send loop */
793
self_set_error(self, ERROR_RESOLVE, _("socket could not be initialized: %s"), selfp->sock->init_error);
796
self_set_error(self, ERROR_RESOLVE, _("unsupported address family"));
798
/* DNS success (even if no socket), refresh in one hour */
799
self_install_resolve_timeout(self, 3600 * 1000);
804
self_set_error(self, ERROR_RESOLVE, _("unable to resolve hostname: %s"), gai_strerror(status));
806
/* DNS failure, retry in 10 seconds */
807
self_install_resolve_timeout(self, 10 * 1000);
810
/* if an error was installed above, remove the send timeout */
811
if (selfp->errors[ERROR_RESOLVE])
812
lm_source_clear(&selfp->send_timeout_id);
814
g_object_unref(self);
817
* A note on gdk_flush(): as advised in the GDK threads
818
* documentation, we only call gdk_flush() from a thread other
819
* than our main thread.
826
#line 827 "lm-host.c"
827
#undef __GOB_FUNCTION__
829
#line 327 "src/lm-host.gob"
831
lm_host_install_resolve_timeout (LMHost * self, int delay)
833
#line 834 "lm-host.c"
834
#define __GOB_FUNCTION__ "LM:Host::install_resolve_timeout"
835
#line 327 "src/lm-host.gob"
836
g_return_if_fail (self != NULL);
837
#line 327 "src/lm-host.gob"
838
g_return_if_fail (LM_IS_HOST (self));
839
#line 840 "lm-host.c"
841
#line 329 "src/lm-host.gob"
843
g_return_if_fail(selfp->resolve_timeout_id == 0);
844
selfp->resolve_timeout_id = gdk_threads_add_timeout(delay, self_resolve_timeout_cb, self);
846
#line 847 "lm-host.c"
847
#undef __GOB_FUNCTION__
849
#line 334 "src/lm-host.gob"
851
lm_host_resolve_timeout_cb (gpointer data)
853
#line 854 "lm-host.c"
854
#define __GOB_FUNCTION__ "LM:Host::resolve_timeout_cb"
856
#line 336 "src/lm-host.gob"
862
selfp->resolve_timeout_id = 0;
863
return FALSE; /* remove source */
865
#line 866 "lm-host.c"
866
#undef __GOB_FUNCTION__
868
#line 345 "src/lm-host.gob"
870
lm_host_send_echo_request (LMHost * self)
872
#line 873 "lm-host.c"
873
#define __GOB_FUNCTION__ "LM:Host::send_echo_request"
874
#line 345 "src/lm-host.gob"
875
g_return_if_fail (self != NULL);
876
#line 345 "src/lm-host.gob"
877
g_return_if_fail (LM_IS_HOST (self));
878
#line 879 "lm-host.c"
880
#line 347 "src/lm-host.gob"
884
g_return_if_fail(selfp->sock != NULL);
885
g_return_if_fail(selfp->sock->init_error == NULL);
886
g_return_if_fail(selfp->addrinfo != NULL);
888
if (lm_icmp_send_echo_request(selfp->sock, selfp->addrinfo, selfp->host_id, selfp->sent_seq, &err))
892
req = &selfp->requests[selfp->sent_seq];
893
req->sent_time = lm_get_ticks();
897
self_clear_error(self, ERROR_SEND);
899
if (! selfp->dead_timeout_id)
903
if (selfp->max_roundtrip_time > 0)
905
timeout = (selfp->max_roundtrip_time / 1000) * 2;
906
if (timeout < MIN_TIMEOUT)
907
timeout = MIN_TIMEOUT;
910
timeout = DEFAULT_TIMEOUT;
912
selfp->dead_timeout_id = gdk_threads_add_timeout(timeout, self_dead_timeout_cb, self);
917
self_set_error(self, ERROR_SEND, _("unable to send echo request: %s"), err->message);
921
#line 922 "lm-host.c"
922
#undef __GOB_FUNCTION__
924
#line 388 "src/lm-host.gob"
926
lm_host_delay_changed_h (GObject * object, GParamSpec * pspec, gpointer user_data)
928
#line 929 "lm-host.c"
929
#define __GOB_FUNCTION__ "LM:Host::delay_changed_h"
931
#line 390 "src/lm-host.gob"
933
Self *self = user_data;
935
if (selfp->send_timeout_id)
937
lm_source_clear(&selfp->send_timeout_id);
938
self_install_send_timeout(self);
940
/* else we cannot send packets: do not install the send timeout */
942
#line 943 "lm-host.c"
943
#undef __GOB_FUNCTION__
945
#line 401 "src/lm-host.gob"
947
lm_host_install_send_timeout (LMHost * self)
949
#line 950 "lm-host.c"
950
#define __GOB_FUNCTION__ "LM:Host::install_send_timeout"
951
#line 401 "src/lm-host.gob"
952
g_return_if_fail (self != NULL);
953
#line 401 "src/lm-host.gob"
954
g_return_if_fail (LM_IS_HOST (self));
955
#line 956 "lm-host.c"
957
#line 403 "src/lm-host.gob"
959
g_return_if_fail(selfp->send_timeout_id == 0);
960
g_return_if_fail(selfp->sock != NULL);
961
g_return_if_fail(selfp->sock->init_error == NULL);
962
g_return_if_fail(selfp->addrinfo != NULL);
964
selfp->send_timeout_id = gdk_threads_add_timeout(self->applet->delay, self_send_timeout_cb, self);
966
#line 967 "lm-host.c"
967
#undef __GOB_FUNCTION__
969
#line 412 "src/lm-host.gob"
971
lm_host_send_timeout_cb (gpointer data)
973
#line 974 "lm-host.c"
974
#define __GOB_FUNCTION__ "LM:Host::send_timeout_cb"
976
#line 414 "src/lm-host.gob"
980
self_send_echo_request(self);
982
return TRUE; /* keep source */
984
#line 985 "lm-host.c"
985
#undef __GOB_FUNCTION__
987
#line 422 "src/lm-host.gob"
989
lm_host_dead_timeout_cb (gpointer data)
991
#line 992 "lm-host.c"
992
#define __GOB_FUNCTION__ "LM:Host::dead_timeout_cb"
994
#line 424 "src/lm-host.gob"
998
self_set_alive(self, FALSE);
1000
selfp->dead_timeout_id = 0;
1001
return FALSE; /* remove source */
1003
#line 1004 "lm-host.c"
1004
#undef __GOB_FUNCTION__
1006
#line 433 "src/lm-host.gob"
1008
lm_host_reply_received (LMHost * self, const LMICMPReply * reply)
1010
#line 1011 "lm-host.c"
1011
#define __GOB_FUNCTION__ "LM:Host::reply_received"
1012
#line 433 "src/lm-host.gob"
1013
g_return_if_fail (self != NULL);
1014
#line 433 "src/lm-host.gob"
1015
g_return_if_fail (LM_IS_HOST (self));
1016
#line 433 "src/lm-host.gob"
1017
g_return_if_fail (reply != NULL);
1018
#line 1019 "lm-host.c"
1020
#line 435 "src/lm-host.gob"
1025
* If there is no send timeout, an error (DNS or socket) has
1026
* occurred and we are unable to send packets: ignore this reply,
1027
* otherwise we would set alive back to TRUE.
1029
if (! selfp->send_timeout_id)
1032
req = &selfp->requests[reply->seq];
1033
if (! req->sent_time)
1034
return; /* no matching request, ignore */
1036
if (reply->received_time < req->sent_time)
1038
* Negative roundtrip-time: this should not normally happen
1039
* since we use a monotonic clock source, but it is possible
1040
* that the OS improperly implements it, or that the monitored
1041
* host returns garbage, etc. Acknowledge the reply but
1042
* otherwise ignore it.
1047
self_set_error(self, ERROR_RECEIVE, "%s", reply->error);
1050
self_clear_error(self, ERROR_RECEIVE);
1051
self_set_roundtrip_time(self, reply->received_time - req->sent_time);
1055
/* we have matched the request, clear it */
1058
#line 1059 "lm-host.c"
1059
#undef __GOB_FUNCTION__