HELP SETTING A CU_SEEME GATEWAY

Juan Carlos Cuesta Cuesta (jcc@litio.tid.es)
Wed, 14 Jun 95 18:44:23 METDST


I don't have direct internet gateway. The only access to INTERNET that I have
is throw a UNIX machine. I decided to create a program that reads the packets
from my PC throw the local network and then send it to INTERNET.
It does the following:
- opens 7648, 7649, 7650 and 7651 to receive datagrams
- when it receives anything from this port, it connects to the reflector
using the same port number if it wasn't already connected and writes
everything it receives.
It simply forwards everything it receives.
It already detects when it push the Cu-SeeMe CONNECT button but it fails to
connect to the reflector port number 7648. I've already tryed with more than
five reflector from the list posted to this list.
Could anybody tell me what ports are used in the transference between the
reflector and Cu-SeeME?

Following is a listing of my program and the results of executing it with the
parameters sivatbox 130.235.128.100 (sivatbox is my PC name).
Thanks
J. C. Cuesta
Madrid (SPAIN)



===========================================================================
===========================================================================
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>

typedef enum {
TRANSF_OUT, /* From LAN to INTERNET */
TRANSF_IN /* From INTERNET to LAN */
} TRANSF_TYPE;

typedef struct {
TRANSF_TYPE type; /* Transfer way */
int port; /* Port number */
int recep; /* Socket in */
int trans; /* Socket out */
} CONEXION;

/* Puertos del servicio */
#define VID_PORT 7648
#define CONTROL_PORT 7649
#define NV_PORT 7650
#define RF_PORT 7651

#define PUERTO_CONEXION VID_PORT

/* Conexions */
CONEXION conections[] = {{TRANSF_OUT,PUERTO_CONEXION,0,0},
{TRANSF_IN,0,0},
{TRANSF_IN,0,0},
{TRANSF_IN,0,0}};

struct sockaddr_in dir_out;
struct sockaddr_in dir_in;

#define SYS(x) (errno = 0 , x , errno == 0)

main(argc, argv)
int argc;
char * argv[];
{
fd_set lectura;
struct sockaddr_in address;
int tamano = sizeof(address);
int socket_escucha;
int max_socket;
int i;
int opcion_tcp = 1;
int puerto_org;
int puerto_des;
int sock_origen;
int sock_destino;
CONEXION *conex;
struct hostent *hp;

int portsNumber = sizeof(conections)/sizeof(conections[0]);

if (argc != 3)
{
fprintf(stderr,"Use: %s pc hosts\n", argv[0]);
exit(1);
}

/* Set the structure from opening requests ports */
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;

/* Open the reception socket from every port */
for (i = 0; i < portsNumber; i++)
{
address.sin_port = conections[i].port;
conections[i].recep = socket(AF_INET, SOCK_DGRAM, 0);

if (!SYS(bind(conections[i].recep,&address,tamano)))
{
perror("BIND");
exit(1);
}
}

/* Get the destination host (reflector) */
hp = gethostbyname(argv[2]);
if (hp != NULL)
{
dir_out.sin_family = AF_INET;
memcpy((char *)&dir_out.sin_addr,hp->h_addr,hp->h_length);
}

/* Get the local host (PC) */
hp = gethostbyname(argv[1]);
if (hp != NULL)
{
dir_in.sin_family = AF_INET;
memcpy((char *)&dir_in.sin_addr,hp->h_addr,hp->h_length);
}

loop();
}

changeBytes(s_origen, s_destino)
int s_origen, s_destino;
{
char buffer[1];
int nbytes = read(s_origen, buffer, sizeof(buffer));
return nbytes > 0 && nbytes == write(s_destino, buffer, nbytes);
}

loop()
{
fd_set lectura;
CONEXION *conex;
int sockConex; /* Socket de conexion */
int max_socket; /* Limite de sockets */
int portsNumber = sizeof(conections)/sizeof(conections[0]);
struct sockaddr_in address;
struct sockaddr_in dir_dest;
int ip_dest;
int i;

while(1)
{
/* Fill select descriptor */
FD_ZERO(&lectura);

for (max_socket = i = 0; i < portsNumber; i++)
if (conections[i].recep > 0)
{
FD_SET(conections[i].recep,&lectura);
max_socket = conections[i].recep;
}

if (max_socket < sockConex)
max_socket = sockConex;

/* Wait */
if (!SYS(select(max_socket+1,&lectura,NULL,NULL,NULL)))
{
perror("SELECT");
exit(1);
}

/* Read */
for (max_socket = i = 0; i < portsNumber; i++)
if (conections[i].recep > 0 &&
FD_ISSET(conections[i].recep,&lectura))
{
if (conections[i].trans == 0)
{
/* Connect to reflector port */
if (!SYS(conections[i].trans = socket(AF_INET,
SOCK_STREAM,0)))
{
perror("reflector socket");
}

dir_out.sin_port = conections[i].port;
if (!SYS(connect(conections[i].trans,&dir_out,
sizeof(dir_out))))
{
perror("connect to reflector");
close(conections[i].trans);
}
else
{
/* Conection ok */
changeBytes(conections[i].recep,
conections[i].trans);
}
}
else
changeBytes(conections[i].recep,conections[i].trans);

}


}
}

==========================================================================
==========================================================================

connect to reflector: Connection refused