?? ipmsg.h
字號:
/* @(#)Copyright (C) H.Shirouzu 1996-2004 ipmsg.h Ver2.05 */
/* ========================================================================
Project Name : IP Messenger for Win32
Module Name : Main Header
Create : 1996-06-01(Sat)
Update : 2004-01-01(Thu)
Copyright : H.Shirouzu
Reference :
======================================================================== */
#ifndef IPMSG_H
#define IPMSG_H
#include <time.h>
/* IP Messenger Communication Protocol version 1.2 define */
/* macro */
#define GET_MODE(command) (command & 0x000000ffUL)
#define GET_OPT(command) (command & 0xffffff00UL)
/* header */
#define IPMSG_VERSION 0x0001
#define IPMSG_DEFAULT_PORT 0x0979
/* command */
#define IPMSG_NOOPERATION 0x00000000UL
#define IPMSG_BR_ENTRY 0x00000001UL
#define IPMSG_BR_EXIT 0x00000002UL
#define IPMSG_ANSENTRY 0x00000003UL
#define IPMSG_BR_ABSENCE 0x00000004UL
#define IPMSG_BR_ISGETLIST 0x00000010UL
#define IPMSG_OKGETLIST 0x00000011UL
#define IPMSG_GETLIST 0x00000012UL
#define IPMSG_ANSLIST 0x00000013UL
#define IPMSG_BR_ISGETLIST2 0x00000018UL
#define IPMSG_SENDMSG 0x00000020UL
#define IPMSG_RECVMSG 0x00000021UL
#define IPMSG_READMSG 0x00000030UL
#define IPMSG_DELMSG 0x00000031UL
#define IPMSG_ANSREADMSG 0x00000032UL
#define IPMSG_GETINFO 0x00000040UL
#define IPMSG_SENDINFO 0x00000041UL
#define IPMSG_GETABSENCEINFO 0x00000050UL
#define IPMSG_SENDABSENCEINFO 0x00000051UL
#define IPMSG_GETFILEDATA 0x00000060UL
#define IPMSG_RELEASEFILES 0x00000061UL
#define IPMSG_GETDIRFILES 0x00000062UL
#define IPMSG_GETPUBKEY 0x00000072UL
#define IPMSG_ANSPUBKEY 0x00000073UL
/* option for all command */
#define IPMSG_ABSENCEOPT 0x00000100UL
#define IPMSG_SERVEROPT 0x00000200UL
#define IPMSG_DIALUPOPT 0x00010000UL
#define IPMSG_FILEATTACHOPT 0x00200000UL
#define IPMSG_ENCRYPTOPT 0x00400000UL
/* option for send command */
#define IPMSG_SENDCHECKOPT 0x00000100UL
#define IPMSG_SECRETOPT 0x00000200UL
#define IPMSG_BROADCASTOPT 0x00000400UL
#define IPMSG_MULTICASTOPT 0x00000800UL
#define IPMSG_NOPOPUPOPT 0x00001000UL
#define IPMSG_AUTORETOPT 0x00002000UL
#define IPMSG_RETRYOPT 0x00004000UL
#define IPMSG_PASSWORDOPT 0x00008000UL
#define IPMSG_NOLOGOPT 0x00020000UL
#define IPMSG_NEWMUTIOPT 0x00040000UL
#define IPMSG_NOADDLISTOPT 0x00080000UL
#define IPMSG_READCHECKOPT 0x00100000UL
#define IPMSG_SECRETEXOPT (IPMSG_READCHECKOPT|IPMSG_SECRETOPT)
/* encryption flags for encrypt command */
#define IPMSG_RSA_512 0x00000001UL
#define IPMSG_RSA_1024 0x00000002UL
#define IPMSG_RSA_2048 0x00000004UL
#define IPMSG_RC2_40 0x00001000UL
#define IPMSG_RC2_128 0x00004000UL
#define IPMSG_RC2_256 0x00008000UL
#define IPMSG_BLOWFISH_128 0x00020000UL
#define IPMSG_BLOWFISH_256 0x00040000UL
#define IPMSG_SIGN_MD5 0x10000000UL
/* compatibilty for Win beta version */
#define IPMSG_RC2_40OLD 0x00000010UL // for beta1-4 only
#define IPMSG_RC2_128OLD 0x00000040UL // for beta1-4 only
#define IPMSG_BLOWFISH_128OLD 0x00000400UL // for beta1-4 only
#define IPMSG_RC2_40ALL (IPMSG_RC2_40|IPMSG_RC2_40OLD)
#define IPMSG_RC2_128ALL (IPMSG_RC2_128|IPMSG_RC2_128OLD)
#define IPMSG_BLOWFISH_128ALL (IPMSG_BLOWFISH_128|IPMSG_BLOWFISH_128OLD)
/* file types for fileattach command */
#define IPMSG_FILE_REGULAR 0x00000001UL
#define IPMSG_FILE_DIR 0x00000002UL
#define IPMSG_FILE_RETPARENT 0x00000003UL // return parent directory
#define IPMSG_FILE_SYMLINK 0x00000004UL
#define IPMSG_FILE_CDEV 0x00000005UL // for UNIX
#define IPMSG_FILE_BDEV 0x00000006UL // for UNIX
#define IPMSG_FILE_FIFO 0x00000007UL // for UNIX
#define IPMSG_FILE_RESFORK 0x00000010UL // for Mac
/* file attribute options for fileattach command */
#define IPMSG_FILE_RONLYOPT 0x00000100UL
#define IPMSG_FILE_HIDDENOPT 0x00001000UL
#define IPMSG_FILE_EXHIDDENOPT 0x00002000UL // for MacOS X
#define IPMSG_FILE_ARCHIVEOPT 0x00004000UL
#define IPMSG_FILE_SYSTEMOPT 0x00008000UL
/* extend attribute types for fileattach command */
#define IPMSG_FILE_UID 0x00000001UL
#define IPMSG_FILE_USERNAME 0x00000002UL // uid by string
#define IPMSG_FILE_GID 0x00000003UL
#define IPMSG_FILE_GROUPNAME 0x00000004UL // gid by string
#define IPMSG_FILE_PERM 0x00000010UL // for UNIX
#define IPMSG_FILE_MAJORNO 0x00000011UL // for UNIX devfile
#define IPMSG_FILE_MINORNO 0x00000012UL // for UNIX devfile
#define IPMSG_FILE_CTIME 0x00000013UL // for UNIX
#define IPMSG_FILE_MTIME 0x00000014UL
#define IPMSG_FILE_ATIME 0x00000015UL
#define IPMSG_FILE_CREATETIME 0x00000016UL
#define IPMSG_FILE_CREATOR 0x00000020UL // for Mac
#define IPMSG_FILE_FILETYPE 0x00000021UL // for Mac
#define IPMSG_FILE_FINDERINFO 0x00000022UL // for Mac
#define IPMSG_FILE_ACL 0x00000030UL
#define IPMSG_FILE_ALIASFNAME 0x00000040UL // alias fname
#define IPMSG_FILE_UNICODEFNAME 0x00000041UL // UNICODE fname
#define FILELIST_SEPARATOR '\a'
#define HOSTLIST_SEPARATOR '\a'
#define HOSTLIST_DUMMY "\b"
/* end of IP Messenger Communication Protocol version 1.2 define */
/* IP Messenger for Windows internal define */
#define IPMSG_REVERSEICON 0x0100
#define IPMSG_TIMERINTERVAL 500
#define IPMSG_ENTRYMINSEC 5
#define IPMSG_GETLIST_FINISH 0
#define IPMSG_BROADCAST_TIMER 0x0101
#define IPMSG_SEND_TIMER 0x0102
#define IPMSG_LISTGET_TIMER 0x0104
#define IPMSG_LISTGETRETRY_TIMER 0x0105
#define IPMSG_ENTRY_TIMER 0x0106
#define IPMSG_DUMMY_TIMER 0x0107
#define IPMSG_RECV_TIMER 0x0108
#define IPMSG_ANS_TIMER 0x0109
#define IPMSG_NICKNAME 1
#define IPMSG_FULLNAME 2
#define IPMSG_NAMESORT 0x00000000
#define IPMSG_IPADDRSORT 0x00000001
#define IPMSG_HOSTSORT 0x00000002
#define IPMSG_NOGROUPSORTOPT 0x00000100
#define IPMSG_ICMPSORTOPT 0x00000200
#define IPMSG_NOKANJISORTOPT 0x00000400
#define IPMSG_ALLREVSORTOPT 0x00000800
#define IPMSG_GROUPREVSORTOPT 0x00001000
#define IPMSG_SUBREVSORTOPT 0x00002000
#define WM_IPMSG_NOTIFY (WM_USER + 101)
#define WM_IPMSG_INITICON (WM_USER + 102)
#define WM_RECVDLG_OPEN (WM_USER + 110)
#define WM_RECVDLG_EXIT (WM_USER + 111)
#define WM_RECVDLG_FILEBUTTON (WM_USER + 112)
#define WM_SENDDLG_OPEN (WM_USER + 121)
#define WM_SENDDLG_CREATE (WM_USER + 122)
#define WM_SENDDLG_EXIT (WM_USER + 123)
#define WM_SENDDLG_HIDE (WM_USER + 124)
#define WM_SENDDLG_RESIZE (WM_USER + 125)
#define WM_UDPEVENT (WM_USER + 130)
#define WM_TCPEVENT (WM_USER + 131)
#define WM_REFRESH_HOST (WM_USER + 140)
#define WM_MSGDLG_EXIT (WM_USER + 150)
#define WM_DELMISCDLG (WM_USER + 151)
#define WM_HIDE_CHILDWIN (WM_USER + 160)
#define WM_EDIT_DBLCLK (WM_USER + 170)
#define WM_DELAYSETTEXT (WM_USER + 180)
// ListView extended define for VC4
#ifndef LVM_SETEXTENDEDLISTVIEWSTYLE
#define LVM_SETEXTENDEDLISTVIEWSTYLE (LVM_FIRST + 54)
#define LVM_GETEXTENDEDLISTVIEWSTYLE (LVM_FIRST + 55)
#define LVM_SETCOLUMNORDERARRAY (LVM_FIRST + 58)
#define LVM_GETCOLUMNORDERARRAY (LVM_FIRST + 59)
#define LVS_EX_GRIDLINES 0x00000001
#define LVS_EX_HEADERDRAGDROP 0x00000010
#define LVS_EX_FULLROWSELECT 0x00000020
#define LVS_SHOWSELALWAYS 0x0008
#endif
// ListView extended define for VC4 & VC5
#ifndef LVM_SETSELECTIONMARK
#define LVM_SETSELECTIONMARK (LVM_FIRST + 67)
#endif
// CryptoAPI for VC4
#ifndef MS_DEF_PROV
typedef unsigned long HCRYPTPROV;
typedef unsigned long HCRYPTKEY;
typedef unsigned long HCRYPTHASH;
typedef unsigned int ALG_ID;
#define ALG_TYPE_RSA (2 << 9)
#define ALG_TYPE_BLOCK (3 << 9)
#define ALG_CLASS_DATA_ENCRYPT (3 << 13)
#define ALG_CLASS_HASH (4 << 13)
#define ALG_CLASS_KEY_EXCHANGE (5 << 13)
#define ALG_SID_RSA_ANY 0
#define ALG_TYPE_ANY 0
#define ALG_SID_RC2 2
#define ALG_SID_MD5 3
#define CALG_RSA_KEYX (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_RSA|ALG_SID_RSA_ANY)
#define CALG_RC2 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_RC2)
#define CALG_MD5 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5)
#define CRYPT_EXPORTABLE 0x00000001
#define PROV_RSA_FULL 1
#define MS_DEF_PROV "Microsoft Base Cryptographic Provider v1.0"
#define MS_ENHANCED_PROV "Microsoft Enhanced Cryptographic Provider v1.0"
#define CUR_BLOB_VERSION 0x02
#define SIMPLEBLOB 0x1
#define PUBLICKEYBLOB 0x6
#define PRIVATEKEYBLOB 0x7
#define CRYPT_NEWKEYSET 0x00000008
#define CRYPT_DELETEKEYSET 0x00000010
#define CRYPT_MACHINE_KEYSET 0x00000020
#define AT_KEYEXCHANGE 1
#define AT_SIGNATURE 2
#define KP_EFFECTIVE_KEYLEN 19 // for CryptSetKeyParam
#define NTE_BAD_KEY 0x80090003L
typedef struct _CRYPTOAPI_BLOB {
DWORD cbData;
BYTE *pbData;
} DATA_BLOB, *PDATA_BLOB;
#endif
typedef struct _CRYPTPROTECT_PROMPTSTRUCT {
DWORD cbSize;
DWORD dwPromptFlags;
HWND hwndApp;
LPCWSTR szPrompt;
} CRYPTPROTECT_PROMPTSTRUCT, *PCRYPTPROTECT_PROMPTSTRUCT;
#define CRYPTPROTECT_UI_FORBIDDEN 0x1
#define CRYPTPROTECT_LOCAL_MACHINE 0x4
#define CRYPTPROTECT_CRED_SYNC 0x8
#define CRYPTPROTECT_AUDIT 0x10
#define CRYPTPROTECT_VERIFY_PROTECTION 0x40
#define SKEY_HEADER_SIZE 12
#define PRIV_BLOB_USER 0x0001
#define PRIV_BLOB_DPAPI 0x0002
#define PRIV_BLOB_RAW 0x0003
#define PRIV_SEED_HEADER "ipmsg:"
#define PRIV_SEED_HEADER_LEN 6
#define PRIV_SEED_LEN (PRIV_SEED_HEADER_LEN + (128/8)) // 128bit seed
extern BOOL (WINAPI *pCryptAcquireContext)(HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD);
extern BOOL (WINAPI *pCryptDestroyKey)(HCRYPTKEY);
extern BOOL (WINAPI *pCryptGetKeyParam)(HCRYPTKEY, DWORD, BYTE *, DWORD *, DWORD);
extern BOOL (WINAPI *pCryptSetKeyParam)(HCRYPTKEY, DWORD, BYTE *, DWORD);
extern BOOL (WINAPI *pCryptExportKey)(HCRYPTKEY, HCRYPTKEY, DWORD, DWORD, BYTE *, DWORD *);
extern BOOL (WINAPI *pCryptGetUserKey)(HCRYPTPROV, DWORD, HCRYPTKEY *);
extern BOOL (WINAPI *pCryptEncrypt)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *, DWORD);
extern BOOL (WINAPI *pCryptGenKey)(HCRYPTPROV, ALG_ID, DWORD, HCRYPTKEY *);
extern BOOL (WINAPI *pCryptGenRandom)(HCRYPTPROV, DWORD, BYTE *);
extern BOOL (WINAPI *pCryptImportKey)(HCRYPTPROV, CONST BYTE *, DWORD, HCRYPTKEY, DWORD, HCRYPTKEY *);
extern BOOL (WINAPI *pCryptDecrypt)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *);
extern BOOL (WINAPI *pCryptCreateHash)(HCRYPTPROV, ALG_ID, HCRYPTKEY, DWORD, HCRYPTHASH *);
extern BOOL (WINAPI *pCryptHashData)(HCRYPTHASH, BYTE *, DWORD, DWORD);
extern BOOL (WINAPI *pCryptSignHash)(HCRYPTHASH, DWORD, LPCSTR, DWORD, BYTE *, DWORD *);
extern BOOL (WINAPI *pCryptVerifySignature)(HCRYPTHASH, CONST BYTE *, DWORD, HCRYPTKEY, LPCSTR, DWORD);
extern BOOL (WINAPI *pCryptReleaseContext)(HCRYPTPROV, DWORD);
extern BOOL (WINAPI *pCryptProtectData)(DATA_BLOB* pDataIn, LPCWSTR szDataDescr, DATA_BLOB* pOptionalEntropy, PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, DATA_BLOB* pDataOut);
extern BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB* pDataIn, LPWSTR* ppszDataDescr, DATA_BLOB* pOptionalEntropy, PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, DATA_BLOB* pDataOut);
// General define
#define MAX_SOCKBUF 65536
#define MAX_UDPBUF 16384
#define MAX_CRYPTLEN ((MAX_UDPBUF - MAX_BUF) / 2)
#define MAX_BUF 1024
#define MAX_NAMEBUF 50
#define MAX_LANGBUF 10
#define MAX_LISTBUF (MAX_NAMEBUF * 3 + 50)
#define MAX_ANSLIST 100
#define HS_TOOLS "HSTools"
#define IP_MSG "IPMsg"
#define NO_NAME "no_name"
#define URL_STR "://"
#define MAILTO_STR "mailto:"
#define MSG_STR "msg"
#define DEFAULT_PRIORITY 10
#define PRIORITY_OFFSET 10
#define DEFAULT_PRIORITYMAX 5
#ifdef JAPANESE
#define PROPORTIONAL_FONT "俵俽 俹僑僔僢僋"
#endif
#define ALIGN_BLOCK(size, align_size) (((size) + (align_size) -1) / (align_size))
class PubKey {
protected:
BYTE *key;
int keyLen;
int e;
int capa;
public:
PubKey(void) { key = NULL; capa = 0; }
~PubKey() { UnSet(); }
void Set(BYTE *_key, int len, int _e, int _capa) {
UnSet(); e = _e; capa = _capa; key = new BYTE [keyLen=len]; memcpy(key, _key, len);
}
void UnSet(void) {
delete [] key; key = NULL; capa = 0;
}
const BYTE *Key(void) { return key; }
int KeyLen(void) { return keyLen; }
int Exponent(void) { return e; }
BOOL KeyBlob(BYTE *blob, int maxLen, int *len) {
if ((*len = KeyBlobLen()) > maxLen) return FALSE;
/* PUBLICSTRUC */ blob[0] = PUBLICKEYBLOB; blob[1] = CUR_BLOB_VERSION;
*(WORD *)(blob+2) = 0; *(ALG_ID *)(blob+4) = CALG_RSA_KEYX;
/* RSAPUBKEY */ memcpy(blob+8, "RSA1", 4);
*(DWORD *)(blob+12) = keyLen * 8; *(int *)(blob+16) = e;
/* PUBKEY_DATA */ memcpy(blob+20, key, keyLen);
return TRUE;
}
int KeyBlobLen(void) { return keyLen + 8 + 12; /* PUBLICKEYSTRUC + RSAPUBKEY */ }
void SetByBlob(BYTE *blob, int _capa) {
UnSet();
keyLen = *(int *)(blob+12) / 8;
key = new BYTE [keyLen];
memcpy(key, blob+20, keyLen);
e = *(int *)(blob+16);
capa = _capa;
}
int Capa(void) { return capa; }
};
struct HostSub {
char userName[MAX_NAMEBUF];
char hostName[MAX_NAMEBUF];
ULONG addr;
int portNo;
};
struct Host {
HostSub hostSub;
char nickName[MAX_NAMEBUF];
char groupName[MAX_NAMEBUF];
ULONG hostStatus;
time_t updateTime;
int priority;
int refCnt;
PubKey pubKey;
int cryptSpec;
Host(void) { refCnt = 0; }
~Host() { refCnt = 0; }
int RefCnt(int cnt=0) { return refCnt += cnt; }
};
class THosts {
public:
enum Kind { NAME, ADDR, NAME_ADDR, MAX_ARRAY };
BOOL enable[MAX_ARRAY];
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -