2 protocol.c -- handle the meta-protocol
3 Copyright (C) 1999,2000 Ivo Timmermans <itimmermans@bigfoot.com>,
4 2000 Guus Sliepen <guus@sliepen.warande.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 $Id: protocol.c,v 1.28.4.24 2000/08/08 17:07:48 guus Exp $
25 #include <sys/types.h>
30 #include <sys/socket.h>
37 #include <netinet/in.h>
47 char buffer[MAXBUFSIZE+1];
50 /* Outgoing request routines */
52 int send_ack(conn_list_t *cl)
56 syslog(LOG_DEBUG, _("Sending ACK to %s (%s)"),
57 cl->vpn_hostname, cl->real_hostname);
59 buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", ACK);
61 if((write(cl->meta_socket, buffer, buflen)) < 0)
63 syslog(LOG_ERR, _("Send failed: %d:%d: %m"), __FILE__, __LINE__);
70 int send_termreq(conn_list_t *cl)
74 syslog(LOG_DEBUG, _("Sending TERMREQ to %s (%s)"),
75 cl->vpn_hostname, cl->real_hostname);
77 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", TERMREQ, myself->vpn_ip);
79 if(write(cl->meta_socket, buffer, buflen) < 0)
82 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
89 int send_timeout(conn_list_t *cl)
93 syslog(LOG_DEBUG, _("Sending TIMEOUT to %s (%s)"),
94 cl->vpn_hostname, cl->real_hostname);
96 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", PINGTIMEOUT, myself->vpn_ip);
98 if((write(cl->meta_socket, buffer, buflen)) < 0)
100 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
107 int send_del_host(conn_list_t *cl, conn_list_t *new_host)
111 syslog(LOG_DEBUG, _("Sending DEL_HOST for %s (%s) to %s (%s)"),
112 new_host->vpn_hostname, new_host->real_hostname, cl->vpn_hostname, cl->real_hostname);
114 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", DEL_HOST, new_host->vpn_ip);
116 if((write(cl->meta_socket, buffer, buflen)) < 0)
118 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
125 /* Evil hack - TCP tunneling is bad */
126 int send_tcppacket(conn_list_t *cl, void *data, int len)
130 syslog(LOG_DEBUG, _("Sending PACKET to %s (%s)"),
131 cl->vpn_hostname, cl->real_hostname);
133 buflen = snprintf(buffer, MAXBUFSIZE, "%d %d\n", PACKET, len);
135 if((write(cl->meta_socket, buffer, buflen)) < 0)
137 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
141 if((write(cl->meta_socket, data, len)) < 0)
143 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
150 int send_ping(conn_list_t *cl)
154 syslog(LOG_DEBUG, _("Sending PING to %s (%s)"),
155 cl->vpn_hostname, cl->real_hostname);
157 buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PING);
159 if((write(cl->meta_socket, buffer, buflen)) < 0)
161 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
168 int send_pong(conn_list_t *cl)
172 syslog(LOG_DEBUG, _("Sending PONG to %s (%s)"),
173 cl->vpn_hostname, cl->real_hostname);
175 buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PONG);
177 if((write(cl->meta_socket, buffer, buflen)) < 0)
179 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
186 int send_add_host(conn_list_t *cl, conn_list_t *new_host)
192 real_ip = new_host->real_ip;
193 hostname = new_host->real_hostname;
194 flags = new_host->flags;
196 /* If we need to propagate information about a new host that wants us to export
197 * it's indirectdata flag, we set the INDIRECTDATA flag and unset the EXPORT...
198 * flag, and set it's real_ip to our vpn_ip, so that net.c send_packet() will
202 if(flags & EXPORTINDIRECTDATA)
204 flags &= ~EXPORTINDIRECTDATA;
205 flags |= INDIRECTDATA;
206 real_ip = myself->vpn_ip;
207 hostname = myself->real_hostname;
211 syslog(LOG_DEBUG, _("Sending ADD_HOST for %s (%s) to %s (%s)"),
212 new_host->vpn_hostname, hostname, cl->vpn_hostname, cl->real_hostname);
214 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx/%lx:%x %d\n", ADD_HOST, real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port, flags);
216 if((write(cl->meta_socket, buffer, buflen)) < 0)
218 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
225 int send_key_changed(conn_list_t *cl, conn_list_t *src)
229 syslog(LOG_DEBUG, _("Sending KEY_CHANGED origin %s to %s (%s)"),
230 src->vpn_hostname, cl->vpn_hostname, cl->real_hostname);
232 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", KEY_CHANGED, src->vpn_ip);
234 if((write(cl->meta_socket, buffer, buflen)) < 0)
236 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
243 void send_key_changed_all(void)
247 for(p = conn_list; p != NULL; p = p->next)
248 if(p->status.meta && p->status.active)
249 send_key_changed(p, myself);
253 int send_basic_info(conn_list_t *cl)
257 syslog(LOG_DEBUG, _("Sending BASIC_INFO to %s"),
260 buflen = snprintf(buffer, MAXBUFSIZE, "%d %d %lx/%lx:%x %d\n", BASIC_INFO, PROT_CURRENT, myself->vpn_ip, myself->vpn_mask, myself->port, myself->flags);
262 if((write(cl->meta_socket, buffer, buflen)) < 0)
264 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
271 int send_passphrase(conn_list_t *cl)
275 encrypt_passphrase(&tmp);
278 syslog(LOG_DEBUG, _("Sending PASSPHRASE to %s (%s)"),
279 cl->vpn_hostname, cl->real_hostname);
281 buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PASSPHRASE, tmp.phrase);
283 if((write(cl->meta_socket, buffer, buflen)) < 0)
285 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
292 int send_public_key(conn_list_t *cl)
296 syslog(LOG_DEBUG, _("Sending PUBLIC_KEY to %s (%s)"),
297 cl->vpn_hostname, cl->real_hostname);
299 buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PUBLIC_KEY, my_public_key_base36);
301 if((write(cl->meta_socket, buffer, buflen)) < 0)
303 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
310 /* WDN doet deze functie? (GS)
311 int send_calculate(conn_list_t *cl, char *k)
314 buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", CALCULATE, k);
316 if((write(cl->meta_socket, buffer, buflen)) < 0)
318 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
326 int send_key_request(ip_t to)
330 fw = lookup_conn(to);
333 syslog(LOG_ERR, _("Attempting to send REQ_KEY to %d.%d.%d.%d, which does not exist?"),
339 syslog(LOG_DEBUG, _("Sending REQ_KEY to %s (%s)"),
340 fw->nexthop->vpn_hostname, fw->nexthop->real_hostname);
342 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx\n", REQ_KEY, to, myself->vpn_ip);
344 if((write(fw->nexthop->meta_socket, buffer, buflen)) < 0)
346 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
349 fw->status.waitingforkey = 1;
354 int send_key_answer(conn_list_t *cl, ip_t to)
359 fw = lookup_conn(to);
363 syslog(LOG_ERR, _("Attempting to send ANS_KEY to %d.%d.%d.%d, which does not exist?"),
369 syslog(LOG_DEBUG, _("Sending ANS_KEY to %s (%s)"),
370 fw->nexthop->vpn_hostname, fw->nexthop->real_hostname);
372 buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx %d %s\n", ANS_KEY, to, myself->vpn_ip, my_key_expiry, my_public_key_base36);
374 if((write(fw->nexthop->meta_socket, buffer, buflen)) < 0)
376 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
384 notify all my direct connections of a new host
385 that was added to the vpn, with the exception
386 of the source of the announcement.
388 int notify_others(conn_list_t *new, conn_list_t *source,
389 int (*function)(conn_list_t*, conn_list_t*))
393 for(p = conn_list; p != NULL; p = p->next)
394 if(p != new && p != source && p->status.meta && p->status.active)
401 notify one connection of everything
404 int notify_one(conn_list_t *new)
408 for(p = conn_list; p != NULL; p = p->next)
409 if(p != new && p->status.active)
410 send_add_host(new, p);
416 The incoming request handlers
419 int basic_info_h(conn_list_t *cl)
424 syslog(LOG_DEBUG, _("Got BASIC_INFO from %s"), cl->real_hostname);
426 if(sscanf(cl->buffer, "%*d %d %lx/%lx:%hx %d", &cl->protocol_version, &cl->vpn_ip, &cl->vpn_mask, &cl->port, &cl->flags) != 5)
428 syslog(LOG_ERR, _("Got bad BASIC_INFO from %s"),
433 cl->vpn_hostname = hostlookup(htonl(cl->vpn_ip));
435 if(cl->protocol_version != PROT_CURRENT)
437 syslog(LOG_ERR, _("Peer uses incompatible protocol version %d"),
438 cl->protocol_version);
442 if(cl->status.outgoing)
444 /* First check if the host we connected to is already in our
445 connection list. If so, we are probably making a loop, which
449 if((old=lookup_conn(cl->vpn_ip)))
452 syslog(LOG_NOTICE, _("Uplink %s (%s) is already in our connection list"),
453 cl->vpn_hostname, cl->real_hostname);
454 cl->status.outgoing = 0;
455 old->status.outgoing = 1;
456 terminate_connection(cl);
460 if(setup_vpn_connection(cl) < 0)
467 if(setup_vpn_connection(cl) < 0)
475 int passphrase_h(conn_list_t *cl)
478 cl->pp = xmalloc(sizeof(*(cl->pp)));
480 if(sscanf(cl->buffer, "%*d %as", &(cl->pp->phrase)) != 1)
482 syslog(LOG_ERR, _("Got bad PASSPHRASE from %s (%s)"),
483 cl->vpn_hostname, cl->real_hostname);
486 cl->pp->len = strlen(cl->pp->phrase);
489 syslog(LOG_DEBUG, _("Got PASSPHRASE from %s (%s)"),
490 cl->vpn_hostname, cl->real_hostname);
492 if(cl->status.outgoing)
500 int public_key_h(conn_list_t *cl)
505 if(sscanf(cl->buffer, "%*d %as", &g_n) != 1)
507 syslog(LOG_ERR, _("Got bad PUBLIC_KEY from %s (%s)"),
508 cl->vpn_hostname, cl->real_hostname);
513 syslog(LOG_DEBUG, _("Got PUBLIC_KEY from %s (%s)"),
514 cl->vpn_hostname, cl->real_hostname);
516 if(verify_passphrase(cl, g_n))
519 syslog(LOG_ERR, _("Intruder from %s: passphrase for %s does not match!"),
520 cl->real_hostname, cl->vpn_hostname);
524 if(cl->status.outgoing)
530 /* Okay, before we active the connection, we check if there is another entry
531 in the connection list with the same vpn_ip. If so, it presumably is an
532 old connection that has timed out but we don't know it yet.
535 while((old = lookup_conn(cl->vpn_ip)))
538 syslog(LOG_NOTICE, _("Removing old entry for %s at %s in favour of new connection from %s"),
539 cl->vpn_hostname, old->real_hostname, cl->real_hostname);
540 old->status.active = 0;
541 terminate_connection(old);
544 cl->status.active = 1;
547 syslog(LOG_NOTICE, _("Connection with %s (%s) activated"),
548 cl->vpn_hostname, cl->real_hostname);
550 notify_others(cl, NULL, send_add_host);
557 int ack_h(conn_list_t *cl)
561 syslog(LOG_DEBUG, _("Got ACK from %s (%s)"),
562 cl->vpn_hostname, cl->real_hostname);
564 cl->status.active = 1;
567 syslog(LOG_NOTICE, _("Connection with %s (%s) activated"),
568 cl->vpn_hostname, cl->real_hostname);
570 notify_others(cl, NULL, send_add_host);
578 int termreq_h(conn_list_t *cl)
581 if(!cl->status.active)
583 syslog(LOG_ERR, _("Got unauthorized TERMREQ from %s (%s)"),
584 cl->vpn_hostname, cl->real_hostname);
589 syslog(LOG_DEBUG, _("Got TERMREQ from %s (%s)"),
590 cl->vpn_hostname, cl->real_hostname);
592 cl->status.termreq = 1;
594 terminate_connection(cl);
599 int timeout_h(conn_list_t *cl)
602 if(!cl->status.active)
604 syslog(LOG_ERR, _("Got unauthorized TIMEOUT from %s (%s)"),
605 cl->vpn_hostname, cl->real_hostname);
610 syslog(LOG_DEBUG, _("Got TIMEOUT from %s (%s)"),
611 cl->vpn_hostname, cl->real_hostname);
613 cl->status.termreq = 1;
614 terminate_connection(cl);
619 int del_host_h(conn_list_t *cl)
624 if(!cl->status.active)
626 syslog(LOG_ERR, _("Got unauthorized DEL_HOST from %s (%s)"),
627 cl->vpn_hostname, cl->real_hostname);
631 if(sscanf(cl->buffer, "%*d %lx", &vpn_ip) != 1)
633 syslog(LOG_ERR, _("Got bad DEL_HOST from %s (%s)"),
634 cl->vpn_hostname, cl->real_hostname);
638 if(!(fw = lookup_conn(vpn_ip)))
640 syslog(LOG_ERR, _("Got DEL_HOST for %d.%d.%d.%d from %s (%s) which does not exist?"),
641 IP_ADDR_V(vpn_ip), cl->vpn_hostname, cl->real_hostname);
645 /* Connections lists are really messed up if this happens */
646 if(vpn_ip == myself->vpn_ip)
648 syslog(LOG_ERR, _("Warning: got DEL_HOST from %s (%s) for ourself, restarting"),
649 cl->vpn_hostname, cl->real_hostname);
655 syslog(LOG_DEBUG, _("Got DEL_HOST for %s (%s) from %s (%s)"),
656 fw->vpn_hostname, fw->real_hostname, cl->vpn_hostname, cl->real_hostname);
658 notify_others(fw, cl, send_del_host);
660 fw->status.termreq = 1;
661 fw->status.active = 0;
663 terminate_connection(fw);
668 int tcppacket_h(conn_list_t *cl)
672 if(!cl->status.active)
674 syslog(LOG_ERR, _("Got unauthorized PACKET from %s (%s)"),
675 cl->vpn_hostname, cl->real_hostname);
679 if(sscanf(cl->buffer, "%*d %d", &len) != 1)
681 syslog(LOG_ERR, _("Got bad PACKET from %s (%s)"),
682 cl->vpn_hostname, cl->real_hostname);
688 syslog(LOG_ERR, _("Got too big PACKET from %s (%s)"),
689 cl->vpn_hostname, cl->real_hostname);
694 syslog(LOG_DEBUG, _("Got PACKET length %d from %s (%s)"), len,
695 cl->vpn_hostname, cl->real_hostname);
703 int ping_h(conn_list_t *cl)
706 if(!cl->status.active)
708 syslog(LOG_ERR, _("Got unauthorized PING from %s (%s)"),
709 cl->vpn_hostname, cl->real_hostname);
714 syslog(LOG_DEBUG, _("Got PING from %s (%s)"),
715 cl->vpn_hostname, cl->real_hostname);
717 cl->status.pinged = 0;
718 cl->status.got_pong = 1;
725 int pong_h(conn_list_t *cl)
728 if(!cl->status.active)
730 syslog(LOG_ERR, _("Got unauthorized PONG from %s (%s)"),
731 cl->vpn_hostname, cl->real_hostname);
736 syslog(LOG_DEBUG, _("Got PONG from %s (%s)"),
737 cl->vpn_hostname, cl->real_hostname);
739 cl->status.got_pong = 1;
744 int add_host_h(conn_list_t *cl)
751 conn_list_t *ncn, *old;
753 if(!cl->status.active)
755 syslog(LOG_ERR, _("Got unauthorized ADD_HOST from %s (%s)"),
756 cl->vpn_hostname, cl->real_hostname);
760 if(sscanf(cl->buffer, "%*d %lx %lx/%lx:%hx %d", &real_ip, &vpn_ip, &vpn_mask, &port, &flags) != 5)
762 syslog(LOG_ERR, _("Got bad ADD_HOST from %s (%s)"),
763 cl->vpn_hostname, cl->real_hostname);
767 if((old = lookup_conn(vpn_ip)))
769 if((real_ip==old->real_ip) && (vpn_mask==old->vpn_mask) && (port==old->port))
772 syslog(LOG_NOTICE, _("Got duplicate ADD_HOST for %s (%s) from %s (%s)"),
773 old->vpn_hostname, old->real_hostname, cl->vpn_hostname, cl->real_hostname);
774 goto skip_add_host; /* One goto a day keeps the deeply nested if constructions away. */
779 syslog(LOG_NOTICE, _("Removing old entry for %s (%s)"),
780 old->vpn_hostname, old->real_hostname);
781 old->status.active = 0;
782 terminate_connection(old);
786 /* Connections lists are really messed up if this happens */
787 if(vpn_ip == myself->vpn_ip)
789 syslog(LOG_ERR, _("Warning: got ADD_HOST from %s (%s) for ourself, restarting"),
790 cl->vpn_hostname, cl->real_hostname);
795 ncn = new_conn_list();
796 ncn->real_ip = real_ip;
797 ncn->real_hostname = hostlookup(htonl(real_ip));
798 ncn->vpn_ip = vpn_ip;
799 ncn->vpn_mask = vpn_mask;
800 ncn->vpn_hostname = hostlookup(htonl(vpn_ip));
804 ncn->next = conn_list;
806 ncn->status.active = 1;
809 syslog(LOG_DEBUG, _("Got ADD_HOST for %s (%s) from %s (%s)"),
810 ncn->vpn_hostname, ncn->real_hostname, cl->vpn_hostname, cl->real_hostname);
812 notify_others(ncn, cl, send_add_host);
819 int req_key_h(conn_list_t *cl)
825 if(!cl->status.active)
827 syslog(LOG_ERR, _("Got unauthorized REQ_KEY from %s (%s)"),
828 cl->vpn_hostname, cl->real_hostname);
832 if(sscanf(cl->buffer, "%*d %lx %lx", &to, &from) != 2)
834 syslog(LOG_ERR, _("Got bad REQ_KEY from %s (%s)"),
835 cl->vpn_hostname, cl->real_hostname);
840 syslog(LOG_DEBUG, _("Got REQ_KEY origin %d.%d.%d.%d destination %d.%d.%d.%d from %s (%s)"),
841 IP_ADDR_V(from), IP_ADDR_V(to), cl->vpn_hostname, cl->real_hostname);
843 if((to & myself->vpn_mask) == (myself->vpn_ip & myself->vpn_mask))
844 { /* hey! they want something from ME! :) */
845 send_key_answer(cl, from);
849 fw = lookup_conn(to);
853 syslog(LOG_ERR, _("Attempting to forward REQ_KEY to %d.%d.%d.%d, which does not exist?"),
859 syslog(LOG_DEBUG, _("Forwarding REQ_KEY to %s (%s)"),
860 fw->nexthop->vpn_hostname, fw->nexthop->real_hostname);
862 cl->buffer[cl->reqlen-1] = '\n';
864 if(write(fw->nexthop->meta_socket, cl->buffer, cl->reqlen) < 0)
866 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
873 void set_keys(conn_list_t *cl, int expiry, char *key)
879 cl->public_key = xmalloc(sizeof(*cl->key));
880 cl->public_key->key = NULL;
883 if(cl->public_key->key)
884 free(cl->public_key->key);
885 cl->public_key->length = strlen(key);
886 cl->public_key->expiry = expiry;
887 cl->public_key->key = xmalloc(cl->public_key->length + 1);
888 strcpy(cl->public_key->key, key);
890 ek = make_shared_key(key);
894 cl->key = xmalloc(sizeof(*cl->key));
901 cl->key->length = strlen(ek);
902 cl->key->expiry = expiry;
903 cl->key->key = xmalloc(cl->key->length + 1);
904 strcpy(cl->key->key, ek);
908 int ans_key_h(conn_list_t *cl)
914 conn_list_t *fw, *gk;
916 if(!cl->status.active)
918 syslog(LOG_ERR, _("Got unauthorized ANS_KEY from %s (%s)"),
919 cl->vpn_hostname, cl->real_hostname);
923 if(sscanf(cl->buffer, "%*d %lx %lx %d %as", &to, &from, &expiry, &key) != 4)
925 syslog(LOG_ERR, _("Got bad ANS_KEY from %s (%s)"),
926 cl->vpn_hostname, cl->real_hostname);
931 syslog(LOG_DEBUG, _("Got ANS_KEY origin %d.%d.%d.%d destination %d.%d.%d.%d from %s (%s)"),
932 IP_ADDR_V(from), IP_ADDR_V(to), cl->vpn_hostname, cl->real_hostname);
934 if(to == myself->vpn_ip)
935 { /* hey! that key's for ME! :) */
936 gk = lookup_conn(from);
940 syslog(LOG_ERR, _("Receiving ANS_KEY origin %d.%d.%d.%d from %s (%s), which does not exist?"),
941 IP_ADDR_V(from), cl->vpn_hostname, cl->real_hostname);
945 set_keys(gk, expiry, key);
946 gk->status.validkey = 1;
947 gk->status.waitingforkey = 0;
952 fw = lookup_conn(to);
956 syslog(LOG_ERR, _("Attempting to forward ANS_KEY to %d.%d.%d.%d, which does not exist?"),
962 syslog(LOG_DEBUG, _("Forwarding ANS_KEY to %s (%s)"),
963 fw->nexthop->vpn_hostname, fw->nexthop->real_hostname);
965 cl->buffer[cl->reqlen-1] = '\n';
967 if((write(fw->nexthop->meta_socket, cl->buffer, cl->reqlen)) < 0)
969 syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
976 int key_changed_h(conn_list_t *cl)
981 if(!cl->status.active)
983 syslog(LOG_ERR, _("Got unauthorized KEY_CHANGED from %s (%s)"),
984 cl->vpn_hostname, cl->real_hostname);
988 if(sscanf(cl->buffer, "%*d %lx", &from) != 1)
990 syslog(LOG_ERR, _("Got bad KEY_CHANGED from %s (%s)"),
991 cl->vpn_hostname, cl->real_hostname);
995 ik = lookup_conn(from);
999 syslog(LOG_ERR, _("Got KEY_CHANGED origin %d.%d.%d.%d from %s (%s), which does not exist?"),
1000 IP_ADDR_V(from), cl->vpn_hostname, cl->real_hostname);
1005 syslog(LOG_DEBUG, _("Got KEY_CHANGED origin %s from %s (%s)"),
1006 ik->vpn_hostname, cl->vpn_hostname, cl->real_hostname);
1008 ik->status.validkey = 0;
1009 ik->status.waitingforkey = 0;
1011 notify_others(ik, cl, send_key_changed);
1016 int (*request_handlers[256])(conn_list_t*) = {
1017 0, ack_h, 0, 0, 0, 0, 0, 0, 0, 0,
1018 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1019 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1020 termreq_h, timeout_h, del_host_h, 0, 0, 0, 0, 0, 0, 0,
1021 ping_h, pong_h, 0, 0, 0, 0, 0, 0, 0, 0,
1022 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023 add_host_h, basic_info_h, passphrase_h, public_key_h, 0, 0, 0, 0, 0, 0,
1024 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1025 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1026 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1027 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1028 tcppacket_h, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1029 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1030 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1031 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1032 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1033 req_key_h, ans_key_h, key_changed_h, 0, 0, 0, 0, 0, 0, 0,
1034 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1035 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1036 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1037 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1039 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1041 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,