80#define INADDR_NONE ~0UL
83#define NBR_ADDWORD(p,word) (*(WORD *)(p)) = htons(word)
84#define NBR_GETWORD(p) ntohs(*(WORD *)(p))
87#define MAX_QUERIES 0xffff
88#define MIN_QUERY_TIMEOUT 100
89#define MAX_QUERY_TIMEOUT 0xffffffff
90#define BCAST_QUERIES 3
91#define BCAST_QUERY_TIMEOUT 750
93#define WINS_QUERY_TIMEOUT 750
94#define MAX_WINS_SERVERS 2
95#define MIN_CACHE_TIMEOUT 60000
96#define CACHE_TIMEOUT 360000
98#define MAX_NBT_NAME_SZ 255
99#define SIMPLE_NAME_QUERY_PKT_SIZE 16 + MAX_NBT_NAME_SZ
101#define NBNS_TYPE_NB 0x0020
102#define NBNS_TYPE_NBSTAT 0x0021
103#define NBNS_CLASS_INTERNET 0x00001
104#define NBNS_HEADER_SIZE (sizeof(WORD) * 6)
105#define NBNS_RESPONSE_AND_OPCODE 0xf800
106#define NBNS_RESPONSE_AND_QUERY 0x8000
107#define NBNS_REPLYCODE 0x0f
109#define NBSS_HDRSIZE 4
114#define NBSS_NACK 0x83
115#define NBSS_RETARGET 0x84
116#define NBSS_KEEPALIVE 0x85
118#define NBSS_ERR_NOT_LISTENING_ON_NAME 0x80
119#define NBSS_ERR_NOT_LISTENING_FOR_CALLER 0x81
120#define NBSS_ERR_BAD_NAME 0x82
121#define NBSS_ERR_INSUFFICIENT_RESOURCES 0x83
123#define NBSS_EXTENSION 0x01
245 sin.sin_addr.s_addr = destAddr;
258 if (
ret < 0 || bytesSent < wsaBuf.
len)
310 WORD respXID,
flags, queryCount, answerCount;
312 DWORD bytesReceived, recvFlags = 0;
314 fromsize =
sizeof(fromaddr);
327 if (
adapter->nameQueryXID != respXID)
346 WORD answerIndex = 0;
351 ptr -
buffer < bytesReceived && shouldContinue)
369 shouldContinue = answerCallback(
data, answerCount,
370 answerIndex,
ptr, rLen);
413 numAddresses++] = *(
const DWORD *)(rData + 2);
437 unsigned int queries;
447 for (queries = 0; queryData.
cacheEntry ==
NULL && queries < maxQueries;
471 return queryData.
ret;
514 TRACE(
"name %s, cacheEntry %p\n",
name, cacheEntry);
541 (*cacheEntry)->nbname[0] =
'*';
542 (*cacheEntry)->numAddresses = 1;
543 (*cacheEntry)->addresses[0] =
addr;
556 host->h_addr_list[
i];
i++)
558 if (
host->h_addr_list &&
host->h_addr_list[0])
566 (*cacheEntry)->nbname[0] =
'*';
567 (*cacheEntry)->numAddresses =
i;
568 for (
i = 0;
i < (*cacheEntry)->numAddresses;
i++)
569 (*cacheEntry)->addresses[
i] =
598 TRACE(
"adapter %p, ncb %p, cacheEntry %p\n",
adapter, ncb, cacheEntry);
654 bcastAddr |= ~adapter->ipr.dwMask;
668 *cacheEntry = newEntry;
691 if (
data && !
data->gotResponse && rData && rLen >= 1)
694 if (rLen >= rData[0] * (
NCBNAMSZ + 2))
701 data->astat->name_count = rData[0];
702 for (
i = 0,
src = rData + 1,
705 i < data->astat->name_count &&
src - rData < rLen &&
726 data->astat->adapter_type = 0xfe;
727 if (
src - rData < rLen)
729 min(rLen - (
src - rData), 6));
767 queryData.
astat = astat;
873 for (ndx = 0; ndx < spaceFor; ndx++)
889 if (spaceFor < cacheEntry->numAddresses)
900 const UCHAR *callingName)
904 unsigned int len = 0;
905 DWORD bytesSent, bytesReceived, recvFlags = 0;
922 ERR(
"send failed\n");
952 FIXME(
"Got a session retarget, can't deal\n");
1005 sizeof(
sin.sin_addr));
1016 static const UCHAR fakedCalledName[] =
"*SMBSERVER";
1017 const UCHAR *calledParty = cacheEntry->
nbname[0] ==
'*'
1018 ? fakedCalledName : cacheEntry->
nbname;
1023 FIXME(
"NBT session to \"*SMBSERVER\" refused,\n");
1024 FIXME(
"should try finding name using ASTAT\n");
1091 r =
WSASend(
session->fd, wsaBufs,
sizeof(wsaBufs) /
sizeof(wsaBufs[0]),
1098 else if (bytesSent < NBSS_HDRSIZE + ncb->ncb_length)
1100 FIXME(
"Only sent %d bytes (of %d), hanging up session\n", bytesSent,
1133 if (
session->bytesPending == 0)
1161 if (bufferCount == 2)
1166 FIXME(
"Oops, received a session keepalive and lost my place\n");
1176 FIXME(
"Received unexpected session msg type %d\n",
buffer[0]);
1186 FIXME(
"Received a message that's too long for my taste\n");
1202 if (bytesReceived < session->bytesPending)
1203 session->bytesPending -= bytesReceived;
1209 if (
session->bytesPending > 0)
1310 for (ndx = 0; !
ret && ndx <
table->dwNumEntries; ndx++)
1355 if (ipAddrs && coalesceTable)
1373 innerIndex < coalesceTable->
dwNumEntries; innerIndex++)
1409static const WCHAR VxD_MSTCPW[] = {
'S',
'Y',
'S',
'T',
'E',
'M',
'\\',
'C',
'u',
'r',
1410 'r',
'e',
'n',
't',
'C',
'o',
'n',
't',
'r',
'o',
'l',
'S',
'e',
't',
'\\',
'S',
'e',
'r',
'v',
1411 'i',
'c',
'e',
's',
'\\',
'V',
'x',
'D',
'\\',
'M',
'S',
'T',
'C',
'P',
'\0' };
1413 'r',
'r',
'e',
'n',
't',
'C',
'o',
'n',
't',
'r',
'o',
'l',
'S',
'e',
't',
'\\',
'S',
'e',
'r',
1414 'v',
'i',
'c',
'e',
's',
'\\',
'N',
'e',
't',
'B',
'T',
'\\',
'P',
'a',
'r',
'a',
'm',
'e',
't',
1418 'e',
'Q',
'u',
'e',
'r',
'y',
'C',
'o',
'u',
'n',
't',
'\0' };
1420 'e',
'Q',
'u',
'e',
'r',
'y',
'T',
'i',
'm',
'e',
'o',
'u',
't',
'\0' };
1422 'Q',
'u',
'e',
'r',
'y',
'C',
'o',
'u',
'n',
't',
'\0' };
1424 'Q',
'u',
'e',
'r',
'y',
'T',
'i',
'm',
'e',
'o',
'u',
't',
'\0' };
1426static const WCHAR CacheTimeoutW[] = {
'C',
'a',
'c',
'h',
'e',
'T',
'i',
'm',
'e',
'o',
1429 'W',
'i',
'n',
'e',
'\\',
'N',
'e',
't',
'w',
'o',
'r',
'k',
'\0' };
1460 size =
sizeof(dword);
1464 size =
sizeof(dword);
1469 size =
sizeof(dword);
1473 size =
sizeof(dword);
1478 size =
sizeof(dword);
1515 static const char *nsValueNames[] = {
"WinsServer",
"BackupWinsServer" };
1519 for (ndx = 0; ndx <
sizeof(nsValueNames) /
sizeof(nsValueNames[0]);
1522 size =
sizeof(nsString) /
sizeof(
char);
static INT adapt(INT delta, INT numpoints, BOOL firsttime)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
ACPI_SIZE strlen(const char *String)
CHAR FAR *WSAAPI inet_ntoa(IN IN_ADDR in)
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
#define RegCloseKey(hKey)
#define ERROR_INSUFFICIENT_BUFFER
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
#define HeapFree(x, y, z)
DWORD WINAPI GetTickCount(VOID)
void NetBIOSEnableAdapter(UCHAR lana)
BOOL NetBIOSRegisterAdapter(ULONG transport, DWORD ifIndex, void *data)
BOOL NetBIOSRegisterTransport(ULONG id, NetBIOSTransport *transport)
void NetBIOSHangupSession(const NCB *ncb)
void NetBIOSEnumAdapters(ULONG transport, NetBIOSEnumAdaptersCallback cb, void *closure)
INT WSAAPI WSARecvFrom(IN SOCKET s, IN OUT LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesRecvd, IN OUT LPDWORD lpFlags, OUT LPSOCKADDR lpFrom, IN OUT LPINT lpFromlen, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
INT WSAAPI WSARecv(IN SOCKET s, IN OUT LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesRecvd, IN OUT LPDWORD lpFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
INT WSAAPI WSASend(IN SOCKET s, IN LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesSent, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
INT WSAAPI WSASendTo(IN SOCKET s, IN LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesSent, IN DWORD dwFlags, IN CONST struct sockaddr *lpTo, IN INT iToLen, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum const GLvoid * addr
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl isalnum(_In_ int _C)
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
#define MIB_IF_TYPE_TOKENRING
struct _MIB_IPADDRROW MIB_IPADDRROW
struct _MIB_IPADDRTABLE MIB_IPADDRTABLE
#define MAX_DOMAIN_NAME_LEN
#define memcpy(s1, s2, n)
struct _ADAPTER_STATUS * PADAPTER_STATUS
struct _FIND_NAME_BUFFER * PFIND_NAME_BUFFER
struct _FIND_NAME_HEADER * PFIND_NAME_HEADER
struct _FIND_NAME_HEADER FIND_NAME_HEADER
BOOL NBNameCacheAddEntry(struct NBNameCache *cache, NBNameCacheEntry *entry)
void NBNameCacheDestroy(struct NBNameCache *cache)
struct NBNameCache * NBNameCacheCreate(HANDLE heap, DWORD entryExpireTimeMS)
const NBNameCacheEntry * NBNameCacheFindEntry(struct NBNameCache *cache, const UCHAR name[NCBNAMSZ])
#define WINS_QUERY_TIMEOUT
struct _NetBTNameQueryData NetBTNameQueryData
static int NetBTSendNameQuery(SOCKET fd, const UCHAR name[NCBNAMSZ], WORD xid, WORD qtype, DWORD destAddr, BOOL broadcast)
static BOOL NetBTEnumCallback(UCHAR totalLANAs, UCHAR lanaIndex, ULONG transport, const NetBIOSAdapterImpl *data, void *closure)
static const WCHAR BcastNameQueryTimeoutW[]
static char gScopeID[MAX_SCOPE_ID_LEN]
static UCHAR NetBTRegisterAdapter(const MIB_IPADDRROW *ipRow)
static const WCHAR ScopeIDW[]
static UCHAR NetBTAstatRemote(NetBTAdapter *adapter, PNCB ncb)
struct _NetBTAdapter NetBTAdapter
static UCHAR NetBTRecv(void *adapt, void *sess, PNCB ncb)
static const WCHAR BcastNameQueryCountW[]
static const WCHAR Config_NetworkW[]
static DWORD gBCastQueries
static DWORD NetBTNameReq(const UCHAR name[NCBNAMSZ], WORD xid, WORD qtype, BOOL broadcast, UCHAR *buffer, int len)
static UCHAR NetBTEnum(void)
static UCHAR NetBTNameWaitLoop(const NetBTAdapter *adapter, SOCKET fd, const NCB *ncb, DWORD sendTo, BOOL broadcast, DWORD timeout, DWORD maxQueries, NBNameCacheEntry **cacheEntry)
static DWORD gWINSQueryTimeout
static DWORD gCacheTimeout
static struct NBNameCache * gNameCache
static UCHAR NetBTInternalFindName(NetBTAdapter *adapter, PNCB ncb, const NBNameCacheEntry **cacheEntry)
static const WCHAR NameSrvQueryCountW[]
static UCHAR NetBTFindName(void *adapt, PNCB ncb)
static BOOL NetBTFindNameAnswerCallback(void *pVoid, WORD answerCount, WORD answerIndex, PUCHAR rData, WORD rLen)
static UCHAR NetBTHangup(void *adapt, void *sess)
static const WCHAR VxD_MSTCPW[]
static DWORD gBCastQueryTimeout
static const WCHAR EnableDNSW[]
static DWORD gWINSQueries
static UCHAR NetBTinetResolve(const UCHAR name[NCBNAMSZ], NBNameCacheEntry **cacheEntry)
#define MIN_CACHE_TIMEOUT
#define BCAST_QUERY_TIMEOUT
static UCHAR NetBTStoreCacheEntry(struct NBNameCache **nameCache, NBNameCacheEntry *cacheEntry)
static UCHAR NetBTCall(void *adapt, PNCB ncb, void **sess)
static const WCHAR NetBT_ParametersW[]
static ULONG gTransportID
static UCHAR NetBTSessionReq(SOCKET fd, const UCHAR *calledName, const UCHAR *callingName)
#define NBSS_ERR_INSUFFICIENT_RESOURCES
#define MIN_QUERY_TIMEOUT
static void NetBTCleanup(void)
static int NetBTNameEncode(const UCHAR *p, UCHAR *buffer)
static DWORD gWINSServers[MAX_WINS_SERVERS]
static void NetBTCleanupAdapter(void *adapt)
#define SIMPLE_NAME_QUERY_PKT_SIZE
static UCHAR NetBTSend(void *adapt, void *sess, PNCB ncb)
static int gNumWINSServers
struct _NetBTNodeQueryData NetBTNodeQueryData
#define NBNS_RESPONSE_AND_OPCODE
static UCHAR NetBTWaitForNameResponse(const NetBTAdapter *adapter, SOCKET fd, DWORD waitUntil, NetBTAnswerCallback answerCallback, void *data)
#define NBNS_CLASS_INTERNET
struct _NetBTSession NetBTSession
BOOL(* NetBTAnswerCallback)(void *data, WORD answerCount, WORD answerIndex, PUCHAR rData, WORD rdLength)
#define NBR_ADDWORD(p, word)
#define NBNS_RESPONSE_AND_QUERY
static const WCHAR NameSrvQueryTimeoutW[]
static const WCHAR CacheTimeoutW[]
static BOOL NetBTNodeStatusAnswerCallback(void *pVoid, WORD answerCount, WORD answerIndex, PUCHAR rData, WORD rLen)
static UCHAR NetBTAstat(void *adapt, PNCB ncb)
#define NCB_CANCELLED(pncb)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
SOCKET WSAAPI WSASocketA(IN INT af, IN INT type, IN INT protocol, IN LPWSAPROTOCOL_INFOA lpProtocolInfo, IN GROUP g, IN DWORD dwFlags)
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
PCRITICAL_SECTION_DEBUG DebugInfo
UCHAR destination_addr[6]
UCHAR bPhysAddr[MAXLEN_PHYSADDR]
UCHAR ncb_callname[NCBNAMSZ]
NetBIOSCleanupAdapter cleanupAdapter
struct NBNameCache * nameCache
NBNameCacheEntry * cacheEntry
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
static const u8_t broadcast[6]
#define FIELD_OFFSET(t, f)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_USER
#define WSA_FLAG_OVERLAPPED
int PASCAL FAR WSAGetLastError(void)