/*

esp_proute.h

Author: Liraz Siri <liraz@bigfoot.com>

Copyrights (c) 1998 Liraz Siri <liraz@bigfoot.com>, Ariel, Israel,
		    All rights reserved.

Created: Sat Oct  3 01:27:32 GMT 1998

Code for the implementation client configuration of a remote esp
server routing table. Currently only used by the proute client.
*/

#include "esp_route.h"

/*****************************
 * PUBLIC routine prototypes *
 *****************************/

/*-------------------------------------------------------------------------*
   Send a esp route operation to the server side. This should be
   either SSH_CMSG_ROUTE_SET_RULE or SSH_CMSG_ROUTE_RM_RULE, anything
   else will be considered just plain rude. What this actually does
   is set 3 rules on the server's routing table. One rule for our
   negotiation (aka esp_SYN) packet, which will expire immediately
   after we use it, and another two rules for the actual session
   routing (these live indefinately, until removed).

   What/How/Why we set the routing table:
    We resolve host, which is the system we actually want to tunnel
    a connection to, find a suitable local network address, and then
    set the following rule:
    Map symbols ( -> = router-in-the-middle )

    1) OUR_ADDR (proto) [srcport:dstport] -> REMOTE_ADDR (proto) [src:dstport]
    2) REMOTE_ADDR (proto) [srcport:dstport] -> OUR_ADDR (proto) [src:dstport]

 *-------------------------------------------------------------------------*/
void esp_proute_sendop(int type, char *source_host, char *host, int port,
                           int transmit_proto, int receive_proto, 
			   int negotiation_only);

/*-- Request the remote server to kindly destroy it's routing table --*/
void esp_proute_remove_all(void);







/******************************
 * PRIVATE routine prototypes *
 ******************************/

/*-- Transmit our rule op (setrule/rmrule) via ssh's packet mechanism --*/
int transmit_rule(int type, routerule *route_rule);

/*-- simple little swap function that could --*/
void swap(u_short *a, u_short *b);

/*-- Look up a hostname, checking first to check wether it's an ip,
     and then actually using gethostbyname to resolve it. Return the
     32bit network number on success, -1 on failure --*/
unsigned long hostlookup(char *host);






