コード例 #1
0
ファイル: sockets.cpp プロジェクト: AmberSandDan/htmapp
CIpAddress::t_string CIpAddress::GetFullHostName()
{
	t_string sDomain = GetDomainName();
	if ( sDomain.length() )
		return disk::FilePath( sDomain, GetHostName() );
	return GetHostName();
}
コード例 #2
0
ファイル: Hooking.cpp プロジェクト: devyyj/Mini-DLP
int WINAPI WSASendCallback(
  _In_  SOCKET                             s,
  _In_  LPWSABUF                           lpBuffers,
  _In_  DWORD                              dwBufferCount,
  _Out_ LPDWORD                            lpNumberOfBytesSent,
  _In_  DWORD                              dwFlags,
  _In_  LPWSAOVERLAPPED                    lpOverlapped,
  _In_  LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
)
{
	/// 웹 사이트 접속 차단
	if(TRUE == pRule->IsBlockAccessWebSite())
	{
		CString strHost = GetHostName(lpBuffers->buf, lpBuffers->len);
		if(TRUE == SearchStringFromFile(BLOCK_ACCESS_SITE_URL_TXT, strHost))
		{
			_TRACE(L"Block Site : %s", strHost);
			s = 0;
		}
	}

	/// 메일 본문을 남긴다.
	if(TRUE == pRule->IsLoggingMail() && pRule->IsLoggingContents())
		MakeLogContents(lpBuffers->buf, lpBuffers->len);

	return WSASendNext(
		s,
		lpBuffers,
		dwBufferCount,
		lpNumberOfBytesSent,
		dwFlags,
		lpOverlapped,
		lpCompletionRoutine
		);
}
コード例 #3
0
ファイル: System.cpp プロジェクト: starand/cpp
sizeint GetIpAddrList(string_v& vsOutIpAddrList)
{
	START_FUNCTION();
	string_v vsIpAddrList;

	string sHostName;
	if (!GetHostName(sHostName)) {
		break;
	}

	struct hostent *pheHostEntry = gethostbyname(sHostName.c_str());
	if (!pheHostEntry) {
		break;
	}

	struct in_addr addr;
	for (int idx = 0; pheHostEntry->h_addr_list[idx] != 0; ++idx) 
	{
		memcpy(&addr, pheHostEntry->h_addr_list[idx], sizeof(struct in_addr));
		vsIpAddrList.push_back(inet_ntoa(addr));
	}

	vsOutIpAddrList.swap(vsIpAddrList);
	END_FUNCTION_RET(vsOutIpAddrList.size());
}
コード例 #4
0
ファイル: ccNetworkManager.cpp プロジェクト: xho95/Luna
bool ccNetworkManager::GetLocalIP(std::string& strIP)
{
    std::string strHostName;

    if (GetHostName(strHostName) == false)
        return false;

    struct hostent *host = ::gethostbyname((char*)strHostName.c_str());

    if (host == NULL)
        return false;

    //  Obtain the computer's IP
#if defined(WIN32)
    ccString::format(strIP, 
        "%d.%d.%d.%d",
        ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b1,
        ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b2,
        ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b3,
        ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b4);
#else
    strIP = inet_ntoa(*(struct in_addr *)*host->h_addr_list);
#endif

    return true;
}
コード例 #5
0
ファイル: mysocket.cpp プロジェクト: sproutman/personal_Works
int MySocket::GetDomainName(char *sbuf)
// Pass back the domain name of this machine in the "sbuf" variable.
// A memory buffer equal to "MysMAX_NAME_LEN" must be pre-allocated
// prior to using this function. Return -1 if an error occurs.
{
  char hostname[MysMAX_NAME_LEN];
  int rv = GetHostName(hostname);
  if(rv < 0) return rv;

  hostent *hostinfo = GetHostInformation(hostname);
  if(!hostinfo) {
    socket_error = MySOCKET_HOSTNAME_ERROR;
    return -1;
  }
  // Prevent crashes if memory has not been allocated
  if(!sbuf) sbuf = new char[MysMAX_NAME_LEN]; 

  strcpy(sbuf, hostinfo->h_name);
  int i; int len = strlen(sbuf);
  for(i = 0; i < len; i++) {
    if(sbuf[i] == '.') break;
  }
  if(++i < len) {
    len -= i;
    memmove(sbuf, sbuf+i, len);
    sbuf[len] = 0; // Null terminate the string
  }
  delete hostinfo;
  return 0;
}
コード例 #6
0
ファイル: Util.cpp プロジェクト: awfover/Gobang
void GetComputerIPList(vector<LPCTSTR> &list)
{
	char *hostname = GetHostName();
	if (!hostname)
	{
		return;
	}

	HOSTENT *lpHost = gethostbyname(hostname);
	if (lpHost == nullptr)
	{
		return;
	}

	int i = 0;
	in_addr addr;
	LPCTSTR address = nullptr;

	list.clear();
	while (lpHost->h_addr_list[i] != 0)
	{
		memset(&addr, 0, sizeof(addr));
		addr.s_addr = *(u_long *)lpHost->h_addr_list[i++];
		list.push_back((LPCTSTR)M2W(inet_ntoa(addr)));
	}
}
コード例 #7
0
ファイル: Sockets.cpp プロジェクト: septag/stcore
String64 Net::ResolveDNS(const char* name)
{
    char host_name[255];
    if (name == nullptr || name[0] == 0 || strcmp(name, "localhost") == 0)
        AllocInternals::StrCpy(host_name, GetHostName(), sizeof(host_name));
    else
        AllocInternals::StrCpy(host_name, name, sizeof(host_name));

    addrinfo* addr;
    if (getaddrinfo(name, nullptr, nullptr, &addr) == 0)    {
        switch (addr->ai_family) {
        case AF_INET:
        {
            String64 r;
            inet_ntop(AF_INET, (sockaddr_in*)addr->ai_addr, r.getBuffer(), sizeof(r));
            return r;
        }
        case AF_INET6:
        {
            String64 r;
            inet_ntop(AF_INET6, (sockaddr_in6*)addr->ai_addr, r.getBuffer(), sizeof(r));
            return r;
        }
        default:
            return String64("0.0.0.0");
        }
    } else {
        return String64("0.0.0.0");
    }
}
コード例 #8
0
NS_IMETHODIMP nsPop3IncomingServer::MarkMessages()
{
  nsresult rv;
  if (m_runningProtocol)
    rv = m_runningProtocol->MarkMessages(&m_uidlsToMark);
  else
  {
    nsCString hostName;
    nsCString userName;
    nsCOMPtr<nsIFile> localPath;

    GetLocalPath(getter_AddRefs(localPath));

    GetHostName(hostName);
    GetUsername(userName);
    // do it all in one fell swoop
    rv = nsPop3Protocol::MarkMsgForHost(hostName.get(), userName.get(), localPath, m_uidlsToMark);
  }
  uint32_t count = m_uidlsToMark.Length();
  for (uint32_t i = 0; i < count; i++)
  {
    Pop3UidlEntry *ue = m_uidlsToMark[i];
    PR_Free(ue->uidl);
    PR_Free(ue);
  }
  m_uidlsToMark.Clear();
  return rv;
}
コード例 #9
0
ファイル: FHClientManager.cpp プロジェクト: felixHwang/FRM
void FHClientManager::InitMachineInfo()
{
	if (NULL != m_pcConnectSocket) {
		FHMessage cMsg;
		cMsg.SetCommandID(FH_COMM_MACHINEINFO);
		cMsg.SetMachineInfo(FH_MSG_MachineInfo(GetHostName()));
		m_pcConnectSocket->SendMessage(cMsg);
	}
}
コード例 #10
0
ファイル: var.c プロジェクト: actility/ong
char *
GetReqId(void)
{
  static char val[256];

  InternalVar = 1;
  sprintf (val, "coap://%s:%s%s/%s", GetHostName(), GetCoapPortR(), SCL_ROOT_APP, GetDriverId());
  InternalVar = 0;
  return val;
}
コード例 #11
0
ファイル: RPN_COMM_sock.c プロジェクト: guziy/rmnlib
/* obtain own host's IPV4 address 
*/
static int get_own_ip_address()  /*   %ENTRY%   */
{
     char buf[1024];
     if(GetHostName(buf,sizeof buf)){
       fprintf(stderr,"Can't find hostname\n");
       return(-1);
       }
     return get_ip_address(buf);

}
コード例 #12
0
ファイル: Hooking.cpp プロジェクト: devyyj/Mini-DLP
///
///	@brief 패킷을 분석하여 메일 내용을 가져온다.
///
void MakeLogContents(const char * buf, int len)
{
	CString strBuf = (CString)buf;
	static CString strFileName;
	CStdioFile file;

	/// 서버로 보내는 패킷이라면
	if(0 == strBuf.Find(L"POST"))
	{
		/// 호스트 이름으로 INI에 저장되어 있는 키 값을 얻어온다.
		CString strHost = GetHostName(buf, len);
		wchar_t szTemp[1024] = {0};
		if(0 != GetPrivateProfileString(L"CONTENTS", strHost, L"", szTemp, 1024, HOOK_WEB_INI))
		{
			/// 메일 내용을 보내는 패킷을 찾기 위해서
			/// 호스트 이름에 해당되는 키 값과 POST 이후에 오는 문자열이 같은 지 확인한다.
			if(5 == strBuf.Find(szTemp))
			{
				/// 메일 내용을 보내는 패킷이라면 html 파일을 생성한다.
				_TRACE(L"Mail Contents!");
				strFileName = (CString)LOG_WEB_CONTENTS + L"\\" + MakeLogFileName(L"PostPacket.html");
				if(FALSE == file.Open(strFileName, CFile::modeCreate | CFile::modeWrite))
				{
					//_TRACE(L"Post Packet file open fail! Error Code : %d", GetLastError());
				}
				else
					file.Close();
			}
		}
	}
	else if(0 == strBuf.Find(L"GET"))
	{
		/// GET 패킷은 제어하지 않는다.
		strFileName = L"";
	}
	else
	{
		/// 메일 내용을 보내는 POST 패킷 이후에 이어서 오는 패킷을 저장한다.
		if(FALSE == file.Open(strFileName, CFile::modeWrite))
		{
			//_TRACE(L"None Packet file open fail! Error Code : %d", GetLastError());
		}
		else
		{
			/// 패킷에서 주로 쓰이는 구분자 '&'를 html 문법에서 줄바꿈에 해당하는 <br>문자로 바꾼다.
			strBuf.Replace(L"&", L"<br>");
			/// URL 인코딩된 패킷을 디코딩한다.
			CString strDecode = Unicode_URLDecode(strBuf);
			/// UTF-8 형식으로 패킷 내용을 html 파일에 저장한다.
			WriteFileUTF8(file, strDecode);
			file.Close();
		}
	}
}
コード例 #13
0
  int LaunchClient()
  {
    std::string sockname;
    std::ostringstream tmp;
    const char *port = strstr(CTX::instance()->solver.socketName.c_str(), ":");
    if(!port){
      // Unix socket
      tmp << CTX::instance()->homeDir << CTX::instance()->solver.socketName
          << _client->getId();
      sockname = FixWindowsPath(tmp.str());
    }
    else{
      // TCP/IP socket
      if(CTX::instance()->solver.socketName.size() &&
         CTX::instance()->solver.socketName[0] == ':')
        tmp << GetHostName(); // prepend hostname if only the port number is given
      tmp << CTX::instance()->solver.socketName;
      if(atoi(port + 1)) // nonzero port is given - append client id
        tmp << _client->getId();
      sockname = tmp.str();
    }

    std::string exe = FixWindowsPath(_client->getExecutable());
    std::string args;
    if(exe.size()){
      if(_client->treatExecutableAsFullCommandLine()){
        args = exe;
        exe = "";
      }
      else{
        std::vector<std::string> cl = onelabUtils::getCommandLine(_client);
        for(unsigned int i = 0; i < cl.size(); i++)
          args.append(" " + cl[i]);
      }
      args.append(" " + _client->getSocketSwitch() +
                  " \"" + _client->getName() + "\" %s");
    }
    else{
      Msg::Info("Listening on socket '%s'", sockname.c_str());
    }

    int sock;
    try{
      sock = Start(exe, args, sockname, CTX::instance()->solver.timeout);
    }
    catch(const char *err){
      Msg::Error("Abnormal server termination (%s on socket %s)", err,
                 sockname.c_str());
      sock = -1;
    }

    return sock;
  }
