From 4899e62259afc42e8b449a68f2f99bba74e8b025 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 21 Mar 2013 20:17:24 +0000 Subject: WinPopup adoptation started git-svn-id: http://svn.miranda-ng.org/main/trunk@4154 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WinPopup/src/netbios_name.h | 155 ++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 protocols/WinPopup/src/netbios_name.h (limited to 'protocols/WinPopup/src/netbios_name.h') diff --git a/protocols/WinPopup/src/netbios_name.h b/protocols/WinPopup/src/netbios_name.h new file mode 100644 index 0000000000..c273082be9 --- /dev/null +++ b/protocols/WinPopup/src/netbios_name.h @@ -0,0 +1,155 @@ +/* + +WinPopup Protocol plugin for Miranda IM. + +Copyright (C) 2004-2011 Nikolay Raspopov + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#define SMB_ANY_NAME _T("* ") +#define FACILITY_NETBIOS (0x0f0f) +#define SMB_HEADER_SIZE (32) + +#pragma pack (push, 1) + +typedef struct SESSION_INFO_BLOCK +{ + SESSION_HEADER sib_header; + SESSION_BUFFER sib_Names[ NCBNAMSZ ]; +} SESSION_INFO_BLOCK, *PSESSION_INFO_BLOCK; + +#pragma pack (pop) + +class netbios_name +{ +public: + netbios_name(LPCTSTR n = SMB_ANY_NAME /* ANSI */, UCHAR type = 0, bool group = false, UCHAR lana = 0); + netbios_name(const NAME_BUFFER& n, UCHAR lana); + netbios_name& operator=(const netbios_name& n); + netbios_name& operator=(const UCHAR* n); + // Сравнение (производиться только по имени, номеру имени, типу имени) + bool operator==(const NAME_BUFFER& n) const; + // Сравнение (производиться только по имени, номеру имени, типу имени) + bool operator!=(const NAME_BUFFER& n) const; + // Сравнение (производиться только по имени, номеру имени, типу имени, адаптеру) + bool operator==(const netbios_name& n) const; + // Сравнение (производиться только по имени, номеру имени, типу имени, адаптеру) + bool operator!=(const netbios_name& n) const; + // Регистрация имени + bool Register(); + // Для ускорения + void AskForDestroy(); + // Дерегистрация имени + void Destroy(); + // Обратное преобразование NetBIOS-имени из OEM в ANSI в виде: NAME + CStringA GetANSIFullName() const; + + CStringA original; // Полное имя (в ANSI кодировке) + NAME_BUFFER netbiosed; // NetBIOS имя (в OEM кодировке): + // typedef struct _NAME_BUFFER { + // UCHAR name[NCBNAMSZ]; + // UCHAR name_num; + // UCHAR name_flags; + // } NAME_BUFFER, *PNAME_BUFFER; + + // Получение атрибутов имени: + + UCHAR GetType() const; + bool IsGroupName() const; + bool IsRegistered() const; + bool IsDuplicated() const; + bool IsError() const; + bool IsOwnName() const; + UCHAR GetLana() const; + size_t GetLength() const; // Длина имени NetBIOS + +protected: + bool m_managed; // Флаг управляемого имени + bool m_registered; // Флаг успешной регистрации имени + bool m_duplicated; // Флаг существования имени до регистрации + bool m_error; // Флаг ошибки прослушивания имени + UCHAR m_lana; // Номер адаптера + HANDLE m_listener; // Хэндлер рабочего потока-слушателя сессий + HANDLE m_dgreceiver; // Хэндлер рабочего потока-слушателя датаграмм + HANDLE m_term; // Хэндлер события останова рабочего потока-слушателя + + // Обратное преобразование NetBIOS-имени из OEM в ANSI + CStringA GetANSIName() const; + + bool GetRealSender(UCHAR lsn, CStringA& sRealFrom) const; + UCHAR AddName(); + UCHAR DeleteName(); + + // Ожидание начала сессии + void Listener(); + static void ListenerThread(LPVOID param); + + // Ожидание датаграммы + void DatagramReceiver(); + static void DatagramReceiverThread(LPVOID param); + + // Обработка сессии (из Listener) + void Receiver(UCHAR lsn); + static void ReceiverThread(LPVOID param); +}; + +typedef CAtlArray netbios_name_array; +typedef CAtlList netbios_name_list; + +/* +Name Number(h) Type Usage +-------------------------------------------------------------------------- + 00 U Workstation Service + 01 U Messenger Service +<\\--__MSBROWSE__> 01 G Master Browser + 03 U Messenger Service + 06 U RAS Server Service + 1F U NetDDE Service + 20 U File Server Service + 21 U RAS Client Service + 22 U Microsoft Exchange Interchange(MSMail +Connector) + 23 U Microsoft Exchange Store + 24 U Microsoft Exchange Directory + 30 U Modem Sharing Server Service + 31 U Modem Sharing Client Service + 43 U SMS Clients Remote Control + 44 U SMS Administrators Remote Control +Tool + 45 U SMS Clients Remote Chat + 46 U SMS Clients Remote Transfer + 4C U DEC Pathworks TCPIP service on +Windows NT + 42 U mccaffee anti-virus + 52 U DEC Pathworks TCPIP service on +Windows NT + 87 U Microsoft Exchange MTA + 6A U Microsoft Exchange IMC + BE U Network Monitor Agent + BF U Network Monitor Application + 03 U Messenger Service + 00 G Domain Name + 1B U Domain Master Browser + 1C G Domain Controllers + 1D U Master Browser + 1E G Browser Service Elections + 1C G IIS + 00 U IIS + [2B] U Lotus Notes Server Service +IRISMULTICAST [2F] G Lotus Notes +IRISNAMESERVER [33] G Lotus Notes +Forte_$ND800ZA [20] U DCA IrmaLan Gateway Server Service +*/ -- cgit v1.2.3