This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrhfunc.h
145 lines (120 loc) · 3.38 KB
/
rhfunc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (c) 2010-2011, Red Hat, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND RED HAT, INC. DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RED HAT, INC. BE LIABLE
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Author: Jan Friesse <jfriesse@redhat.com>
*/
#ifndef _RHFUNC_H_
#define _RHFUNC_H_
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <netdb.h>
#include "addrfunc.h"
#include "gcra.h"
#include "util.h"
#ifdef __cplusplus
extern "C" {
#endif
enum rh_client_state {
RH_CS_INITIAL,
RH_CS_QUERY,
RH_CS_STOP
};
enum rh_server_state {
RH_SS_INITIAL,
RH_SS_ANSWER,
RH_SS_FINISHING,
};
enum rh_client_stop_reason {
RH_CSR_NONE,
RH_CSR_SERVER,
RH_CSR_TO_SEND_EXHAUSTED,
RH_CSR_SEND_MAXIMUM,
RH_CSR_REMOTE_VERSION_RECEIVED,
};
enum rh_list_finish_state {
RH_LFS_CLIENT,
RH_LFS_SERVER,
RH_LFS_BOTH,
};
/*
* Remote host info item, client info part
*/
struct rh_item_ci {
enum rh_client_state state;
char client_id[CLIENTID_LEN];
struct timeval last_init_ts;
struct timeval last_query_ts;
char *server_info;
char *ses_id;
uint32_t *dup_buffer[2];
size_t server_info_len;
size_t ses_id_len;
double avg_rtt[2];
double m2_rtt[2];
double rtt_max[2];
double rtt_min[2];
uint64_t no_err_msgs;
uint64_t no_dups[2];
uint64_t no_received[2];
uint64_t no_sent;
uint32_t first_mcast_seq;
uint32_t lru_seq_num; /* Last Received Unicast seq number */
uint32_t seq_num;
int dup_buf_items;
int seq_num_overflow;
};
/*
* Remote host info item, server info part
*/
struct rh_item_si {
enum rh_server_state state;
char ses_id[SESSIONID_LEN];
struct gcra_item gcra;
struct timeval last_init_ts;
};
/*
* Remote host info item. This is intended to use with TAILQ list.
*/
struct rh_item {
struct ai_item *addr;
struct rh_item_ci client_info;
struct rh_item_si server_info;
TAILQ_ENTRY(rh_item) entries;
};
/*
* Typedef of TAILQ head of list of rh_item(s)
*/
TAILQ_HEAD(rh_list, rh_item);
extern int rh_ci_is_dup_packet(const struct rh_item_ci *ci, uint32_t seq,
int cast_index);
extern struct rh_item *rh_list_add_item(struct rh_list *rh_list, struct ai_item *addr,
int dup_buf_items, int rate_limit_time);
extern void rh_list_create(struct rh_list *rh_list, struct aii_list *remote_addrs,
int dup_buf_items, int rate_limit_time);
extern struct rh_item *rh_list_find(struct rh_list *rh_list, const struct sockaddr *sa);
extern void rh_list_free(struct rh_list *rh_list);
extern void rh_list_gen_cid(struct rh_list *rh_list,
const struct ai_item *local_addr);
extern int rh_list_hn_max_len(struct rh_list *rh_list);
extern unsigned int rh_list_length(const struct rh_list *rh_list);
extern void rh_list_put_to_finish_state(struct rh_list *rh_list,
enum rh_list_finish_state fs);
#ifdef __cplusplus
}
#endif
#endif /* _RHFUNC_H_ */