コード例 #14
0
unsigned int uGetLocalIP()
{
    char szHostName[WFA_BUFF_256];
    struct hostent*	HostData;

    GetHostName(szHostName, WFA_BUFF_256);
    HostData = gethostbyname(szHostName);
    if (HostData == NULL)
        return 0;

    return *((unsigned int*)HostData->h_addr);
}
コード例 #15
0
ファイル: CLog.cpp プロジェクト: happy0123/log
    // 初始化日志
    void CLog::InitLog(const char* argv0, const char* dir)
    {
        // 获取不含路径和后缀名的程序名
        const char* slash = strrchr(argv0, '/');
#ifdef _WIN32
        if (!slash)  slash = strrchr(argv0, '\\');
#endif
        slash = slash ? slash + 1 : argv0;
        char buf[1024] = { 0 };
        char* p = strrchr((char*)slash, '.');
        if( p )
            strncpy(buf, slash, (p-slash));
        else
            strcpy(buf, slash);

        // 初始化Google glog
        InitGoogleLogging(buf);

        // 设置日志路径
        SetLogDir(dir);

        // 日志文件只写一个,所以取消Info以外的文件
        SetLogDestination(FATAL,  "");
        SetLogDestination(ERROR,  "");
        SetLogDestination(WARN,   "");

        // 完整的日志文件名称:  <short program name>.<hostname>.log.<date>-<time>.<pid>
        // 拼接日志文件名的前部:<short program name>.<hostname>.log.        
        string hostname;
        GetHostName(&hostname);
        *(buf+strlen(buf)) = '.';
        strcpy(buf+strlen(buf), hostname.c_str());
        strcpy(buf+strlen(buf), ".log.");

        // 设置INFO级别的日志文件前缀
        if( 0 != strcmp(dir, "./"))
        {
            string tmp = dir;
            tmp += buf;
            SetLogDestination(INFO, tmp.c_str());
        }
        else
            SetLogDestination(INFO, buf);
        
        // 默认情况下WARN级别的日志会屏幕输出
        SetStderrThreshold(WARN);

        // 日志是否写屏幕( Debug写,Release不写 )
        //SetAlsoLogToStderr(m_bIsDebug);
        SetLogToStderr(false);
        SetAlsoLogToStderr(false);
    }
