31 #include <netdb.h>
32 #include <errno.h>
33 #include <libidspace.h>
34
35 #include <libvarpd_provider.h>
36 #include <libvarpd_svp.h>
37
38 typedef struct svp_shoot_vl3 {
39 svp_query_t ssv_query;
40 struct sockaddr_in6 ssv_sock;
41 svp_log_vl3_t *ssv_vl3;
42 svp_sdlog_t *ssv_log;
43 } svp_shoot_vl3_t;
44
45 static mutex_t svp_remote_lock = ERRORCHECKMUTEX;
46 static avl_tree_t svp_remote_tree;
47 static svp_timer_t svp_dns_timer;
48 static id_space_t *svp_idspace;
49 static int svp_dns_timer_rate = 30; /* seconds */
50
51 static void
52 svp_remote_mkfmamsg(svp_remote_t *srp, svp_degrade_state_t state, char *buf,
53 size_t buflen)
54 {
55 switch (state) {
56 case SVP_RD_DNS_FAIL:
57 (void) snprintf(buf, buflen, "failed to resolve or find "
58 "entries for hostname %s", srp->sr_hostname);
59 break;
60 case SVP_RD_REMOTE_FAIL:
61 (void) snprintf(buf, buflen, "cannot reach any remote peers");
62 break;
63 default:
64 (void) snprintf(buf, buflen, "unkonwn error state: %d", state);
65 }
66 }
67
68 static int
69 svp_remote_comparator(const void *l, const void *r)
70 {
|
31 #include <netdb.h>
32 #include <errno.h>
33 #include <libidspace.h>
34
35 #include <libvarpd_provider.h>
36 #include <libvarpd_svp.h>
37
38 typedef struct svp_shoot_vl3 {
39 svp_query_t ssv_query;
40 struct sockaddr_in6 ssv_sock;
41 svp_log_vl3_t *ssv_vl3;
42 svp_sdlog_t *ssv_log;
43 } svp_shoot_vl3_t;
44
45 static mutex_t svp_remote_lock = ERRORCHECKMUTEX;
46 static avl_tree_t svp_remote_tree;
47 static svp_timer_t svp_dns_timer;
48 static id_space_t *svp_idspace;
49 static int svp_dns_timer_rate = 30; /* seconds */
50
51 id_t
52 svp_id_alloc(void)
53 {
54 return (id_alloc(svp_idspace));
55 }
56
57 static void
58 svp_remote_mkfmamsg(svp_remote_t *srp, svp_degrade_state_t state, char *buf,
59 size_t buflen)
60 {
61 switch (state) {
62 case SVP_RD_DNS_FAIL:
63 (void) snprintf(buf, buflen, "failed to resolve or find "
64 "entries for hostname %s", srp->sr_hostname);
65 break;
66 case SVP_RD_REMOTE_FAIL:
67 (void) snprintf(buf, buflen, "cannot reach any remote peers");
68 break;
69 default:
70 (void) snprintf(buf, buflen, "unkonwn error state: %d", state);
71 }
72 }
73
74 static int
75 svp_remote_comparator(const void *l, const void *r)
76 {
|