Exemple #1
0
int main(int argc, char* argv[]) {
  struct tuntap_dev tuntap;
  int i;
  int mtu = 1400;

  printf("Welcome to n2n\n");
  initWin32();
  open_wintap(&tuntap, "1.2.3.20", "255.255.255.0", mtu);

  for(i=0; i<10; i++) {
    u_char buf[MTU];
    int rc;

    rc = tun_read(&tuntap, buf, sizeof(buf));
    buf[0]=2;
    buf[1]=3;
    buf[2]=4;

    printf("tun_read returned %d\n", rc);
    rc = tun_write(&tuntap, buf, rc);
    printf("tun_write returned %d\n", rc);
  }
  // rc = tun_open (device->device_name, IF_MODE_TUN);
  WSACleanup ();
  return(0);
}
Exemple #2
0
/** Initialise the supernode structure */
static int init_sn( n2n_sn_t * sss )
{
#ifdef WIN32
    initWin32();
#endif
    memset( sss, 0, sizeof(n2n_sn_t) );

    sss->daemon = 1; /* By defult run as a daemon. */
    sss->lport = N2N_SN_LPORT_DEFAULT;
    sss->sock = -1;
    sss->mgmt_sock = -1;
    sss->edges = NULL;

#ifdef N2N_MULTIPLE_SUPERNODES
    sss->snm_discovery_state = N2N_SNM_STATE_DISCOVERY;
    sss->sn_sock = -1;
    sss->seq_num = -1;
    memset(&sss->supernodes, 0, sizeof(sn_list_t));
    memset(&sss->communities, 0, sizeof(comm_list_t));
#endif

    return 0; /* OK */
}
Exemple #3
0
int main(int argc, char* argv[])
{
	struct tuntap_dev tuntap;
	int i;
	int mtu = 1400;

	printf("Welcome to n2n\n");
	initWin32();
	open_wintap(&tuntap, "static", "192.168.0.2", "255.255.255.0", "00 ff 65 21 b3 dd",mtu);

	//for (i = 0; i < 10; i++)
	while(1)
	{
		u_char buf[MTU];
		int rc;

		rc = tuntap_read(&tuntap, buf, sizeof(buf));
		dumphex(NULL, (char*)buf, rc);
		buf[0] = 2;
		buf[1] = 3;
		buf[2] = 4;

		printf("tun_read returned %d\n", rc);
		rc = tuntap_write(&tuntap, buf, rc);
		printf("tun_write returned %d\n", rc);
		if (_kbhit())
		{
			int ch = getchar();
			if (ch == 'q') break;
		}
	}
	// rc = tun_open (device->device_name, IF_MODE_TUN);
	tuntap_close(&tuntap);
	WSACleanup();
	return(0);
}
Exemple #4
0
/*
=====================
	initSystem
=====================
*/
BOOL initSystem() {

	//get game directory path (Ex: D:\Games\Netrix)
	//
	GetCurrentDirectory( MAX_PATH, k_system.szStartDir );

	N_InitTrace();

	//init Win32 system
	//
	initWin32();

	//System
	//
	k_system.pLeftGame	= NULL;
	k_system.pRightGame	= NULL;
	k_system.gameType	= GNO;
	k_system.pause		= FALSE;
	k_system.flags		= 0;
	k_system.dwAccumTime	= 0;
	k_system.dwTime		= 0;
	
	//Maps
	//
	k_system.cMaps	= 0;
	k_system.pMaps	= NULL;
	k_system.idMap	= -1;
	
	//Bots
	//
	k_system.cBots	= 0;
	k_system.pBots	= NULL;
	k_system.idBotLeft	= -1;
	k_system.idBotRight	= -1;
	
	//Paths
	//
	k_system.pPaths	= NULL;
	k_system.cPaths	= 0;
	
	//HWND
	//
	k_system.hwnd		= NULL;
	k_system.hwndLeft	= NULL;
	k_system.hwndRight	= NULL;
	
	k_system.cPlayers	= 0;

	initRandom();

	cfInitTable();

	//resources
	//
	loadResources();
	
	//init bot system
	//
	botInit();

	//Skins
	//
	loadSkin( &k_system.hSkinRgnLeft, &k_system.hSkinBitmapLeft,
		&k_system.cxSkinLeft, &k_system.cySkinLeft, IDR_SKIN_LEFT );

	loadSkin( &k_system.hSkinRgnRight, &k_system.hSkinBitmapRight,
		&k_system.cxSkinRight, &k_system.cySkinRight, IDR_SKIN_RIGHT );

	createWindow();
	
	//GUI
	//
	populateGUI();

	if( !initGraphics( NEUTRAL ) )
		return FALSE;

	if( !initGraphics( LEFTGAME ) )
		return FALSE;

	updateWindow( CGF_DRAWLEFT );
	
	//winmm
	timeBeginPeriod( 1 );
	
	return TRUE;
}