-char buffer[MAXBUFSIZE+1];
-int buflen;
-
-/* Outgoing request routines */
-
-int send_ack(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, "Send ACK to %s", cl->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;
- }
-
- syslog(LOG_NOTICE, "Connection with %s activated.", cl->hostname);
-cp
- return 0;
-}
-
-int send_termreq(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, "Send TERMREQ to " IP_ADDR_S,
- IP_ADDR_V(cl->vpn_ip));
-
- 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 > 2)
- syslog(LOG_DEBUG, "Send TIMEOUT to " IP_ADDR_S,
- IP_ADDR_V(cl->vpn_ip));
-
- 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 > 2)
- syslog(LOG_DEBUG, "Sending delete host " IP_ADDR_S " to " IP_ADDR_S,
- IP_ADDR_V(new_host->vpn_ip), IP_ADDR_V(cl->vpn_ip));
-
- 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;
-}
-
-int send_ping(conn_list_t *cl)
-{
-cp
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, "pinging " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip));
-
- 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
- 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)
-{
-cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, "Sending add host to " IP_ADDR_S,
- IP_ADDR_V(cl->vpn_ip));
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx/%lx:%x\n", ADD_HOST, new_host->real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port);
-
- 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 > 2)
- syslog(LOG_DEBUG, "Sending KEY_CHANGED to " IP_ADDR_S,
- IP_ADDR_V(cl->vpn_ip));
-
- 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 > 2)
- syslog(LOG_DEBUG, "Send BASIC_INFO to " IP_ADDR_S,
- IP_ADDR_V(cl->real_ip));
-
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %d %lx/%lx:%x\n", BASIC_INFO, PROT_CURRENT, myself->vpn_ip, myself->vpn_mask, myself->port);
-
- 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 > 2)
- syslog(LOG_DEBUG, "Send PASSPHRASE %s to " IP_ADDR_S,
- tmp.phrase, IP_ADDR_V(cl->vpn_ip));
-
- 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 > 2)
- syslog(LOG_DEBUG, "Send PUBLIC_KEY %s to " IP_ADDR_S,
- my_public_key_base36, IP_ADDR_V(cl->vpn_ip));
-
- 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;
-}
-
-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;
-}