예제 #1
0
파일: ftp.c 프로젝트: jadfeitrouni/FTPVita
void ftp_fini()
{
	if (ftp_initialized) {
		/* In order to "stop" the blocking sceNetAccept,
		 * we have to close the server socket; this way
		 * the accept call will return an error */
		sceNetSocketClose(server_sockfd);

		/* Wait until the server threads ends */
		sceKernelWaitThreadEnd(server_thid, NULL, NULL);

		/* To close the clients we have to do the same:
		 * we have to iterate over all the clients
		 * and shutdown their sockets */
		client_list_thread_end();

		/* Delete the client list mutex */
		sceKernelDeleteMutex(client_list_mtx);

		client_list = NULL;

		sceNetCtlTerm();
		sceNetTerm();

		if (net_memory) {
			free(net_memory);
			net_memory = NULL;
		}

		ftp_initialized = 0;
	}
}
예제 #2
0
int WiFiManager::Terminate()
{
    u32 err;

    err = sceNetApctlTerm();
    if (err == 0x80410A04)
        Console::Print("sceNetApctlTerm returned common error");
    else if (err != 0)
        Console::Print("sceNetApctlTerm returns error");

    err = sceNetResolverTerm();
    if (err != 0)
        Console::Print("sceNetResolverTerm returns error");

    err = sceNetInetTerm();
    if (err != 0)
        Console::Print("sceNetInetTerm returns error");
    err = sceNetTerm();
    if (err != 0)
        Console::Print("sceNetTerm returns error");
       
	_connected = false;
	LCD::PrintMessage("WIFI Disconnected");
   return 0; // assume it worked
}
예제 #3
0
파일: adhoc.c 프로젝트: 173210/mvspsp
int adhocTerm(void)
{
	if (adhoc_initialized > 0)
	{
		char message[256];

		sprintf(message, TEXT(DISCONNECTING_FROM_x), Server ? TEXT(CLIENT) : TEXT(SERVER));
		adhoc_init_progress(5, message);

		sceNetAdhocctlDisconnect();
		update_progress();

		sceNetAdhocPdpDelete(pdpId, 0);
		update_progress();

		sceNetAdhocctlTerm();
		update_progress();

		sceNetAdhocTerm();
		update_progress();

		sceNetTerm();
		update_progress();

		show_progress(TEXT(DISCONNECTED));

		adhoc_initialized = 0;
	}

	return 0;
}
예제 #4
0
/**
 * network_deinit:
 *
 * Deinitialize platform specific socket libraries.
 **/
