-char buffer[MAXBUFSIZE+1];
-int buflen;
-
-/* Outgoing request routines */
-
-int send_ack(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending ACK to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", ACK);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %d:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_termreq(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending TERMREQ to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", TERMREQ, myself->vpn_ip);
-
- if(write(cl->meta_socket, buffer, buflen) < 0)
- {
- if(debug_lvl > 1)
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_timeout(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending TIMEOUT to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", PINGTIMEOUT, myself->vpn_ip);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_del_host(conn_list_t *cl, conn_list_t *new_host)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending DEL_HOST for %s (%s) to %s (%s)"),
- new_host->vpn_hostname, new_host->real_hostname, cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", DEL_HOST, new_host->vpn_ip);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-/* Evil hack - TCP tunneling is bad */
-int send_tcppacket(conn_list_t *cl, void *data, int len)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending PACKET to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %d\n", PACKET, len);
-
- if((write(cl->meta_socket, buffer, buflen)) != buflen)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-
- if((write(cl->meta_socket, data, len)) != len)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-
-cp
- return 0;
-}
-
-int send_ping(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending PING to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PING);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_pong(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending PONG to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PONG);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_add_host(conn_list_t *cl, conn_list_t *new_host)
-{
- ip_t real_ip;
- int flags;
- char *hostname;
-cp
- real_ip = new_host->real_ip;
- hostname = new_host->real_hostname;
- flags = new_host->flags;
-
- /* If we need to propagate information about a new host that wants us to export
- * it's indirectdata flag, we set the INDIRECTDATA flag and unset the EXPORT...
- * flag, and set it's real_ip to our vpn_ip, so that net.c send_packet() will
- * work correctly.
- */
-
- if(flags & EXPORTINDIRECTDATA)
- {
- flags &= ~EXPORTINDIRECTDATA;
- flags |= INDIRECTDATA;
- real_ip = myself->vpn_ip;
- hostname = myself->real_hostname;
- }
-
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending ADD_HOST for %s (%s) to %s (%s)"),
- new_host->vpn_hostname, hostname, cl->vpn_hostname, cl->real_hostname);
-
- 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);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_key_changed(conn_list_t *cl, conn_list_t *src)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending KEY_CHANGED origin %s to %s (%s)"),
- src->vpn_hostname, cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", KEY_CHANGED, src->vpn_ip);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-void send_key_changed_all(void)
-{
- conn_list_t *p;
-cp
- for(p = conn_list; p != NULL; p = p->next)
- if(p->status.meta && p->status.active)
- send_key_changed(p, myself);
-cp
-}
-
-int send_basic_info(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending BASIC_INFO to %s"),
- cl->real_hostname);
-
- 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);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_passphrase(conn_list_t *cl)
-{
- passphrase_t tmp;
-cp
- encrypt_passphrase(&tmp);
-
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending PASSPHRASE to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PASSPHRASE, tmp.phrase);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-int send_public_key(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending PUBLIC_KEY to %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PUBLIC_KEY, my_public_key_base36);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-
-/* WDN doet deze functie? (GS)
-int send_calculate(conn_list_t *cl, char *k)
-{
-cp
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", CALCULATE, k);
-
- if((write(cl->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
-cp
- return 0;
-}
-*/
-
-int send_key_request(ip_t to)
-{
- conn_list_t *fw;
-cp
- fw = lookup_conn(to);
- if(!fw)
- {
- syslog(LOG_ERR, _("Attempting to send REQ_KEY to %d.%d.%d.%d, which does not exist?"),
- IP_ADDR_V(to));
- return -1;
- }
-
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending REQ_KEY to %s (%s)"),
- fw->nexthop->vpn_hostname, fw->nexthop->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx\n", REQ_KEY, to, myself->vpn_ip);
-
- if((write(fw->nexthop->meta_socket, buffer, buflen)) < 0)
- {
- syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
- return -1;
- }
- fw->status.waitingforkey = 1;
-cp
- return 0;
-}
-
-int send_key_answer(conn_list_t *cl, ip_t to)
-{
- conn_list_t *fw;
-cp
-
- fw = lookup_conn(to);
-
- if(!fw)
- {
- syslog(LOG_ERR, _("Attempting to send ANS_KEY to %d.%d.%d.%d, which does not exist?"),
- IP_ADDR_V(to));
- return -1;
- }
-
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending ANS_KEY to %s (%s)"),
- fw->nexthop->vpn_hostname, fw->nexthop->real_hostname);
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx %d %s\n", ANS_KEY, to, myself->vpn_ip, my_key_expiry, my_public_key_base36);