コード例 #16
0
void DwMsgId::CreateDefault()
{
    char hostname[80];
    hostname[0] = 0;
    GetHostName(hostname, 80);
    hostname[79] = 0;
    char scratch[80];
    time_t tt = time(NULL);
    struct tm tms = *localtime(&tt);
    int pos = 0;
    scratch[pos++] = '<';
    int n = tms.tm_year;
    scratch[pos++] = char(n / 10   % 10 + '0');
    scratch[pos++] = char(n        % 10 + '0');
    n = tms.tm_mon + 1;
    scratch[pos++] = char(n / 10 % 10 + '0');
    scratch[pos++] = char(n      % 10 + '0');
    n = tms.tm_mday;
    scratch[pos++] = char(n / 10 % 10 + '0');
    scratch[pos++] = char(n      % 10 + '0');
    n = tms.tm_hour;
    scratch[pos++] = char(n / 10 % 10 + '0');
    scratch[pos++] = char(n      % 10 + '0');
    n = tms.tm_min;
    scratch[pos++] = char(n / 10 % 10 + '0');
    scratch[pos++] = char(n      % 10 + '0');
    n = tms.tm_sec;
    scratch[pos++] = char(n / 10 % 10 + '0');
    scratch[pos++] = char(n      % 10 + '0');
    static int counter = 0;
    scratch[pos++] = base35chars[counter / 35 % 35];
    scratch[pos++] = base35chars[counter   % 35];
    ++counter;
    scratch[pos++] = '.';
    DwUint32 pid = GetPid();
    scratch[pos++] = char(pid / 10000 % 10 + '0');
    scratch[pos++] = char(pid / 1000  % 10 + '0');
    scratch[pos++] = char(pid / 100   % 10 + '0');
    scratch[pos++] = char(pid / 10    % 10 + '0');
    scratch[pos++] = char(pid         % 10 + '0');
    scratch[pos++] = '@';
    char *cp = hostname;
    while(*cp && pos < 79)
    {
        scratch[pos++] = *cp++;
    }
    scratch[pos++] = '>';
    scratch[pos] = 0;
    mString = scratch;
    mIsModified = 0;
    Parse();
}
コード例 #17
0
        static std::wstring GetNewFilePath(const std::wstring& dir, time_t time)
        {
            std::wostringstream filename;
            if (!dir.empty())
            {
                // Windows can tolerate forward slashes in paths.
                filename << dir << L"/";
            }

            filename << L"events.out.tfevents." 
                << std::setfill(L'0') << std::setw(10) << time
                << L"." << ToWString(GetHostName());
            return filename.str();
        }
