- Timestamp:
- Mar 8, 2002, 12:37:56 PM (23 years ago)
- Location:
- trunk/src/wnetap32
- Files:
-
- 2 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wnetap32/makefile
r6676 r8052 1 # $Id: makefile,v 1. 19 2001-09-07 08:20:58 phallerExp $1 # $Id: makefile,v 1.20 2002-03-08 11:37:10 sandervl Exp $ 2 2 3 3 # … … 42 42 $(ODIN32_LIB)/user32.lib \ 43 43 $(ODIN32_LIB)/$(ODINCRT).lib \ 44 netapi32.lib \ 44 45 OS2386.LIB \ 45 46 $(RTLLIB_O) … … 47 48 48 49 # 49 # Target and original target names - names of the dll without exten tion and path50 # Target and original target names - names of the dll without extension and path 50 51 # 52 # @@@PH TARGET = wnetap32 53 # @@@PH ORGTARGET = netapi32 51 54 TARGET = wnetap32 52 ORGTARGET = netapi3253 54 55 55 56 # -
trunk/src/wnetap32/oslibnet.cpp
r6672 r8052 1 /* $Id: oslibnet.cpp,v 1. 5 2001-09-06 22:23:40 phallerExp $1 /* $Id: oslibnet.cpp,v 1.6 2002-03-08 11:37:10 sandervl Exp $ 2 2 * 3 3 * Wrappers for OS/2 Netbios/Network/LAN API … … 30 30 #include <netstats.h> 31 31 #include <server.h> 32 #include <ncb.h> 33 #include <netbios.h> 34 // #include <netb_1_c.h> 35 // #include <netb_2_c.h> 36 // #include <netb_4_c.h> 37 38 #include "wnetap32.h" 39 #include "oslibnet.h" 32 40 33 41 … … 301 309 return rc; 302 310 } 311 312 313 /***************************************************************************** 314 * Name : OSLibNetBIOS 315 * Purpose : 316 * Parameters: PNCB pncb (Win32-style of the structure!!!) 317 * Variables : 318 * Result : 319 * Remark : 320 * Status : TESTED 321 * 322 * Author : Patrick Haller 2002/02/26 01:42 323 *****************************************************************************/ 324 325 UCHAR OSLibNetBIOS_Passthru(PNCB_w pncb) 326 { 327 // IBM NETBIOS 3.0 as defined in ncb.h 328 // UCHAR rc = NetBios( (struct ncb LSFAR *)pncb ); 329 330 // Note: 331 // asynchronous operation probably not really supported here, 332 // this has to be done with a wrapper thread! 333 334 // @@@PH 335 // open / close the right adapter based upon 336 // the LANA number specified inside the NCB 337 338 USHORT sel = RestoreOS2FS(); 339 UCHAR rc = NetBios32Submit(0, // send automatically to first adapter 340 // open & close are implicit 341 0, // single NCB w/o error retry! 342 (struct ncb LSFAR *)pncb ); 343 SetFS(sel); 344 return rc; 345 } 346 347 348 /***************************************************************************** 349 * Name : OSLibNetBIOSEnum 350 * Purpose : 351 * Parameters: PNCB pncb (Win32-style of the structure!!!) 352 * Variables : 353 * Result : 354 * Remark : 355 * Status : TESTED 356 * 357 * Author : Patrick Haller 2002/02/26 01:42 358 *****************************************************************************/ 359 360 UCHAR OSLibNetBIOS_Enum(PNCB_w pncb) 361 { 362 static BOOL flagEnumAvailable = FALSE; 363 static UCHAR arrLANA[ MAX_LANA_w ]; 364 static int iLANALength = 0; 365 USHORT sel = RestoreOS2FS(); 366 367 if (FALSE == flagEnumAvailable) 368 { 369 ULONG ulEntriesReturned = 0; 370 ULONG ulEntriesAvailable = 0; 371 ULONG rc; 372 PVOID pBuffer; 373 ULONG ulBufferLength; 374 struct netbios_info_1* pNBI1; 375 376 // reset the array first 377 memset( arrLANA, 0, sizeof( arrLANA ) ); 378 379 380 // determine number of available entries 381 rc = NetBios32Enum(NULL, 382 0, 383 NULL, 384 0, 385 &ulEntriesReturned, 386 &ulEntriesAvailable); 387 388 // if network adapters are available ... 389 iLANALength = ulEntriesAvailable; 390 if (0 != ulEntriesAvailable) 391 { 392 // allocate buffer of sufficient size 393 ulBufferLength = ulEntriesAvailable * sizeof( struct netbios_info_1 ); 394 pBuffer = malloc( ulBufferLength ); 395 if (NULL == pBuffer) 396 { 397 SetFS(sel); 398 pncb->ncb_retcode = NRC_SYSTEM_w; 399 return NRC_SYSTEM_w; 400 } 401 402 // enumerate all network drivers (net1, net2, ...) 403 // and build the array of LANA numbers 404 rc = NetBios32Enum(NULL, // local machine 405 1, 406 (PUCHAR)pBuffer, 407 ulBufferLength, 408 &ulEntriesReturned, 409 &ulEntriesAvailable); 410 pNBI1 = (struct netbios_info_1 *)pBuffer; 411 for (ULONG ulCount = 0; 412 ulCount < ulEntriesReturned; 413 ulCount++) 414 { 415 arrLANA[ ulCount ] = pNBI1->nb1_lana_num; 416 pNBI1++; 417 } 418 419 free( pBuffer ); 420 } 421 // else no network adapters are available 422 423 flagEnumAvailable = TRUE; 424 } 425 426 // copy the result 427 PLANA_ENUM_w pLE = (PLANA_ENUM_w)pncb->ncb_buffer; 428 pLE->length = iLANALength; 429 430 // compensate UCHAR size for the length field 431 memcpy( pLE->lana, 432 arrLANA, 433 pncb->ncb_length - sizeof(UCHAR) ); 434 pncb->ncb_retcode = NRC_GOODRET_w; 435 436 SetFS(sel); 437 return pncb->ncb_retcode; 438 } 439 440 441 442 443 /***************************************************************************** 444 * Name : OSLibNetBIOS 445 * Purpose : 446 * Parameters: PNCB pncb (Win32-style of the structure!!!) 447 * Variables : 448 * Result : 449 * Remark : this is for synchronous operation only! 450 * Status : TESTED 451 * 452 * Author : Patrick Haller 2002/02/26 01:42 453 *****************************************************************************/ 454 455 UCHAR OSLibNetBIOS(PNCB_w pncb) 456 { 457 dprintf(("NETBIOS: Netbios NCB: command=%02xh, retcode=%d, lsn=%d, num=%d, buffer=%08xh, " 458 "length=%d callname='%s' name='%s' rto=%d sto=%d pfnCallback=%08xh, lana=%d, " 459 "cmd_cplt=%d event=%08xh\n", 460 pncb->ncb_command, 461 pncb->ncb_retcode, 462 pncb->ncb_lsn, 463 pncb->ncb_num, 464 pncb->ncb_buffer, 465 pncb->ncb_length, 466 pncb->ncb_callname, 467 pncb->ncb_name, 468 pncb->ncb_rto, 469 pncb->ncb_sto, 470 pncb->ncb_post, 471 pncb->ncb_lana_num, 472 pncb->ncb_cmd_cplt, 473 pncb->ncb_event)); 474 475 // Request Router 476 // The request router is responsible for mapping the incoming commands 477 // and NCBs to their OS/2 NetBIOS pendant plus support of synchronous / 478 // asynchronous handling of NCB processing. 479 480 // Note: 481 // for a first attempt at NetBIOS support, we just try to pass through 482 // all supported commands and assume the structures are essentially 483 // compatible. 484 UCHAR rc; 485 486 switch (pncb->ncb_command & ~ASYNCH_w) 487 { 488 case NCBENUM_w: 489 { 490 // enumerate all network drivers (net1, net2, ...) 491 // and build the array of LANA numbers 492 rc = OSLibNetBIOS_Enum( pncb ); 493 break; 494 } 495 496 // Note: NCBLANSTALERT_w 497 // seems to be supported in asynchronous manner only, 498 // we just try to pass it through! 499 500 case NCBACTION_w: 501 dprintf(("NCBACTION not yet implemented")); 502 break; 503 504 case NCBTRACE_w: 505 dprintf(("NCBTRACE not yet implemented")); 506 break; 507 508 case NCBRESET_w: 509 // This seems to cause the requester to go wild 510 // (netbios session limit exceeded) 511 // rc = OSLibNetBIOS_Passthru( pncb ); 512 513 // Win32 and OS/2 do have different behaviour upon RESET calls. 514 // Returning OK here is experimental. 515 pncb->ncb_retcode = NRC_GOODRET_w; 516 pncb->ncb_cmd_cplt = NRC_GOODRET_w; 517 rc = NRC_GOODRET_w; 518 break; 519 520 521 default: 522 rc = OSLibNetBIOS_Passthru( pncb ); 523 break; 524 } 525 526 dprintf(("NETBIOS: Netbios NCB: command=%02xh --> rc=%d\n", 527 pncb->ncb_command, 528 rc)); 529 return rc; 530 } 531 532 533 /***************************************************************************** 534 * Name : 535 * Purpose : 536 * Parameters: PNCB pncb (Win32-style of the structure!!!) 537 * Variables : 538 * Result : 539 * Remark : 540 * Status : TESTED 541 * 542 * Author : Patrick Haller 2002/02/26 01:42 543 *****************************************************************************/ 544 545 DWORD WIN32API OSLibNetbiosHlpHandler(LPVOID lpParam) 546 { 547 PNCB_w pncb = (PNCB_w)lpParam; 548 UCHAR ncb_cmd_original = pncb->ncb_command; 549 void (* CALLBACK ncb_post_original)( struct _NCB_w * ) = pncb->ncb_post; 550 551 // rewrite ncb for synchronous operation 552 pncb->ncb_command &= ~ASYNCH_w; 553 pncb->ncb_post = 0; 554 // ncb_cmd_cplt is expected to be NRC_PENDING_w 555 // when we come here (set by the main Netbios() function) 556 557 // synchronous operation 558 // return code is expected to be stored inside pncb 559 dprintf(("NETBIOS: async NETBIOS for command %02xh\n", 560 pncb->ncb_command)); 561 562 OSLibNetBIOS( pncb ); 563 564 dprintf(("NETBIOS: async NETBIOS for command %02xh returned %d\n", 565 pncb->ncb_command, 566 pncb->ncb_retcode)); 567 568 // restore original command 569 pncb->ncb_command = ncb_cmd_original; 570 pncb->ncb_post = ncb_post_original; 571 572 // propagate the command complete value as netbios is expected 573 // to do for asynchronous operation 574 pncb->ncb_cmd_cplt= pncb->ncb_retcode; 575 576 // perform post-operation notification! 577 if (pncb->ncb_event) 578 { 579 // Netbios seems to use PulseEvent instead of SetEvent. 580 581 // SetEvent( pncb->ncb_event ); 582 PulseEvent( pncb->ncb_event ); 583 } 584 585 if (pncb->ncb_post != NULL) 586 { 587 // callback into post function 588 (pncb->ncb_post)( pncb ); 589 } 590 591 return pncb->ncb_retcode; 592 } -
trunk/src/wnetap32/oslibnet.h
r6672 r8052 1 /* $Id: oslibnet.h,v 1. 3 2001-09-06 22:23:40 phallerExp $ */1 /* $Id: oslibnet.h,v 1.4 2002-03-08 11:37:10 sandervl Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Netbios/Network/LAN API … … 17 17 18 18 #define NERR_OK 0 19 20 #ifndef NERR_BASE 19 21 #define NERR_BASE 1 /* @@@PH DUMMY ! */ 22 #endif 20 23 21 24 -
trunk/src/wnetap32/wnetap32.cpp
r6676 r8052 1 /* $Id: wnetap32.cpp,v 1.1 6 2001-09-07 08:20:59 phallerExp $ */1 /* $Id: wnetap32.cpp,v 1.17 2002-03-08 11:37:10 sandervl Exp $ */ 2 2 3 3 /* … … 38 38 #include <winconst.h> 39 39 40 #include "wnetap32.h" 41 #include "lanman.h" 40 42 #include "oslibnet.h" 41 #include "lanman.h"42 43 43 44 ODINDEBUGCHANNEL(WNETAP32-WNETAP32) 45 46 47 extern DWORD WIN32API OSLibNetbiosHlpHandler(LPVOID lpParam); 44 48 45 49 … … 48 52 ****************************************************************************/ 49 53 50 #define NCBNAMSZ 1651 #define MAX_LANA 25452 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 0x0072 #define NRC_BUFLEN 0x0173 #define NRC_ILLCMD 0x0374 #define NRC_CMDTMO 0x0575 #define NRC_INCOMP 0x0676 #define NRC_BADDR 0x0777 #define NRC_SNUMOUT 0x0878 #define NRC_NORES 0x0979 #define NRC_SCLOSED 0x0a80 #define NRC_CMDCAN 0x0b81 #define NRC_DUPNAME 0x0d82 #define NRC_NAMTFUL 0x0e83 #define NRC_ACTSES 0x0f84 #define NRC_LOCTFUL 0x1185 #define NRC_REMTFUL 0x1286 #define NRC_ILLNN 0x1387 #define NRC_NOCALL 0x1488 #define NRC_NOWILD 0x1589 #define NRC_INUSE 0x1690 #define NRC_NAMERR 0x1791 #define NRC_SABORT 0x1892 #define NRC_NAMCONF 0x1993 #define NRC_IFBUSY 0x2194 #define NRC_TOOMANY 0x2295 #define NRC_BRIDGE 0x2396 #define NRC_CANOCCR 0x2497 #define NRC_CANCEL 0x2698 #define NRC_DUPENV 0x3099 #define NRC_ENVNOTDEF 0x34100 #define NRC_OSRESNOTAV 0x35101 #define NRC_MAXAPPS 0x36102 #define NRC_NOSAPS 0x37103 #define NRC_NORESOURCES 0x38104 #define NRC_INVADDRESS 0x39105 #define NRC_INVDDID 0x3B106 #define NRC_LOCKFAIL 0x3C107 #define NRC_OPENERR 0x3f108 #define NRC_SYSTEM 0x40109 110 #define NRC_PENDING 0xff111 112 54 113 55 //****************************************************************************** 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. 114 61 //****************************************************************************** 62 //#define NETBIOS_ENABLED 115 63 ODINFUNCTION1(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 125 151 126 152 /***************************************************************************** … … 1073 1099 * Name : NET_API_STATUS I_NetPathType 1074 1100 * Purpose : 1101 1075 1102 * Parameters: wrong 1076 1103 * Variables : … … 1096 1123 /***************************************************************************** 1097 1124 * Name : NET_API_STATUS NetapipBufferAllocate 1125 1098 1126 * Purpose : 1099 1127 * Parameters: wrong
Note:
See TracChangeset
for help on using the changeset viewer.