void network_deinit(void)
{
#if defined(_WIN32)
   WSACleanup();
#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
   cellNetCtlTerm();
   sys_net_finalize_network();
   cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
#elif defined(VITA)
   sceNetCtlTerm();
   sceNetTerm();

   if (_net_compat_net_memory)
   {
      free(_net_compat_net_memory);
      _net_compat_net_memory = NULL;
   }
#elif defined(GEKKO) && !defined(HW_DOL)
   net_deinit();
#elif defined(_3DS)
   socExit();
   
   if(_net_compat_net_memory)
   {
	  free(_net_compat_net_memory);
	  _net_compat_net_memory = NULL;
   }
#endif
}
예제 #5
0
int nlhTerm()
{
    u32 err;

//REVIEW: we need to do something first to stop the connection
//REVIEW: -- sceNetApctlTerm returns 80410A04 on V1 firmware
    err = sceNetApctlTerm();
    if (err == 0x80410A04)
        printf("sceNetApctlTerm returned common error\n");
    else if (err != 0)
        my_printn("sceNetApctlTerm returns ", err, "\n");

    err = sceNetResolverTerm();
    if (err != 0)
        my_printn("sceNetResolverTerm returns ", err, "\n");

    err = sceNetInetTerm();
    if (err != 0)
        my_printn("sceNetInetTerm returns ", err, "\n");
    err = sceNetTerm();
    if (err != 0)
        my_printn("sceNetTerm returns ", err, "\n");

    return 0; // assume it worked
}
예제 #6
0
파일: adhoc.c 프로젝트: 173210/mvspsp
static void adhocDisconnect(void)
{
	char message[256];

	sprintf(message, TEXT(DISCONNECTING_FROM_x), TEXT(LOBBY));
	adhoc_init_progress(8, message);

	sceNetAdhocMatchingStop(matchingId);
	update_progress();

	sceNetAdhocMatchingDelete(matchingId);
	update_progress();

	sceNetAdhocMatchingTerm();
	update_progress();

	sceNetAdhocctlDisconnect();
	update_progress();

	sceNetAdhocPdpDelete(pdpId, 0);
	update_progress();

	sceNetAdhocctlTerm();
	update_progress();

	sceNetAdhocTerm();
	update_progress();

	sceNetTerm();
	update_progress();

	show_progress(TEXT(DISCONNECTED));

	adhoc_initialized = 0;
}
예제 #7
0
void netTerm(void)
{
	sceNetApctlTerm();
	
	sceNetInetTerm();
	
	sceNetTerm();
}
예제 #8
0
파일: sceNet.cpp 프로젝트: Klozz/ppsspp
// TODO: should that struct actually be initialized here?
u32 sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netinitPri, u32 netinitStack)  {
	// May need to Terminate old one first since the game (ie. GTA:VCS) might not called sceNetTerm before the next sceNetInit and behave strangely
	if (netInited) sceNetTerm();

	ERROR_LOG(SCENET, "UNIMPL sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d) at %08x", poolSize, calloutPri, calloutStack, netinitPri, netinitStack, currentMIPS->pc);
	netInited = true;
	netMallocStat.maximum = poolSize;
	netMallocStat.free = poolSize;
	netMallocStat.pool = 0;

	return 0;
}
예제 #9
0
파일: main.c 프로젝트: CDragu/pspsdk
void netTerm()
{
	sceHttpSaveSystemCookie();
	sceHttpsEnd();
	sceHttpEnd();
	sceSslEnd();
	sceNetApctlTerm();
	sceNetInetTerm();
	sceNetTerm();
	
	unloadNetModules();	
}
예제 #10
0
void console_fini()
{
	if (console_initialzed) {
		sceKernelDeleteMutex(console_mtx);
		sceNetSocketClose(sock);
		sceNetTerm();
		if (net_memory) {
			free(net_memory);
			net_memory = NULL;
		}
	}
}
예제 #11
0
/**
 * Finish debugnet library 
 *
 * @par Example:
 * @code
 * debugNetFinish();
 * @endcode
 */
