ReactOS 0.4.15-dev-8191-gbc6c731
netbios.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Service Host
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: base/services/svchost/netbios.c
5 * PURPOSE: NetBIOS Service Support
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "svchost.h"
12
13#include <lmerr.h>
14#include <nb30.h>
15
16/* GLOBALS *******************************************************************/
17
21
22/* FUNCTIONS *****************************************************************/
23
27 _In_ DWORD NetBiosError
28 )
29{
30 /* Convert from one status to another */
31 switch (NetBiosError)
32 {
33 case NRC_GOODRET:
34 return NERR_Success;
35 case NRC_INUSE:
36 case NRC_NAMCONF:
37 return NERR_DuplicateName;
38 case NRC_NOWILD:
39 case NRC_NAMERR:
41 case NRC_NOCALL:
42 return NERR_NameNotFound;
43 case NRC_NORES:
45 case NRC_DUPNAME:
46 return NERR_AlreadyExists;
47 case NRC_NAMTFUL:
48 return NERR_TooManyNames;
49 case NRC_ACTSES:
50 return NERR_DeleteLater;
51 case NRC_REMTFUL:
52 return ERROR_REM_NOT_LIST;
53 default:
54 return NERR_NetworkError;
55 }
56}
57
58BOOL
61 _In_ UCHAR Lana
62 )
63{
64 DWORD i = Lana / 32;
65
66 /* Clear the flag for this LANA */
67 return (i <= 7) ? LanaFlags[i] & (1 << (Lana - 32 * i)) : FALSE;
68}
69
70VOID
73 _In_ UCHAR Lana
74 )
75{
76 DWORD i = Lana / 32;
77
78 /* Set the flag for this LANA */
79 if (i <= 7) LanaFlags[i] |= 1 << (Lana - 32 * i);
80}
81
82VOID
85 VOID
86 )
87{
88 /* Initialize NetBIOS-related structures and variables */
92}
93
94VOID
97 VOID
98 )
99{
100 /* While holding the lock, drop a reference*/
102 if ((GlobalNetBiosUseCount != 0) && (--GlobalNetBiosUseCount == 0))
103 {
104 /* All references are gone, clear all LANA's */
106 }
108}
109
110VOID
111WINAPI
113 VOID
114 )
115{
116 /* Increment the reference counter while holding the lock */
120}
121
122DWORD
123WINAPI
125 _In_ UCHAR LanaNum
126 )
127{
128 DWORD dwError = ERROR_SUCCESS;
129 UCHAR nbtError;
130 NCB ncb;
131
132 /* Block all other NetBIOS operations */
134
135 /* Is this LANA enabled? */
136 if (!LanaFlagIsSet(LanaNum))
137 {
138 /* Yep, build a reset packet */
139 ZeroMemory(&ncb, sizeof(ncb));
140 ncb.ncb_lsn = 0;
141 ncb.ncb_command = NCBRESET;
142 ncb.ncb_callname[0] = 0xFE; // Max Sessions
143 ncb.ncb_callname[1] = 0;
144 ncb.ncb_callname[2] = 0xFD; // Max Names
145 ncb.ncb_callname[3] = 0;
146 ncb.ncb_lana_num = LanaNum;
147
148 /* Send it */
149 nbtError = Netbios(&ncb);
150
151 /* Convert the status to Win32 format */
152 dwError = SvcNetBiosStatusToApiStatus(nbtError);
153
154 /* Enable the LANA if the reset worked */
155 if (dwError == ERROR_SUCCESS) SetLanaFlag(LanaNum);
156 }
157
158 /* Drop the lock and return */
160 return dwError;
161}
DWORD WINAPI SvcNetBiosReset(_In_ UCHAR LanaNum)
Definition: netbios.c:124
DWORD LanaFlags[8]
Definition: netbios.c:19
LONG GlobalNetBiosUseCount
Definition: netbios.c:18
BOOL WINAPI LanaFlagIsSet(_In_ UCHAR Lana)
Definition: netbios.c:60
VOID WINAPI SvcNetBiosClose(VOID)
Definition: netbios.c:96
VOID WINAPI SvcNetBiosOpen(VOID)
Definition: netbios.c:112
DWORD WINAPI SvcNetBiosStatusToApiStatus(_In_ DWORD NetBiosError)
Definition: netbios.c:26
CRITICAL_SECTION SvcNetBiosCritSec
Definition: netbios.c:20
VOID WINAPI SvcNetBiosInit(VOID)
Definition: netbios.c:84
VOID WINAPI SetLanaFlag(_In_ UCHAR Lana)
Definition: netbios.c:72
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
UCHAR WINAPI Netbios(PNCB ncb)
Definition: netbios.c:785
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
Definition: glfuncs.h:248
#define NERR_Success
Definition: lmerr.h:5
#define NERR_TooManyNames
Definition: lmerr.h:127
#define NERR_NameNotFound
Definition: lmerr.h:123
#define NERR_DeleteLater
Definition: lmerr.h:143
#define NERR_DuplicateName
Definition: lmerr.h:142
#define NERR_AlreadyExists
Definition: lmerr.h:126
#define NERR_NetworkError
Definition: lmerr.h:24
#define NERR_NoNetworkResource
Definition: lmerr.h:10
#define _In_
Definition: ms_sal.h:308
#define NRC_ACTSES
Definition: nb30.h:64
#define NRC_REMTFUL
Definition: nb30.h:66
#define NRC_DUPNAME
Definition: nb30.h:62
#define NRC_NOWILD
Definition: nb30.h:69
#define NRC_GOODRET
Definition: nb30.h:52
#define NRC_INUSE
Definition: nb30.h:70
#define NRC_NAMERR
Definition: nb30.h:71
#define NCBRESET
Definition: nb30.h:38
#define NRC_NAMCONF
Definition: nb30.h:73
#define NRC_NOCALL
Definition: nb30.h:68
#define NRC_NAMTFUL
Definition: nb30.h:63
#define NRC_NORES
Definition: nb30.h:59
long LONG
Definition: pedump.c:60
Definition: nb30.h:148
UCHAR ncb_lana_num
Definition: nb30.h:160
UCHAR ncb_callname[NCBNAMSZ]
Definition: nb30.h:155
UCHAR ncb_command
Definition: nb30.h:149
UCHAR ncb_lsn
Definition: nb30.h:151
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define ZeroMemory
Definition: winbase.h:1712
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WINAPI
Definition: msvc.h:6
#define ERROR_REM_NOT_LIST
Definition: winerror.h:143
unsigned char UCHAR
Definition: xmlstorage.h:181