コード例 #18
0
ファイル: shell.c プロジェクト: lenomirei/LinuxCode
int main()
{
  while(1)
  {
    char *my_argv[64];
      struct passwd *pwd=getpwuid(getuid());
      char hostname[256]={'\0'};
      char cwd[256]={'\0'};
      getcwd(cwd,256);
      GetHostName(hostname,256);
      printf("[%s@%s %s]#",pwd->pw_name,hostname,basename(cwd));
      fflush(stdout);
      char buf[1024];
      buf[0]='\0';

      int count=read(0,buf,sizeof(buf));
      buf[count-1]='\0';
      my_argv[0]=buf;    
    pid_t id=fork();
    if(id==0)
    {
      //child
     
      if(strncmp(buf,"cd",2)==0) 
      {
        exit(1);
      }
      BuildCommand(my_argv,buf);
     execvp(my_argv[0],my_argv);
     printf("if the process has some problem ,I should run here\n");
     exit(0);
    }
    else
    {
      //father
      int status=0;
      wait(&status);
      if(status==256)
      {
        my_argv[0]+=3;
        chdir(my_argv[0]);
      }
    }
  }
  return 0;
}
コード例 #19
0
ファイル: server.c プロジェクト: xhbang/network-exercise
int main(int argc, char *argv[])
{
  int sctcp;
  char hostname[80] = "";
  struct sockaddr_in SC_link = { 0 };
  int server_port=8000;
  int childPid=0;
  static LList userlist;
  InitList(&userlist);
  pthread_t id;
  int ret;

  printf("Server is starting\n");
  sctcp=tcpSocket();	//client-server comunicate with tcp
  Setsockopt(sctcp);		//set SO_REUSEADDR,SO_LINGER opt
  GetHostName(hostname, sizeof(hostname));
  CreateSockAddr(hostname,&SC_link,server_port);
  Bind(sctcp, (struct sockaddr *) &SC_link,sizeof(SC_link));
  Listen(sctcp);
  printf("Server started successfully and it is ready now\n");
  printf("Now entered listening mode\n");
  for (;;)
  {
    struct sockaddr_in client_sockaddr = { 0 };
    int cli_socket, cli_sock2,clientLength = sizeof(client_sockaddr);
    (void) memset(&client_sockaddr, 0, sizeof(client_sockaddr));
    cli_socket = Accept(sctcp,(struct sockaddr *) &client_sockaddr, &clientLength);
    if (-1 == cli_socket)
    {
      perror("accept()");
    }
    threadargs newargs;
    newargs.sock=cli_socket;
    newargs.list=&userlist;
    //      accept_cli(&newargs);
    ret=pthread_create(&id,NULL,(void *)accept_cli,&newargs);
    if(ret!=0)
      perror("thread create error");
  }


  return EXIT_SUCCESS;
}
コード例 #20
0
ファイル: processcommander.cpp プロジェクト: pkgw/aoflagger
void ProcessCommander::Run(bool finishConnections)
{
	_errors.clear();
	_finishConnections = finishConnections;
	
	if(!_observation.GetItems().empty() && !_tasks.empty())
	{
		const std::string thisHostName = GetHostName();
		
		// make a list of the involved nodes
		_nodeCommands.Initialize(_observation);
		
		// recycle idle connections
		ConnectionVector list = _idleConnections;
		_idleConnections.clear();
		for(ConnectionVector::iterator i=list.begin();i!=list.end();++i)
		{
			onConnectionAwaitingCommand(*i);
		}
		
		if(_processes.empty())
		{
			//construct a process for each unique node name
			std::vector<std::string> list;
			_nodeCommands.NodeList(list);
			for(std::vector<std::string>::const_iterator i=list.begin();i!=list.end();++i)
			{
				RemoteProcess *process = new RemoteProcess(*i, thisHostName);
				process->SignalFinished() = boost::bind(&ProcessCommander::onProcessFinished, this, _1, _2, _3);
				process->Start();
				_processes.push_back(process);
			}
		}
		
		// We will now start accepting connections. The Run() method will not return until the server
		// stops listening and there are no more io operations pending. With asynchroneous
		// handles, the server and its connections will call onEvent...(). These handles
		// will push new tasks until all tasks in the ProcessCommander are finished.
		_server.Run();
	}
}
コード例 #21
0
ファイル: mysocket.cpp プロジェクト: sproutman/personal_Works
int MySocket::GetIPAddress(char *sbuf)
// Pass back the IP Address of this machine in the "sbuf" variable.
// A memory buffer equal to "MysMAX_NAME_LEN" must be pre-allocated
// prior to using this function. Return -1 if an error occurs.
{
  char hostname[MysMAX_NAME_LEN];
  int rv = GetHostName(hostname);
  if(rv < 0) return rv;

  in_addr *ialist;
  hostent *hostinfo = GetHostInformation(hostname);
  if(!hostinfo) {
    socket_error = MySOCKET_HOSTNAME_ERROR;
    return -1;
  }
  ialist = (in_addr *)hostinfo->h_addr_list[0];

  // Prevent crashes if memory has not been allocated
  if(!sbuf) sbuf = new char[MysMAX_NAME_LEN]; 

  strcpy(sbuf, inet_ntoa(*ialist));
  delete hostinfo;
  return 0;
}
コード例 #22
0
ファイル: System.cpp プロジェクト: starand/cpp
bool GetFirstIpAddr(string& sOutIpAddr)
{
	START_FUNCTION_BOOL();

	string sHostName;
	if (!GetHostName(sHostName)) {
		break;
	}

	struct hostent *pheHostEntry = gethostbyname(sHostName.c_str());
	if (!pheHostEntry) {
		break;
	}

	if (pheHostEntry->h_addr_list[0] == 0) {
		break;
	}

	struct in_addr iaAddress;
	memcpy(&iaAddress, pheHostEntry->h_addr_list[0], sizeof(struct in_addr));
	sOutIpAddr = inet_ntoa(iaAddress);

	END_FUNCTION_BOOL();
}
コード例 #23
0
ファイル: Hooking.cpp プロジェクト: devyyj/Mini-DLP
int WINAPI sendCallback(
  _In_       SOCKET s,
  _In_ const char   *buf,
  _In_       int    len,
  _In_       int    flags
)
{
	/// 웹 사이트 접속 차단
	if(TRUE == pRule->IsBlockAccessWebSite())
	{
		CString strHost = GetHostName(buf, len);
		if(TRUE == SearchStringFromFile(BLOCK_ACCESS_SITE_URL_TXT, strHost))
		{
			_TRACE(L"Block Site : %s", strHost);
			s = 0;
		}
	}

	/// 메일 본문을 남긴다.
	if(TRUE == pRule->IsLoggingMail() && pRule->IsLoggingContents())
		MakeLogContents(buf, len);

	return sendNext(s, buf, len, flags);
}
コード例 #24
0
// IPC connection processing thread
void EtherIPIpcConnectThread(THREAD *t, void *p)
{
	ETHERIP_SERVER *s;
	IPC *ipc = NULL;
	UINT error_code = 0;
	char tmp[MAX_SIZE];
	ETHERIP_ID id;
	// Validate arguments
	if (t == NULL || p == NULL)
	{
		return;
	}

	s = (ETHERIP_SERVER *)p;

	GetHostName(tmp, sizeof(tmp), &s->ClientIP);

	// Get the setting of the virtual HUB to be connected based on the client ID presented
	if (SearchEtherIPId(s->Ike->IPsec, &id, s->ClientId) == false &&
		SearchEtherIPId(s->Ike->IPsec, &id, "*") == false)
	{
		// Failed to get the settings for the virtual HUB
		Debug("Not Found: EtherIP Settings for Client ID \"%s\".\n", s->ClientId);

		EtherIPLog(s, "LE_NO_SETTING", s->ClientId);
	}
	else
	{
		UINT mss = CalcEtherIPTcpMss(s);
		char client_name[MAX_SIZE];

		if (s->L2TPv3 == false)
		{
			StrCpy(client_name, sizeof(client_name), ETHERIP_CLIENT_NAME);
		}
		else
		{
			if (IsEmptyStr(s->VendorName))
			{
				StrCpy(client_name, sizeof(client_name), ETHERIP_L2TPV3_CLIENT_NAME);
			}
			else
			{
				Format(client_name, sizeof(client_name), ETHERIP_L2TPV3_CLIENT_NAME_EX, s->VendorName);
			}
		}

		// Execution of IPC connection process
		EtherIPLog(s, "LE_START_IPC", id.HubName, id.UserName, mss);
		ipc = NewIPC(s->Cedar, client_name,
			(s->L2TPv3 ? ETHERIP_L2TPV3_POSTFIX : ETHERIP_POSTFIX),
			id.HubName, id.UserName, id.Password,
			&error_code,
			&s->ClientIP, s->ClientPort,
			&s->ServerIP, s->ServerPort,
			tmp,
			s->CryptName, true, mss);

		if (ipc != NULL)
		{
			Copy(&s->CurrentEtherIPIdSetting, &id, sizeof(ETHERIP_ID));
			EtherIPLog(s, "LE_IPC_CONNECT_OK", id.HubName);
		}
		else
		{
			EtherIPLog(s, "LE_IPC_CONNECT_ERROR", id.HubName, error_code, _E(error_code));
		}
	}

	Lock(s->Lock);
	{
		// Set the results
		ReleaseThread(s->IpcConnectThread);
		s->IpcConnectThread = NULL;

		s->Ipc = ipc;

		s->LastConnectFailedTick = Tick64();
	}
	Unlock(s->Lock);

	// Hit the event to cause interrupt
	SetSockEvent(s->SockEvent);

	// Release the EtherIP object that is hold by this thread
	ReleaseEtherIPServer(s);
}
コード例 #25
0
ファイル: espcfg.cpp プロジェクト: Josh-Googler/HPCC-Platform
CEspConfig::CEspConfig(IProperties* inputs, IPropertyTree* envpt, IPropertyTree* procpt, bool isDali)
{
    hsami_=0;
    serverstatus=NULL;
    useDali=false;
    
    if(inputs)
        m_inputs.setown(inputs);

    if(!envpt || !procpt)
        return;

    m_envpt.setown(envpt);
    m_cfg.setown(procpt);

    loadBuiltIns();   
   
    // load options
    const char* level = m_cfg->queryProp("@logLevel");
    m_options.logLevel = level ? atoi(level) : LogMin;
    m_options.logReq = m_cfg->getPropBool("@logRequests", true);
    m_options.logResp = m_cfg->getPropBool("@logResponses", false);
    m_options.frameTitle.set(m_cfg->queryProp("@name"));
    m_options.slowProcessingTime = m_cfg->getPropInt("@slowProcessingTime", 30) * 1000; //in msec

    if (!m_cfg->getProp("@name", m_process))
    {
        ERRLOG("EspProcess name not found");
    }
    else
    {
        DBGLOG("ESP process name [%s]", m_process.str());

        IPropertyTreeIterator *pt_iter = NULL;
        StringBuffer daliservers;
        if (m_cfg->getProp("@daliServers", daliservers))
            initDali(daliservers.str());

#ifndef _DEBUG
        startPerformanceMonitor(m_cfg->getPropInt("@perfReportDelay", 60)*1000);
#endif

        //get the local computer name:              
        m_cfg->getProp("@computer", m_computer);

        //get the local computer information:               
        StringBuffer xpath;
        xpath.appendf("Hardware/Computer[@name=\"%s\"]", m_computer.str());

        IPropertyTree *computer = m_envpt->queryPropTree(xpath.str());
        if (computer)
        {
            StringBuffer address;
            computer->getProp("@netAddress", address);

            int port = m_cfg->getPropInt("@port", 1500);
            if(strcmp(address.str(), ".") == 0)
            {
                GetHostName(address.clear());
            }
            m_address.set(address.str(), (unsigned short) port);
        }
      
        xpath.clear();
        xpath.append("EspService");
 
        pt_iter = m_cfg->getElements(xpath.str());

        if (pt_iter!=NULL)
        {
            IPropertyTree *ptree = NULL;

            pt_iter->first();

            while(pt_iter->isValid())
            {
                ptree = &pt_iter->query();
                if (ptree)
                {
                    srv_cfg *svcfg = new srv_cfg;

                    ptree->getProp("@name", svcfg->name);
                    ptree->getProp("@type", svcfg->type);
                    ptree->getProp("@plugin", svcfg->plugin);
                    fixPlugin(svcfg->plugin);

                    map<string, srv_cfg*>::value_type en(svcfg->name.str(), svcfg);
                    m_services.insert(en);
                }               
                pt_iter->next();
            }
    
            pt_iter->Release();
            pt_iter=NULL;
        }

        xpath.clear();
        xpath.append("EspProtocol");
 
        pt_iter = m_cfg->getElements(xpath.str());

        if (pt_iter!=NULL)
        {
            IPropertyTree *ptree = NULL;

            pt_iter->first();
    

            while(pt_iter->isValid())
            {
                ptree = &pt_iter->query();
                if (ptree)
                {
                    protocol_cfg *pcfg = new protocol_cfg;

                    ptree->getProp("@name", pcfg->name);
                    ptree->getProp("@plugin", pcfg->plugin);
                    fixPlugin(pcfg->plugin);
                    ptree->getProp("@type", pcfg->type);

                    map<string, protocol_cfg*>::value_type en(pcfg->name.str(), pcfg);
                    m_protocols.insert(en);
                }               

                pt_iter->next();
            }
    
            pt_iter->Release();
            pt_iter=NULL;
        }

        xpath.clear();
        xpath.append("EspBinding");
 
        pt_iter = m_cfg->getElements(xpath.str());

        if (pt_iter!=NULL)
        {
            IPropertyTree *ptree = NULL;

            pt_iter->first();
    

            while(pt_iter->isValid())
            {
                ptree = &pt_iter->query();
                if (ptree)
                {
                    binding_cfg *bcfg = new binding_cfg;
                    
                    ptree->getProp("@name", bcfg->name);
                    ptree->getProp("@type", bcfg->type);
                    ptree->getProp("@plugin", bcfg->plugin);
                    fixPlugin(bcfg->plugin);
                    bcfg->isDefault = ptree->getPropBool("@defaultBinding", false);
                    
                    StringBuffer addr;
                    ptree->getProp("@netAddress", addr);
                    if(strcmp(addr.str(), ".") == 0)
                    {
                        bcfg->address.append("0.0.0.0");
                    }
                    else
                    {
                        bcfg->address.append(addr.str());
                    }
                    
                    StringBuffer portstr;
                    ptree->getProp("@port", portstr);
                    bcfg->port = atoi(portstr.str());
                    ptree->getProp("@service", bcfg->service_name);
                    ptree->getProp("@protocol", bcfg->protocol_name);
                    
                    m_bindings.push_back(bcfg);
                }
                
                pt_iter->next();
            }
    
            pt_iter->Release();
            pt_iter=NULL;
        }
    }
}
コード例 #26
0
ファイル: process.cpp プロジェクト: jam2w0i1n2/hiphop-php
void Process::InitProcessStatics() {
  HostName = GetHostName();
  CurrentWorkingDirectory = GetCurrentDirectory();
}
コード例 #27
0
ファイル: config.c プロジェクト: flensrocker/vdr
cSetup::cSetup(void)
{
  strcpy(OSDLanguage, ""); // default is taken from environment
  strcpy(OSDSkin, "lcars");
  strcpy(OSDTheme, "default");
  PrimaryDVB = 1;
  ShowInfoOnChSwitch = 1;
  TimeoutRequChInfo = 1;
  MenuScrollPage = 1;
  MenuScrollWrap = 0;
  MenuKeyCloses = 0;
  MarkInstantRecord = 1;
  strcpy(NameInstantRecord, TIMERMACRO_TITLE " " TIMERMACRO_EPISODE);
  InstantRecordTime = DEFINSTRECTIME;
  LnbSLOF    = 11700;
  LnbFrequLo =  9750;
  LnbFrequHi = 10600;
  DiSEqC = 0;
  UsePositioner = 0;
  SiteLat = 0;
  SiteLon = 0;
  PositionerSpeed = 15;
  PositionerSwing = 650;
  PositionerLastLon = 0;
  SetSystemTime = 0;
  TimeSource = 0;
  TimeTransponder = 0;
  StandardCompliance = STANDARD_DVB;
  MarginStart = 2;
  MarginStop = 10;
  AudioLanguages[0] = -1;
  DisplaySubtitles = 0;
  SubtitleLanguages[0] = -1;
  SubtitleOffset = 0;
  SubtitleFgTransparency = 0;
  SubtitleBgTransparency = 0;
  EPGLanguages[0] = -1;
  EPGScanTimeout = 5;
  EPGBugfixLevel = 3;
  EPGLinger = 0;
  SVDRPTimeout = 300;
  SVDRPPeering = 0;
  strn0cpy(SVDRPHostName, GetHostName(), sizeof(SVDRPHostName));
  strcpy(SVDRPDefaultHost, "");
  ZapTimeout = 3;
  ChannelEntryTimeout = 1000;
  RcRepeatDelay = 300;
  RcRepeatDelta = 100;
  DefaultPriority = 50;
  DefaultLifetime = MAXLIFETIME;
  RecordKeyHandling = 2;
  PauseKeyHandling = 2;
  PausePriority = 10;
  PauseLifetime = 1;
  UseSubtitle = 1;
  UseVps = 0;
  VpsMargin = 120;
  RecordingDirs = 1;
  FoldersInTimerMenu = 1;
  AlwaysSortFoldersFirst = 1;
  DefaultSortModeRec = rsmTime;
  NumberKeysForChars = 1;
  ColorKey0 = 0;
  ColorKey1 = 1;
  ColorKey2 = 2;
  ColorKey3 = 3;
  VideoDisplayFormat = 1;
  VideoFormat = 0;
  UpdateChannels = 5;
  UseDolbyDigital = 1;
  ChannelInfoPos = 0;
  ChannelInfoTime = 5;
  OSDLeftP = 0.08;
  OSDTopP = 0.08;
  OSDWidthP = 0.87;
  OSDHeightP = 0.84;
  OSDLeft = 54;
  OSDTop = 45;
  OSDWidth = 624;
  OSDHeight = 486;
  OSDAspect = 1.0;
  OSDMessageTime = 1;
  UseSmallFont = 1;
  AntiAlias = 1;
  strcpy(FontOsd, DefaultFontOsd);
  strcpy(FontSml, DefaultFontSml);
  strcpy(FontFix, DefaultFontFix);
  FontOsdSizeP = 0.031;
  FontSmlSizeP = 0.028;
  FontFixSizeP = 0.030;
  FontOsdSize = 22;
  FontSmlSize = 18;
  FontFixSize = 20;
  MaxVideoFileSize = MAXVIDEOFILESIZEDEFAULT;
  SplitEditedFiles = 0;
  DelTimeshiftRec = 0;
  MinEventTimeout = 30;
  MinUserInactivity = 300;
  NextWakeupTime = 0;
  MultiSpeedMode = 0;
  ShowReplayMode = 0;
  ShowRemainingTime = 0;
  ProgressDisplayTime = 0;
  PauseOnMarkSet = 0;
  PauseOnMarkJump = 1;
  SkipEdited = 0;
  PauseAtLastMark = 0;
  AdaptiveSkipInitial = 120;
  AdaptiveSkipTimeout = 3;
  AdaptiveSkipAlternate = 0;
  AdaptiveSkipPrevNext = 0;
  SkipSeconds = 60;
  SkipSecondsRepeat = 60;
  ResumeID = 0;
  CurrentChannel = -1;
  CurrentVolume = MAXVOLUME;
  VolumeSteps = 51;
  VolumeLinearize = 0;
  CurrentDolby = 0;
  InitialChannel = "";
  DeviceBondings = "";
  InitialVolume = -1;
  ChannelsWrap = 0;
  ShowChannelNamesWithSource = 0;
  EmergencyExit = 1;
}
コード例 #28
0
void UPnpDeviceDesc::OutputDevice( QTextStream &os,
                                   UPnpDevice *pDevice,
                                   const QString &sUserAgent )
{
    if (pDevice == NULL)
        return;

    QString sFriendlyName = QString( "%1: %2" )
                               .arg( GetHostName() )
                               .arg( pDevice->m_sFriendlyName );

    // ----------------------------------------------------------------------
    // Only override the root device
    // ----------------------------------------------------------------------

    if (pDevice == &m_rootDevice)
        sFriendlyName = UPnp::g_pConfig->GetValue( "UPnP/FriendlyName",
                                                   sFriendlyName  );

    os << "<device>\n";
    os << FormatValue( "deviceType"   , pDevice->m_sDeviceType );
    os << FormatValue( "friendlyName" , sFriendlyName          );

    // ----------------------------------------------------------------------
    // XBox 360 needs specific values in the Device Description.
    //
    // -=>TODO: This should be externalized in a more generic/extension
    //          kind of way.
    // ----------------------------------------------------------------------

    bool bIsXbox360 =
        sUserAgent.startsWith(QString("Xbox/2.0"), Qt::CaseInsensitive) ||
        sUserAgent.startsWith( QString("Mozilla/4.0"), Qt::CaseInsensitive);

    os << FormatValue( "manufacturer" , pDevice->m_sManufacturer    );
    os << FormatValue( "modelURL"     , pDevice->m_sModelURL        );

    if ( bIsXbox360 )
    {
        os << FormatValue( "modelName"    ,
                           "Windows Media Connect Compatible (MythTV)");
    }
    else
    {
        os << FormatValue( "modelName"    , pDevice->m_sModelName       );
    }

    os << FormatValue( "manufacturerURL"  , pDevice->m_sManufacturerURL );
    os << FormatValue( "modelDescription" , pDevice->m_sModelDescription);
    os << FormatValue( "modelNumber"      , pDevice->m_sModelNumber     );
    os << FormatValue( "serialNumber"     , pDevice->m_sSerialNumber    );
    os << FormatValue( "UPC"              , pDevice->m_sUPC             );
    os << FormatValue( "presentationURL"  , pDevice->m_sPresentationURL );

    // MythTV Custom information
    os << FormatValue( "mythtv:X_secure" , pDevice->m_securityPin ? "true" : "false");
    os << FormatValue( "mythtv:X_protocol", pDevice->m_protocolVersion );

    NameValues::const_iterator nit = pDevice->m_lstExtra.begin();
    for (; nit != pDevice->m_lstExtra.end(); ++nit)
    {
        // -=>TODO: Hack to handle one element with attributes... need to
        //          handle attributes in a more generic way.

        if ((*nit).sName == "dlna:X_DLNADOC")
        {
            os << QString("<dlna:X_DLNADOC xmlns:dlna=\"urn:"
                          "schemas-dlna-org:device-1-0\">%1"
                          "</dlna:X_DLNADOC>\n" ).arg((*nit).sValue);
        }
        else
            os << FormatValue( (*nit).sName, (*nit).sValue );
    }

    // ----------------------------------------------------------------------
    // Output Any Icons.
    // ----------------------------------------------------------------------

    if (pDevice->m_listIcons.count() > 0)
    {
        os << "<iconList>\n";

        UPnpIconList::const_iterator it = pDevice->m_listIcons.begin();
        for (; it != pDevice->m_listIcons.end(); ++it)
        {

            os << "<icon>\n";
            os << FormatValue( "mimetype", (*it)->m_sMimeType );
            os << FormatValue( "width"   , (*it)->m_nWidth    );
            os << FormatValue( "height"  , (*it)->m_nHeight   );
            os << FormatValue( "depth"   , (*it)->m_nDepth    );
            os << FormatValue( "url"     , (*it)->m_sURL      );
            os << "</icon>\n";
        }
        os << "</iconList>\n";
    }

    os << FormatValue( "UDN"          , pDevice->GetUDN()      );

    // ----------------------------------------------------------------------
    // Output any Services
    // ----------------------------------------------------------------------

    if (pDevice->m_listServices.count() > 0)
    {
        // ------------------------------------------------------------------
        // -=>TODO: As a temporary fix don't expose the MSRR service unless we
        //          as an XBox360 or Windows MediaPlayer.
        //
        //          There is a problem with a DSM-520 with firmware 1.04 and
        //          the Denon AVR-4306 receiver.
        //
        //          If the MSRR Service is exposed, it won't let us browse
        //          any media content.
        //
        //          Need to find out real fix and remove this code.
        // ------------------------------------------------------------------

        //bool bDSM = sUserAgent.startsWith( "INTEL_NMPR/2.1 DLNADOC/1.00", false );

        os << "<serviceList>\n";

        UPnpServiceList::const_iterator it = pDevice->m_listServices.begin();
        for (; it != pDevice->m_listServices.end(); ++it)
        {
            if (!bIsXbox360 && (*it)->m_sServiceType.startsWith(
                    "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar",
                    Qt::CaseInsensitive))
            {
                continue;
            }

            os << "<service>\n";
            os << FormatValue( "serviceType", (*it)->m_sServiceType );
            os << FormatValue( "serviceId"  , (*it)->m_sServiceId   );
            os << FormatValue( "SCPDURL"    , (*it)->m_sSCPDURL     );
            os << FormatValue( "controlURL" , (*it)->m_sControlURL  );
            os << FormatValue( "eventSubURL", (*it)->m_sEventSubURL );
            os << "</service>\n";
        }
        os << "</serviceList>\n";
    }

    // ----------------------------------------------------------------------
    // Output any Embedded Devices
    // ----------------------------------------------------------------------

    // -=>Note:  XBMC can't handle sub-devices, it's UserAgent is blank.
#if 0
    if (sUserAgent.length() > 0)
    {
        if (pDevice->m_listDevices.count() > 0)
        {
            os << "<deviceList>";

            for ( UPnpDevice *pEmbeddedDevice  = pDevice->m_listDevices.first();
                              pEmbeddedDevice != NULL;
                              pEmbeddedDevice  = pDevice->m_listDevices.next() )
            {
                OutputDevice( os, pEmbeddedDevice );
            }
            os << "</deviceList>";
        }
    }
#endif
    os << "</device>\n";
    os << flush;
}
コード例 #29
0
ファイル: JackNetAdapter.cpp プロジェクト: antkazam/jack2
    JackNetAdapter::JackNetAdapter(jack_client_t* jack_client, jack_nframes_t buffer_size, jack_nframes_t sample_rate, const JSList* params)
            : JackAudioAdapterInterface(buffer_size, sample_rate), JackNetSlaveInterface(), fThread(this)
    {
        jack_log("JackNetAdapter::JackNetAdapter");

        /*
        Global parameter setting : we can't call JackNetSlaveInterface constructor with some parameters before,
        because we don't have full parametering right now, parameters will be parsed from the param list,
        and then JackNetSlaveInterface will be filled with proper values.
        */
        char multicast_ip[32];
        uint udp_port;
        GetHostName(fParams.fName, JACK_CLIENT_NAME_SIZE);
        fSocket.GetName(fParams.fSlaveNetName);
        fParams.fMtu = DEFAULT_MTU;
        // Desactivated for now...
        fParams.fTransportSync = 0;
        int send_audio = -1;
        int return_audio = -1;
        fParams.fSendMidiChannels = 0;
        fParams.fReturnMidiChannels = 0;
        fParams.fSampleRate = sample_rate;
        fParams.fPeriodSize = buffer_size;
        fParams.fSlaveSyncMode = 1;
        fParams.fNetworkLatency = 2;
        fParams.fSampleEncoder = JackFloatEncoder;
        fClient = jack_client;
    
        // Possibly use env variable
        const char* default_udp_port = getenv("JACK_NETJACK_PORT");
        udp_port = (default_udp_port) ? atoi(default_udp_port) : DEFAULT_PORT;

        const char* default_multicast_ip = getenv("JACK_NETJACK_MULTICAST");
        if (default_multicast_ip) {
            strcpy(multicast_ip, default_multicast_ip);
        } else {
            strcpy(multicast_ip, DEFAULT_MULTICAST_IP);
        }

        //options parsing
        const JSList* node;
        const jack_driver_param_t* param;
        for (node = params; node; node = jack_slist_next(node))
        {
            param = (const jack_driver_param_t*) node->data;

            switch (param->character) {
                case 'a' :
                    assert(strlen(param->value.str) < 32);
                    strcpy(multicast_ip, param->value.str);
                    break;
                case 'p' :
                    udp_port = param->value.ui;
                    break;
                case 'M' :
                    fParams.fMtu = param->value.i;
                    break;
                case 'C' :
                    send_audio = param->value.i;
                    break;
                case 'P' :
                    return_audio = param->value.i;
                    break;
                case 'n' :
                    strncpy(fParams.fName, param->value.str, JACK_CLIENT_NAME_SIZE);
                    break;
                case 't' :
                    fParams.fTransportSync = param->value.ui;
                    break;
            #if HAVE_CELT
                case 'c':
                    if (param->value.i > 0) {
                        fParams.fSampleEncoder = JackCeltEncoder;
                        fParams.fKBps = param->value.i;
                    }
                    break;
            #endif
            #if HAVE_OPUS
                case 'O':
                    if (param->value.i > 0) {
                        fParams.fSampleEncoder = JackOpusEncoder;
                        fParams.fKBps = param->value.i;
                    }
                    break;
            #endif
                case 'l' :
                    fParams.fNetworkLatency = param->value.i;
                    if (fParams.fNetworkLatency > NETWORK_MAX_LATENCY) {
                        jack_error("Error : network latency is limited to %d\n", NETWORK_MAX_LATENCY);
                        throw std::bad_alloc();
                    }
                    break;
                case 'q':
                    fQuality = param->value.ui;
                    break;
                case 'g':
                    fRingbufferCurSize = param->value.ui;
                    fAdaptative = false;
                    break;
             }
        }

        strcpy(fMulticastIP, multicast_ip);

        // Set the socket parameters
        fSocket.SetPort(udp_port);
        fSocket.SetAddress(fMulticastIP, udp_port);

        // If not set, takes default
        fParams.fSendAudioChannels = (send_audio == -1) ? 2 : send_audio;

        // If not set, takes default
        fParams.fReturnAudioChannels = (return_audio == -1) ? 2 : return_audio;

        // Set the audio adapter interface channel values
        SetInputs(fParams.fSendAudioChannels);
        SetOutputs(fParams.fReturnAudioChannels);

        // Soft buffers will be allocated later (once network initialization done)
        fSoftCaptureBuffer = NULL;
        fSoftPlaybackBuffer = NULL;
    }