void debugNetFinish()
{
    if (debugnet_initialized) {
       
        sceNetCtlTerm();
        sceNetTerm();

        if (net_memory) {
            free(net_memory);
            net_memory = NULL;
        }

        debugnet_initialized = 0;
    }
}
예제 #12
0
파일: adhoc.c 프로젝트: nworkers/smsplus
int pspAdhocShutdown()
{
  if (_net_init)
  {
    if (_net_adhoc_init)
    {
      if (_net_adhoc_ctl_init)
      {
        if (_net_adhoc_ctl_connect)
        {
          if (_net_adhoc_pdp_create)
          {
            if (_net_adhoc_matching_init)
            {
              if (_net_adhoc_matching_create)
              {
                if (_net_adhoc_matching_start)
                {
                  sceNetAdhocMatchingStop(_matching_id);
                  _net_adhoc_matching_start = 0;
                }
                sceNetAdhocMatchingDelete(_matching_id);
                _net_adhoc_matching_create = 0;
              }
              sceNetAdhocMatchingTerm();
              _net_adhoc_matching_init = 0;
            }
            sceNetAdhocPdpDelete(_pdp_id, 0);
            _net_adhoc_pdp_create = 0;
          }
          sceNetAdhocctlDisconnect();
          _net_adhoc_ctl_connect = 0;
        }
        sceNetAdhocctlTerm();
        _net_adhoc_ctl_init = 0;
      }
      sceNetAdhocTerm();
      _net_adhoc_init = 0;
    }
    sceNetTerm();
    _net_init = 0;
  }

  return 1;
}
예제 #13
0
int AdhocShutdown(void)
{	
	sceNetAdhocctlDisconnect();
	
	sceNetAdhocctlDelHandler(0);
	
	sceNetAdhocctlTerm(); 
	
	sceNetAdhocTerm();
	
	sceNetTerm();
	
	sceUtilityUnloadNetModule(PSP_NET_MODULE_ADHOC);
	
	sceUtilityUnloadNetModule(PSP_NET_MODULE_COMMON);
	
	return 1;
}
예제 #14
0
파일: adhoc.c 프로젝트: 173210/mvspsp
int adhocInit(const char *matchingData)
{
	struct productStruct product;
	int error = 0, state = 0;
	unsigned char mac[6];
	const char *unknown = "";
	char message[256];

	video_set_mode(32);

	mode = MODE_LOBBY;
	Server = 0;
	adhoc_initialized = 0;

	g_unk1        = 0;
	g_matchEvent  = 0;
	g_matchOptLen = 0;
	matchChanged  = 0;
	memset(g_mac, 0, sizeof(g_mac));
	memset(g_mymac, 0, sizeof(g_mymac));

	sprintf((char *)product.product, PRODUCT "00%d%d%d", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
	product.unknown = 0;

	ClearPspList();

	if (strlen(matchingData) == 0)
		return -1;

	strcpy(g_matchingData, matchingData);

	sprintf(message, TEXT(CONNECTING_TO_x), TEXT(LOBBY));
	adhoc_init_progress(10, message);

	if ((error = sceNetInit(0x20000, 0x20, 0x1000, 0x20, 0x1000)) == 0)
	{
		update_progress();
		if ((error = sceNetAdhocInit()) == 0)
		{
			update_progress();
			if ((error = sceNetAdhocctlInit(0x2000, 0x20, &product)) == 0)
			{
				update_progress();
				if ((error = sceNetAdhocctlConnect(unknown)) == 0)
				{
					update_progress();
					do
					{
						if ((error = sceNetAdhocctlGetState(&state)) != 0) break;
						sceKernelDelayThread(1000000/60);

					} while (state != 1);

					if (!error)
					{
						update_progress();

						sceWlanGetEtherAddr(mac);
						update_progress();

						if ((pdpId = sceNetAdhocPdpCreate(mac, PDP_PORT, PDP_BUFFER_SIZE, 0)) > 0)
						{
							update_progress();
							if ((error = sceNetAdhocMatchingInit(0x20000)) == 0)
							{
								update_progress();
								if ((matchingId = sceNetAdhocMatchingCreate(MATCHING_CREATE_PARAMS)) >= 0)
								{
									update_progress();
									if ((error = sceNetAdhocMatchingStart(MATCHING_START_PARAMS)) == 0)
									{
										update_progress();
										show_progress(TEXT(CONNECTED));
										sceKernelDelayThread(1000000);
										adhoc_initialized = 1;
										return 0;
									}
									sceNetAdhocMatchingDelete(matchingId);
								}
								error = 2;
								sceNetAdhocMatchingTerm();
							}
							sceNetAdhocPdpDelete(pdpId, 0);
						}
						error = 1;
					}
					sceNetAdhocctlDisconnect();
				}
				sceNetAdhocctlTerm();
			}
			sceNetAdhocTerm();
		}
		sceNetTerm();
	}

	switch (error)
	{
	case 1:  sprintf(message, "%s (PDP ID = %08x)", TEXT(FAILED), pdpId); break;
	case 2:  sprintf(message, "%s (Matching ID = %08x)", TEXT(FAILED), matchingId); break;
	default: sprintf(message, "%s (Error Code = %08x)", TEXT(FAILED), error); break;
	}

	show_progress(message);

	pad_wait_clear();
	pad_wait_press(PAD_WAIT_INFINITY);

	return -1;
}
예제 #15
0
파일: adhoc.c 프로젝트: nworkers/smsplus
int pspAdhocConnect(const PspMAC mac)
{
  int err, state = 0;
  char temp[64];
  char ssid[10];
  sceNetEtherNtostr((unsigned char*)mac, temp);

  ssid[0] = temp[9];
  ssid[1] = temp[10];
  ssid[2] = temp[12];
  ssid[3] = temp[13];
  ssid[4] = temp[15];
  ssid[5] = temp[16];
  ssid[6] = '\0';

  if (_net_adhoc_ctl_connect)
  {
    if (_net_adhoc_pdp_create)
    {
      if (_net_adhoc_matching_init)
      {
        if (_net_adhoc_matching_create)
        {
          if (_net_adhoc_matching_start)
          {
            sceNetAdhocMatchingStop(_matching_id);
            _net_adhoc_matching_start = 0;
          }
          sceNetAdhocMatchingDelete(_matching_id);
          _net_adhoc_matching_create = 0;
        }
        sceNetAdhocMatchingTerm();
        _net_adhoc_matching_init = 0;
      }
      sceNetAdhocPdpDelete(_pdp_id, 0);
      _net_adhoc_pdp_create = 0;
    }
    sceNetAdhocctlDisconnect();
    _net_adhoc_ctl_connect = 0;
  }

  do
  {
    if ((err = sceNetAdhocctlGetState(&state)) != 0) break;
    sceKernelDelayThread(1000000/60);
  } while (state == 1);

  if ((err = sceNetAdhocctlConnect((void*)ssid)) == 0)
  {
    do
    {
      if ((err = sceNetAdhocctlGetState(&state)) != 0) break;
      sceKernelDelayThread(1000000/60);
    } while (state != 1);

    if (!err)
    {
      if ((_pdp_id = sceNetAdhocPdpCreate(_own_mac, 0x309, 0x800, 0)) > 0)
      {
        if (pspAdhocIsMACEqual(mac, _own_mac))
          sceKernelDelayThread(1000000);
        return 1;
      }
    }

    if (_net_adhoc_ctl_connect)
    {
      sceNetAdhocctlDisconnect();
      _net_adhoc_ctl_connect = 0;
    }

    if (state == 1)
    {
      do
      {
        if ((err = sceNetAdhocctlGetState(&state)) != 0) 
          break;
        sceKernelDelayThread(1000000/60);
      } while (state == 1);
    }
  }

  if (_net_init)
  {
    if (_net_adhoc_init)
    {
      if (_net_adhoc_ctl_init)
      {
        sceNetAdhocctlTerm();
        _net_adhoc_ctl_init = 0;
      }
      sceNetAdhocTerm();
      _net_adhoc_init = 0;
    }
    sceNetTerm();
    _net_init = 0;
  }

  return 0;
}
예제 #16
0
// The order that procedures are called was taken by patching
// Lumines network procs
int adhocTerm()
{
    u32 err;

	if(g_NetAdhocctlConnect)
	{
		printf2("sceNetAdhocctlDisconnect\n");
		err = sceNetAdhocctlDisconnect();
		if(err != 0)
		{
			pspDebugScreenInit();
			printf(" returned %x\n", err);
		}
		g_NetAdhocctlConnect = false;
	}

	if(g_NetAdhocPdpCreate)
	{
		printf2("sceNetAdhocPdpDelete\n");
		err = sceNetAdhocPdpDelete(pdpId,0);
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetAdhocPdpDelete returned %x\n", err);
		}
		g_NetAdhocPdpCreate = false;
	}

	if(g_NetAdhocMatchingStart)
	{
		printf2("sceNetAdhocMatchingStop\n");
		err = sceNetAdhocMatchingStop(matchingId);
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetAdhocMatchingStop returned %x\n", err);
		}
		g_NetAdhocMatchingStart = false;
	}

	if(g_NetAdhocMatchingCreate)
	{
		printf2("sceNetAdhocMatchingDelete\n");
		err = sceNetAdhocMatchingDelete(matchingId);
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetAdhocMatchingDelete returned %x\n", err);
		}
		g_NetAdhocMatchingCreate = false;
	}
	
	if(g_NetAdhocMatchingInit)
	{
		printf2("sceNetAdhocMatchingTerm\n");
		err = sceNetAdhocMatchingTerm();
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetAdhocMatchingTerm returned %x\n", err);
		}
		g_NetAdhocMatchingInit = false;
	}
	
	if(g_NetAdhocctlInit)
	{
		printf2("sceNetAdhocctlTerm\n");
		err = sceNetAdhocctlTerm();
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetAdhocctlTerm returned %x\n", err);
		}
		g_NetAdhocctlInit = false;
	}

	if(g_NetAdhocInit)
	{
		printf2("sceNetAdhocTerm\n");
		err = sceNetAdhocTerm();
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetAdhocTerm returned %x\n", err);
		}
		g_NetAdhocInit = false;
	}

	if(g_NetInit)
	{
		printf2("sceNetTerm\n");
		err = sceNetTerm();
		if(err != 0)
		{
			pspDebugScreenInit();
			printf("sceNetTerm returned %x\n", err);
		}
		g_NetInit = false;
	}

    return 0; // assume it worked
}
예제 #17
0
파일: adhoc.c 프로젝트: nworkers/smsplus
int pspAdhocInit(const char *product_name, 
                PspMatchingCallback callback)
{
  /* Shut down adhoc, if currently enabled */
  pspAdhocShutdown();

  struct productStruct product;
  char mac[20];
  int err, state = 0;

  strncpy(product.product, product_name, 9);
  product.unknown = 0;
  if (sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, 
                                     _matching_data, 128) != 0)
    return 0;

  if ((err = sceNetInit(0x20000, 0x2A, 0x1000, 0x2A, 0x1000)) == 0)
  {
    _net_init = 1;
    if ((err = sceNetAdhocInit()) == 0)
    {
      _net_adhoc_init = 1;
      if ((err = sceNetAdhocctlInit(0x2000, 0x20, &product)) == 0)
      {
        _net_adhoc_ctl_init = 1;
        if ((err = sceNetAdhocctlConnect((void*)"")) == 0)
        {
          _net_adhoc_ctl_connect = 1;
          do
          {
            if ((err = sceNetAdhocctlGetState(&state)) != 0) break;
            sceKernelDelayThread(1000000/60);
          } while (state != 1);

          /* Get WLAN MAC */
          unsigned char own_mac[8];
          sceWlanGetEtherAddr(own_mac);
          memcpy(_own_mac, own_mac, sizeof(unsigned char) * 6);

          if (err == 0)
          {
            sceWlanGetEtherAddr((unsigned char*)mac);
            if ((_pdp_id = sceNetAdhocPdpCreate((unsigned char*)mac, 0x309, 0x400, 0)) > 0)
            {
              _net_adhoc_pdp_create = 1;
              if ((err = sceNetAdhocMatchingInit(0x20000)) == 0)
              {
                _net_adhoc_matching_init = 1;
                _matching_id = sceNetAdhocMatchingCreate(3,
                                                        0xa,
                                                        0x22b,
                                                        0x800,
                                                        0x2dc6c0,
                                                        0x5b8d80,
                                                        3,
                                                        0x7a120,
                                                        callback);
                if (_matching_id >= 0)
                {
                  _net_adhoc_matching_create = 1;
                  err = sceNetAdhocMatchingStart(_matching_id,
                                                0x10,
                                                0x2000,
                                                0x10,
                                                0x2000,
                                                strlen(_matching_data) + 1,
                                                _matching_data);
                  if (err == 0)
                  {
                    _net_adhoc_matching_start = 1;
                    /* Everything checked out */
                    return 1;
                  }
                  sceNetAdhocMatchingDelete(_matching_id);
                  _net_adhoc_matching_create = 0;
                }
                sceNetAdhocMatchingTerm();
                _net_adhoc_matching_init = 0;
              }
              sceNetAdhocPdpDelete(_pdp_id, 0);
              _net_adhoc_pdp_create = 0;
            }
          }
          sceNetAdhocctlDisconnect();
          _net_adhoc_ctl_connect = 0;
        }
        sceNetAdhocctlTerm();
        _net_adhoc_ctl_init = 0;
      }
      sceNetAdhocTerm();
      _net_adhoc_init = 0;
    }
    sceNetTerm();
    _net_init = 0;
  }
  
  return 0;
}
예제 #18
0
int main_thread( SceSize args, void *argp )
{
	char ip[16], * argv[5];
	int port, entry;
	parseArgs( argv, args, ( char * )argp );
	//sceUtilityGetNetParam
	strcpy( ip, argv[1] );
	port = atoi( argv[2] );
	entry = atoi( argv[3] );
	block_size = atoi( argv[4] );
	log( "%s:%d entry %d\n", ip, port, entry );
	
	/*ctrl_opts.inited = sceUtilityLoadNetModule( PSP_NET_MODULE_COMMON );
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error loading Net modules (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}
	ctrl_opts.inited = sceUtilityLoadNetModule( PSP_NET_MODULE_INET );
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error loading iNet module (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}*/
	ctrl_opts.inited = sceNetInit( 0x10000, 0x20, 0x1000, 0x20, 0x1000 );
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error Initing pspnet (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}
	ctrl_opts.inited = sceNetInetInit();
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error initing Inet (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}
	ctrl_opts.inited = sceNetResolverInit();
	if( ctrl_opts.inited != 0 )
	{
		log( "Error initing Resolver (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}
	ctrl_opts.inited = sceNetApctlInit( 0x1400, 0x42 );
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error initing Apctl (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}
	log( "pspnet init OK!\n" );
	
	ctrl_opts.inited = connectApctl( entry );
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error connecting Apctl (0x%08x)\n", ctrl_opts.inited );
		goto net_term;
	}
	
	ctrl_opts.inited = connectSocket( ip, ( unsigned short )port );
	if ( ctrl_opts.inited != 0 )
	{
		log( "Error connecting Socket\n" );
		goto net_term;
	}
	ctrl_opts.inited = 1;
	
	sceKernelSleepThread();
	
net_term:
	log( "stopping wifi...\n" );
	disconnectSocket();
	disconnectApctl();
	sceNetApctlTerm();
	sceNetResolverTerm();
	sceNetInetTerm();
	sceNetTerm();
	//sceUtilityUnloadNetModule( PSP_NET_MODULE_INET );
	//sceUtilityUnloadNetModule( PSP_NET_MODULE_COMMON );
	ctrl_opts.thid = -1;
	ctrl_opts.inited = -1;
	return sceKernelExitDeleteThread( 0 );
}
예제 #19
0
파일: adhoc.c 프로젝트: 173210/mvspsp
static int adhocStartP2P(void)
{
	int error = 0, state = 1;
	unsigned char mac[6];
	char message[256];

	sprintf(message, TEXT(DISCONNECTING_FROM_x), TEXT(LOBBY));
	adhoc_init_progress(6, message);

	sceNetAdhocMatchingStop(matchingId);
	update_progress();

	sceNetAdhocMatchingDelete(matchingId);
	update_progress();

	sceNetAdhocMatchingTerm();
	update_progress();

	sceNetAdhocPdpDelete(pdpId, 0);
	update_progress();

	sceNetAdhocctlDisconnect();
	update_progress();

	do
	{
		if ((error = sceNetAdhocctlGetState(&state)) != 0) break;
			sceKernelDelayThread(1000000/60);
	} while (state == 1);

	update_progress();
	show_progress(TEXT(DISCONNECTED));


	mode = MODE_P2P;
	sprintf(message, TEXT(CONNECTING_TO_x), Server ? TEXT(CLIENT) : TEXT(SERVER));
	adhoc_init_progress(4, message);

	if ((error = sceNetAdhocctlConnect((int *)g_ssid)) == 0)
	{
		update_progress();
		do
		{
			if ((error = sceNetAdhocctlGetState(&state)) != 0) break;
			sceKernelDelayThread(1000000/60);
		} while (state != 1);

		if (!error)
		{
			update_progress();

			sceWlanGetEtherAddr(mac);
			memcpy(g_mymac, mac, 6);
			update_progress();

			if ((pdpId = sceNetAdhocPdpCreate(mac, PDP_PORT, PDP_BUFFER_SIZE, 0)) > 0)
			{
				update_progress();
				adhoc_initialized = 2;

				show_progress(TEXT(WAITING_FOR_SYNCHRONIZATION));
				if ((error = adhocSync()) == 0)
					return Server;
			}
			else
			{
				error = 1;
			}
		}
		sceNetAdhocctlDisconnect();

		if (state == 1)
		{
			do
			{
				if ((error = sceNetAdhocctlGetState(&state)) != 0) break;
				sceKernelDelayThread(1000000/60);
			} while (state == 1);
		}
	}

	sceNetAdhocctlTerm();
	sceNetAdhocTerm();
	sceNetTerm();

	adhoc_initialized = 0;

	switch (error)
	{
	case 1:  sprintf(message, "%s (PDP ID = %08x)", TEXT(FAILED), pdpId); break;
	default: sprintf(message, "%s (Error Code = %08x)", TEXT(FAILED), error); break;
	}

	show_progress(message);

	pad_wait_clear();
	pad_wait_press(PAD_WAIT_INFINITY);

	return -1;
}