WSnetbs.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /*
  2.  *   wsnetbs.h
  3.  *   Copyright (c) 1994-1999, Microsoft Corp. All rights reserved.
  4.  *
  5.  *   Windows Sockets include file for NETBIOS.  This file contains all
  6.  *   standardized NETBIOS information.  Include this header file after
  7.  *   winsock.h.
  8.  *
  9.  */
  10. #ifndef _WSNETBS_
  11. #define _WSNETBS_
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif
  15. /*
  16.  *   This is the structure of the SOCKADDR structure for NETBIOS.
  17.  *
  18.  */
  19. #define NETBIOS_NAME_LENGTH 16
  20. typedef struct sockaddr_nb {
  21.     short   snb_family;
  22.     u_short snb_type;
  23.     char    snb_name[NETBIOS_NAME_LENGTH];
  24. } SOCKADDR_NB, *PSOCKADDR_NB,FAR *LPSOCKADDR_NB;
  25. /*
  26.  * Bit values for the snb_type field of SOCKADDR_NB.
  27.  *
  28.  */
  29. #define NETBIOS_UNIQUE_NAME         (0x0000)
  30. #define NETBIOS_GROUP_NAME          (0x0001)
  31. #define NETBIOS_TYPE_QUICK_UNIQUE   (0x0002)
  32. #define NETBIOS_TYPE_QUICK_GROUP    (0x0003)
  33. /*
  34.  * A macro convenient for setting up NETBIOS SOCKADDRs.
  35.  *
  36.  */
  37. #define SET_NETBIOS_SOCKADDR(_snb,_type,_name,_port)                          
  38.     {                                                                         
  39.         int _i;                                                               
  40.         (_snb)->snb_family = AF_NETBIOS;                                      
  41.         (_snb)->snb_type = (_type);                                           
  42.         for (_i=0; _i<NETBIOS_NAME_LENGTH-1; _i++) {                          
  43.             (_snb)->snb_name[_i] = ' ';                                       
  44.         }                                                                     
  45.         for (_i=0; *((_name)+_i) != '' && _i<NETBIOS_NAME_LENGTH-1; _i++) { 
  46.             (_snb)->snb_name[_i] = *((_name)+_i);                             
  47.         }                                                                     
  48.         (_snb)->snb_name[NETBIOS_NAME_LENGTH-1] = (_port);                    
  49.     }
  50. /*
  51.  *   To open a NetBIOS socket, call the socket() function as follows:
  52.  *
  53.  *       s = socket( AF_NETBIOS, {SOCK_SEQPACKET|SOCK_DGRAM}, -Lana );
  54.  *
  55.  *   where Lana is the NetBIOS Lana number of interest.  For example, to
  56.  *   open a socket for Lana 2, specify -2 as the "protocol" parameter
  57.  *   to the socket() function.
  58.  *
  59.  */
  60. #endif