base
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/***************************************************************************
|
||||
Local Ip Cache Class
|
||||
-----------------------------------------
|
||||
begin : 2010/03/31
|
||||
copyright : (C) 2005 SolutionBox Inc.
|
||||
author : Service 1 Team
|
||||
email : svc1@solbox.com
|
||||
version : 1.0
|
||||
|
||||
CopyRight(C) 2005 SolutionBox Inc. All Rights reserved.
|
||||
Redistribution and use in source and binary forms, with or with out
|
||||
modification, are not permitted in outside of SolutionBox Inc.
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __LOCAL_IP_CACHE__
|
||||
#define __LOCAL_IP_CACHE__
|
||||
|
||||
#include <pthread.h>
|
||||
#include <string>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/// @brief CLocalIPCache
|
||||
/// CLocalIPCache는 생성자의 두 번째 param으로 입력한 NIC명의
|
||||
/// IP정보를 전달 해주는 클래스이다.
|
||||
/// 주요 인터페이스 함수는 쓰레드를 시작 하는 start()함수와
|
||||
/// IP를 얻어오는 GetLocalIP() 함수이다.
|
||||
///
|
||||
/// 내부적으로 Thread를 사용하고있다.
|
||||
class CLocalIPCache
|
||||
{
|
||||
public:
|
||||
/// @brief 생성자
|
||||
/// @param [in] szNICName 현재 클래스를 사용하여 IP정보를 얻을 NIC 장비의 이름을 입력한다.
|
||||
CLocalIPCache( const string& szNICName );
|
||||
~CLocalIPCache();
|
||||
|
||||
|
||||
/// @brief Thread를 생성하고, 이를 시작한다.
|
||||
/// @param none
|
||||
/// @return 성공은 return true 실패는 return false
|
||||
bool Start();
|
||||
|
||||
/// @brief 생성자의 두 번째 param으로 입력된 NIC 장비의 IP정보를 리턴한다.
|
||||
/// @param [out] szLocalIP 요청한 NIC에 해당하는 IP값을 전달한다.
|
||||
/// @return 성공은 return true, 실패하면 false.
|
||||
bool GetLocalIP(string& szLocalIP);
|
||||
|
||||
private:
|
||||
|
||||
// 입력받은 NIC 명.
|
||||
string m_szNICName;
|
||||
|
||||
// 해당 NIC의 ip를 입력받는다.
|
||||
string m_szLocalIP;
|
||||
|
||||
pthread_mutex_t m_mxLock;
|
||||
|
||||
// 쓰레드 핸들
|
||||
pthread_t m_threadHandle;
|
||||
|
||||
// 쓰레드 시작 루틴이다.
|
||||
static void* EntryPoint(void* arg);
|
||||
|
||||
// 해당 함수의 내용은 수정하지 말것.
|
||||
void Excute();
|
||||
|
||||
// m_szNICName 해당 NIC의 ip정보를 얻는 함수이다.
|
||||
bool GetIP(string& szLocalIP);
|
||||
};
|
||||
|
||||
#endif // __LOCAL_IP_CACHE__
|
||||
Reference in New Issue
Block a user