Lines Matching defs:adhost
84 static struct adist_host *adhost;
144 if (proto_send(adhost->adh_conn, &val, sizeof(val)) < 0) {
148 if (proto_recv(adhost->adh_conn, &val, sizeof(val)) < 0) {
155 adhost->adh_remoteaddr);
158 if (proto_connection_recv(adhost->adh_conn, true, &conn) < 0) {
164 adhost->adh_remoteaddr);
168 pjdlog_debug(1, "Connected to %s.", adhost->adh_remoteaddr);
180 adhost->adh_remoteaddr);
189 adhost->adh_remoteaddr);
196 adhost->adh_remoteaddr);
205 adhost->adh_version = atoi(welcome + 5);
206 if (adhost->adh_version > ADIST_VERSION) {
208 adhost->adh_remoteaddr, adhost->adh_version, ADIST_VERSION);
213 pjdlog_debug(1, "Version %d negotiated with %s.", adhost->adh_version,
214 adhost->adh_remoteaddr);
218 adhost->adh_remoteaddr);
226 adhost->adh_remoteaddr);
232 if (HMAC(EVP_sha256(), adhost->adh_password,
233 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
243 adhost->adh_remoteaddr);
258 adhost->adh_remoteaddr);
266 adhost->adh_remoteaddr);
272 if (HMAC(EVP_sha256(), adhost->adh_password,
273 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
283 adhost->adh_remoteaddr);
289 if (proto_recv(conn, &adhost->adh_trail_offset,
290 sizeof(adhost->adh_trail_offset)) == -1) {
293 adhost->adh_remoteaddr);
297 adhost->adh_trail_offset = le64toh(adhost->adh_trail_offset);
298 if (proto_recv(conn, &adhost->adh_trail_name,
299 sizeof(adhost->adh_trail_name)) == -1) {
302 adhost->adh_remoteaddr);
307 adhost->adh_trail_name, (uintmax_t)adhost->adh_trail_offset);
311 PJDLOG_ASSERT(adhost->adh_remote == NULL);
313 adhost->adh_remote = conn;
330 if (adhost->adh_remote == NULL) {
334 pjdlog_debug(2, "Closing connection to %s.", adhost->adh_remoteaddr);
335 proto_close(adhost->adh_remote);
337 adhost->adh_remote = NULL;
338 adhost->adh_reset = true;
339 adhost->adh_trail_name[0] = '\0';
340 adhost->adh_trail_offset = 0;
344 pjdlog_warning("Disconnected from %s.", adhost->adh_remoteaddr);
396 if (adhost->adh_reset) {
398 adhost->adh_reset = false;
402 while (adhost->adh_remote == NULL)
404 trail_start(adist_trail, adhost->adh_trail_name,
405 adhost->adh_trail_offset);
417 if (adhost->adh_reset)
425 adhost->adh_directory,
462 adhost->adh_directory, trail_filename(adist_trail),
470 adhost->adh_directory, trail_filename(adist_trail));
503 if (adhost->adh_remote == NULL) {
562 if (adhost->adh_remote == NULL ||
563 proto_send(adhost->adh_remote, &adreq->adr_packet,
568 if (adhost->adh_remote != NULL)
611 if (adhost->adh_remote == NULL) {
619 if (proto_recv(adhost->adh_remote, &adrep,
679 PJDLOG_ASSERT(adhost->adh_role == ADIST_ROLE_SENDER);
682 if (adhost->adh_remote != NULL) {
685 adhost->adh_remoteaddr);
695 adhost->adh_remoteaddr);
698 adhost->adh_remoteaddr);
701 adhost->adh_remoteaddr);
785 adhost = adh;
791 proto_send(adhost->adh_conn, NULL, 0);
793 descriptors_cleanup(adhost);
796 descriptors_assert(adhost, mode);
801 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
802 role2str(adhost->adh_role));
804 setproctitle("[%s] (%s) ", adhost->adh_name,
805 role2str(adhost->adh_role));
813 adist_trail = trail_new(adhost->adh_directory, false);
818 role2str(adhost->adh_role), adhost->adh_name) != 0) {
832 adhost->adh_remoteaddr);
834 adhost->adh_reset = true;