/* GABA:
   (expr
     (name forward_local_port)
     (globals
       (listen LISTEN_COMMAND)
       (start_io TCPIP_START_IO))
     (params
       (backend object io_backend)
       (local object address_info)
       (target object address_info))
     (expr
       (lambda (connection)
         (listen (lambda (peer)
	           (start_io (open_direct_tcpip target peer connection)))
		 backend
	         local))))
*/

static struct lsh_object *
forward_local_port(struct io_backend *backend,
		   struct address_info *local,
		   struct address_info *target)
{
  /* (C (C (B* listen (B start_io) (C (open_direct_tcpip target)))
           backend) local) */
  return MAKE_TRACE("forward_local_port", 
    C2(C2(Bp3(LISTEN_COMMAND, B1(TCPIP_START_IO),
	      C1(A(OPEN_DIRECT_TCPIP, ((struct lsh_object *) target)))),
	  ((struct lsh_object *) backend)),
       ((struct lsh_object *) local)));
}