コード例 #30
0
void CTO2GameServerShell::Update(LTFLOAT timeElapsed)
{
	// Update the main server first
	CGameServerShell::Update(timeElapsed);

	m_VersionMgr.Update();

	if (!GetServerDir())
		return;

	//if we're hosting LANOnly game, don't publish the server
	if( m_ServerGameOptions.m_bLANOnly )
		return;

	// Are we still waiting?
	static std::string status;
	switch (GetServerDir()->GetCurStatus())
	{
		case IServerDirectory::eStatus_Processing : 
			status ="";
			break;
		case IServerDirectory::eStatus_Waiting : 
			if (status.empty())
				status = GetServerDir()->GetLastRequestResultString();
			break;
		case IServerDirectory::eStatus_Error : 
			{
				
				IServerDirectory::ERequest eErrorRequest = GetServerDir()->GetLastErrorRequest();
				status = GetServerDir()->GetLastRequestResultString();
				GetServerDir()->ProcessRequestList();
			}
			break;
	};



	// Publish the server if we've waited long enough since the last directory update
	uint32 nCurTime = (uint32)GetTickCount();
	if ((m_nLastPublishTime == 0) || 
		((nCurTime - m_nLastPublishTime) > k_nRepublishDelay))
	{
		status = "";
		m_nLastPublishTime = nCurTime;
		uint32 nMax = 0;
		g_pLTServer->GetMaxConnections(nMax);

		// If not run by a dedicated server, we need to add one connection
		// for the local host.
		if( !m_ServerGameOptions.m_bDedicated )
			nMax++;

		GetServerDir()->SetActivePeer(0);

		CAutoMessage cMsg;

		// Update the summary info
		cMsg.WriteString(GetHostName());
		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Name, *cMsg.Read());

		char fname[_MAX_FNAME] = "";
		_splitpath( GetCurLevel(), NULL, NULL, fname, NULL );

		// Update the summary info
		cMsg.WriteString(g_pVersionMgr->GetBuild());
		cMsg.WriteString( fname );
		cMsg.Writeuint8(GetNumPlayers());
		cMsg.Writeuint8(nMax);
		cMsg.Writebool(m_ServerGameOptions.m_bUsePassword);
		cMsg.Writeuint8((uint8)GetGameType());
		cMsg.WriteString( m_ServerGameOptions.m_sModName.c_str() );

		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Summary, *cMsg.Read());


		// Update the details
		ServerMissionSettings sms = g_pServerMissionMgr->GetServerSettings();
		cMsg.Writebool(sms.m_bUseSkills);
		cMsg.Writebool(sms.m_bFriendlyFire);
		cMsg.Writeuint8(sms.m_nMPDifficulty);
		cMsg.Writefloat(sms.m_fPlayerDiffFactor);

		CPlayerObj* pPlayer = GetFirstNetPlayer();
	    while (pPlayer)
		{
			//has player info
			cMsg.Writebool(true);
			cMsg.WriteString(pPlayer->GetNetUniqueName());
			cMsg.Writeuint16( Min( GetPlayerPing(pPlayer), ( uint32 )65535 ));
			pPlayer = GetNextNetPlayer();
		};

		//end of player info
		cMsg.Writebool(false);

	
		cMsg.Writeuint8(sms.m_nRunSpeed);
		cMsg.Writeuint8(sms.m_nScoreLimit);
		cMsg.Writeuint8(sms.m_nTimeLimit);

		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Details, *cMsg.Read());

		// Update the port
		char aHostAddr[16];
		uint16 nHostPort;
		g_pLTServer->GetTcpIpAddress(aHostAddr, sizeof(aHostAddr), nHostPort);
		cMsg.Writeuint16(nHostPort);
		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Port, *cMsg.Read());
		
		// Tell serverdir again about info, but in service specific manner.
		PeerInfo_Service_Titan peerInfo;
		peerInfo.m_sHostName = GetHostName( );
		peerInfo.m_sCurWorld = fname; 
		peerInfo.m_nCurNumPlayers = GetNumPlayers( );
		peerInfo.m_nMaxNumPlayers = nMax;
		peerInfo.m_bUsePassword = m_ServerGameOptions.m_bUsePassword;
		peerInfo.m_sGameType = GameTypeToString( GetGameType( ));
		peerInfo.m_nScoreLimit = sms.m_nScoreLimit;
		peerInfo.m_nTimeLimit = sms.m_nTimeLimit;

		PeerInfo_Service_Titan::Player player;
		CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
		while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
		{
			CPlayerObj* pPlayerObj = *iter;

			player.m_sName = pPlayerObj->GetNetUniqueName( );
			player.m_nScore = pPlayerObj->GetPlayerScore()->GetScore( );

			float fPing;
			g_pLTServer->GetClientPing( pPlayerObj->GetClient( ), fPing );
			player.m_nPing = ( uint16 )( fPing + 0.5f );

			peerInfo.m_PlayerList.push_back( player );

			iter++;
		}


		cMsg.Writeuint32(( uint32 )&peerInfo );
		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Service, *cMsg.Read());

		// Tell the world about me...
		GetServerDir()->QueueRequest(IServerDirectory::eRequest_Publish_Server);
	}
}