home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / wsnetbs.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  2KB  |  70 lines

  1. /*
  2.  *   wsnetbs.h
  3.  *   Copyright 1994 - 1998 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.  
  11. #ifndef _WSNETBS_
  12. #define _WSNETBS_
  13.  
  14. /*
  15.  *   This is the structure of the SOCKADDR structure for NETBIOS.
  16.  *
  17.  */
  18.  
  19. #define NETBIOS_NAME_LENGTH 16
  20.  
  21. typedef struct sockaddr_nb {
  22.     short   snb_family;
  23.     u_short snb_type;
  24.     char    snb_name[NETBIOS_NAME_LENGTH];
  25. } SOCKADDR_NB, *PSOCKADDR_NB,FAR *LPSOCKADDR_NB;
  26.  
  27. /*
  28.  * Bit values for the snb_type field of SOCKADDR_NB.
  29.  *
  30.  */
  31.  
  32. #define NETBIOS_UNIQUE_NAME         (0x0000)
  33. #define NETBIOS_GROUP_NAME          (0x0001)
  34. #define NETBIOS_TYPE_QUICK_UNIQUE   (0x0002)
  35. #define NETBIOS_TYPE_QUICK_GROUP    (0x0003)
  36.  
  37. /*
  38.  * A macro convenient for setting up NETBIOS SOCKADDRs.
  39.  *
  40.  */
  41.  
  42. #define SET_NETBIOS_SOCKADDR(_snb,_type,_name,_port)                          \
  43.     {                                                                         \
  44.         int _i;                                                               \
  45.         (_snb)->snb_family = AF_NETBIOS;                                      \
  46.         (_snb)->snb_type = (_type);                                           \
  47.         for (_i=0; _i<NETBIOS_NAME_LENGTH-1; _i++) {                          \
  48.             (_snb)->snb_name[_i] = ' ';                                       \
  49.         }                                                                     \
  50.         for (_i=0; *((_name)+_i) != '\0' && _i<NETBIOS_NAME_LENGTH-1; _i++) { \
  51.             (_snb)->snb_name[_i] = *((_name)+_i);                             \
  52.         }                                                                     \
  53.         (_snb)->snb_name[NETBIOS_NAME_LENGTH-1] = (_port);                    \
  54.     }
  55.  
  56. /*
  57.  *   To open a NetBIOS socket, call the socket() function as follows:
  58.  *
  59.  *       s = socket( AF_NETBIOS, {SOCK_SEQPACKET|SOCK_DGRAM}, -Lana );
  60.  *
  61.  *   where Lana is the NetBIOS Lana number of interest.  For example, to
  62.  *   open a socket for Lana 2, specify -2 as the "protocol" parameter
  63.  *   to the socket() function.
  64.  *
  65.  */
  66.  
  67.  
  68. #endif
  69.  
  70.