Ignore:
Timestamp:
Mar 8, 2002, 12:37:56 PM (24 years ago)
Author:
sandervl
Message:

PH: Netbios updates (currently disabled)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wnetap32/wnetap32.cpp

    r6676 r8052  
    1 /* $Id: wnetap32.cpp,v 1.16 2001-09-07 08:20:59 phaller Exp $ */
     1/* $Id: wnetap32.cpp,v 1.17 2002-03-08 11:37:10 sandervl Exp $ */
    22
    33/*
     
    3838#include <winconst.h>
    3939
     40#include "wnetap32.h"
     41#include "lanman.h"
    4042#include "oslibnet.h"
    41 #include "lanman.h"
    4243
    4344ODINDEBUGCHANNEL(WNETAP32-WNETAP32)
     45
     46
     47extern DWORD WIN32API OSLibNetbiosHlpHandler(LPVOID lpParam);
    4448
    4549
     
    4852 ****************************************************************************/
    4953
    50 #define NCBNAMSZ        16
    51 #define MAX_LANA       254
    52 
    53 typedef struct _NCB {
    54     UCHAR   ncb_command;
    55     UCHAR   ncb_retcode;
    56     UCHAR   ncb_lsn;
    57     UCHAR   ncb_num;
    58     PUCHAR  ncb_buffer;
    59     WORD    ncb_length;
    60     UCHAR   ncb_callname[NCBNAMSZ];
    61     UCHAR   ncb_name[NCBNAMSZ];
    62     UCHAR   ncb_rto;
    63     UCHAR   ncb_sto;
    64     void (* CALLBACK ncb_post)( struct _NCB * );
    65     UCHAR   ncb_lana_num;
    66     UCHAR   ncb_cmd_cplt;
    67     UCHAR   ncb_reserve[10];
    68     HANDLE  ncb_event;
    69 } NCB, *PNCB;
    70 
    71 #define NRC_GOODRET     0x00
    72 #define NRC_BUFLEN      0x01
    73 #define NRC_ILLCMD      0x03
    74 #define NRC_CMDTMO      0x05
    75 #define NRC_INCOMP      0x06
    76 #define NRC_BADDR       0x07
    77 #define NRC_SNUMOUT     0x08
    78 #define NRC_NORES       0x09
    79 #define NRC_SCLOSED     0x0a
    80 #define NRC_CMDCAN      0x0b
    81 #define NRC_DUPNAME     0x0d
    82 #define NRC_NAMTFUL     0x0e
    83 #define NRC_ACTSES      0x0f
    84 #define NRC_LOCTFUL     0x11
    85 #define NRC_REMTFUL     0x12
    86 #define NRC_ILLNN       0x13
    87 #define NRC_NOCALL      0x14
    88 #define NRC_NOWILD      0x15
    89 #define NRC_INUSE       0x16
    90 #define NRC_NAMERR      0x17
    91 #define NRC_SABORT      0x18
    92 #define NRC_NAMCONF     0x19
    93 #define NRC_IFBUSY      0x21
    94 #define NRC_TOOMANY     0x22
    95 #define NRC_BRIDGE      0x23
    96 #define NRC_CANOCCR     0x24
    97 #define NRC_CANCEL      0x26
    98 #define NRC_DUPENV      0x30
    99 #define NRC_ENVNOTDEF   0x34
    100 #define NRC_OSRESNOTAV  0x35
    101 #define NRC_MAXAPPS     0x36
    102 #define NRC_NOSAPS      0x37
    103 #define NRC_NORESOURCES 0x38
    104 #define NRC_INVADDRESS  0x39
    105 #define NRC_INVDDID     0x3B
    106 #define NRC_LOCKFAIL    0x3C
    107 #define NRC_OPENERR     0x3f
    108 #define NRC_SYSTEM      0x40
    109 
    110 #define NRC_PENDING     0xff
    111 
    11254
    11355//******************************************************************************
     56// Note:
     57// The major difference between OS/2 and Win32 regarding NetBIOS is
     58// all operations and resources are per-process for Win32 and
     59// global for OS/2. So we might probably end up with stray netbios names etc.
     60// long after a process has vanished.
    11461//******************************************************************************
     62//#define NETBIOS_ENABLED
    11563ODINFUNCTION1(UCHAR, OS2Netbios,
    116               PNCB, pncb)
    117 {
    118 #ifdef DEBUG
    119   WriteLog("OS2Netbios; pretend no network available\n");
    120 #endif
    121   return(NRC_OPENERR);
    122 }
    123 //******************************************************************************
    124 //******************************************************************************
     64              PNCB_w, pncb)
     65{
     66#ifndef NETBIOS_ENABLED
     67  pncb->ncb_retcode = NRC_OPENERR_w;
     68  return pncb->ncb_retcode;
     69 
     70#else
     71  UCHAR rc;
     72
     73  // Note: OS/2 specific documentation is found in DSSPGR1+DSSPGR2
     74 
     75  // fork for asynchronous operation:
     76  if (pncb->ncb_command & ASYNCH_w)
     77  {
     78    // either event or post may be specified
     79    if ( (pncb->ncb_event != 0) &&
     80         (pncb->ncb_post  != 0) )
     81    {
     82      pncb->ncb_retcode = NRC_ILLCMD_w;
     83      return NRC_ILLCMD_w;
     84    }
     85   
     86   
     87    // @@@PH
     88    // we might go for one or more statically allocated
     89    // worker threads instead of creating and destroying
     90    // a thread for each single request.
     91   
     92    // we're to start an ODIN thread ourself and do
     93    // the operation itself synchronously!
     94   
     95    // say the netbios operation is still pending ...
     96    pncb->ncb_cmd_cplt = NRC_PENDING_w;
     97   
     98    UCHAR  ucCommand = pncb->ncb_command;
     99    DWORD  tidNetbios;
     100    HANDLE hNetbiosThread = CreateThread(NULL,
     101                                         0x8000,
     102                                         OSLibNetbiosHlpHandler,
     103                                         (LPVOID)pncb,
     104                                         0, // thread creation flags
     105                                         &tidNetbios);
     106    if (hNetbiosThread == NULL)
     107    {
     108      // in case the thread could not be launched,
     109      // return with error
     110      pncb->ncb_retcode  = NRC_SYSTEM_w;
     111      pncb->ncb_cmd_cplt = NRC_SYSTEM_w;
     112      return pncb->ncb_retcode;
     113    }
     114    else
     115    {
     116      dprintf(("NETBIOS: Netbios helper thread %d started for command %02xh\n",
     117               tidNetbios,
     118               ucCommand));
     119     
     120      // verify if the operation has completed already
     121      if (pncb->ncb_cmd_cplt != NRC_PENDING_w)
     122      {
     123        // Docs say in this case return as if the request was synchronous
     124        rc = pncb->ncb_retcode;
     125      }
     126      else
     127      {
     128        // this is the "operation pending" return code
     129        rc = 0;
     130      }
     131    }
     132  }
     133  else
     134  {
     135    // verify request
     136    if ( (pncb->ncb_event != 0) ||
     137         (pncb->ncb_post  != 0) )
     138    {
     139      pncb->ncb_retcode = NRC_ILLCMD_w;
     140      return NRC_ILLCMD_w;
     141    }
     142   
     143    // call the Request Router
     144    rc = OSLibNetBIOS( pncb );
     145  }
     146
     147  return( rc );
     148#endif /* NETBIOS_ENABLED */
     149}
     150
    125151
    126152/*****************************************************************************
     
    10731099 * Name      : NET_API_STATUS I_NetPathType
    10741100 * Purpose   :
     1101
    10751102 * Parameters: wrong
    10761103 * Variables :
     
    10961123/*****************************************************************************
    10971124 * Name      : NET_API_STATUS NetapipBufferAllocate
     1125
    10981126 * Purpose   :
    10991127 * Parameters: wrong
Note: See TracChangeset for help on using the changeset viewer.