home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit 2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Texts / Rfc / RFC1002.TXT < prev    next >
Encoding:
Text File  |  1999-11-04  |  161.4 KB  |  5,099 lines

  1. Network Working Group
  2. Request for Comments: 1002                         March, 1987
  3.  
  4.  
  5.  
  6.  
  7.              PROTOCOL STANDARD FOR A NetBIOS SERVICE
  8.                      ON A TCP/UDP TRANSPORT:
  9.                      DETAILED SPECIFICATIONS
  10.  
  11.  
  12.  
  13.  
  14.                             ABSTRACT
  15.  
  16. This RFC defines a proposed standard protocol to support NetBIOS
  17. services in a TCP/IP environment.  Both local network and internet
  18. operation are supported.  Various node types are defined to accommodate
  19. local and internet topologies and to allow operation with or without the
  20. use of IP broadcast.
  21.  
  22. This RFC gives the detailed specifications of the NetBIOS-over-TCP
  23. packets, protocols, and defined constants and variables.  A more general
  24. overview is found in a companion RFC, "Protocol Standard For a NetBIOS
  25. Service on a TCP/UDP Transport: Concepts and Methods".
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. NetBIOS Working Group                                           [Page 1]
  56.  
  57.  
  58. RFC 1002                                                      March 1987
  59.  
  60.  
  61.                         TABLE OF CONTENTS
  62.  
  63.  
  64. 1.  STATUS OF THIS MEMO                                              4
  65.  
  66. 2.  ACKNOWLEDGEMENTS                                                 4
  67.  
  68. 3.  INTRODUCTION                                                     5
  69.  
  70. 4.  PACKET DESCRIPTIONS                                              5
  71.   4.1  NAME FORMAT                                                   5
  72.   4.2  NAME SERVICE PACKETS                                          7
  73.      4.2.1  GENERAL FORMAT OF NAME SERVICE PACKETS                   7
  74.        4.2.1.1  HEADER                                               8
  75.        4.2.1.2  QUESTION SECTION                                    10
  76.        4.2.1.3  RESOURCE RECORD                                     11
  77.      4.2.2  NAME REGISTRATION REQUEST                               13
  78.      4.2.3  NAME OVERWRITE REQUEST & DEMAND                         14
  79.      4.2.4  NAME REFRESH REQUEST                                    15
  80.      4.2.5  POSITIVE NAME REGISTRATION RESPONSE                     16
  81.      4.2.6  NEGATIVE NAME REGISTRATION RESPONSE                     16
  82.      4.2.7  END-NODE CHALLENGE REGISTRATION RESPONSE                17
  83.      4.2.8  NAME CONFLICT DEMAND                                    18
  84.      4.2.9  NAME RELEASE REQUEST & DEMAND                           19
  85.      4.2.10  POSITIVE NAME RELEASE RESPONSE                         20
  86.      4.2.11  NEGATIVE NAME RELEASE RESPONSE                         20
  87.      4.2.12  NAME QUERY REQUEST                                     21
  88.      4.2.13  POSITIVE NAME QUERY RESPONSE                           22
  89.      4.2.14  NEGATIVE NAME QUERY RESPONSE                           23
  90.      4.2.15  REDIRECT NAME QUERY RESPONSE                           24
  91.      4.2.16  WAIT FOR ACKNOWLEDGEMENT (WACK) RESPONSE               25
  92.      4.2.17  NODE STATUS REQUEST                                    26
  93.      4.2.18  NODE STATUS RESPONSE                                   27
  94.   4.3  SESSION SERVICE PACKETS                                      29
  95.      4.3.1  GENERAL FORMAT OF SESSION PACKETS                       29
  96.      4.3.2  SESSION REQUEST PACKET                                  30
  97.      4.3.3  POSITIVE SESSION RESPONSE PACKET                        31
  98.      4.3.4  NEGATIVE SESSION RESPONSE PACKET                        31
  99.      4.3.5  SESSION RETARGET RESPONSE PACKET                        31
  100.      4.3.6  SESSION MESSAGE PACKET                                  32
  101.      4.3.7  SESSION KEEP ALIVE PACKET                               32
  102.   4.4  DATAGRAM SERVICE PACKETS                                     32
  103.      4.4.1  NetBIOS DATAGRAM HEADER                                 32
  104.      4.4.2  DIRECT_UNIQUE, DIRECT_GROUP, & BROADCAST DATAGRAM       33
  105.      4.4.3  DATAGRAM ERROR PACKET                                   34
  106.      4.4.4  DATAGRAM QUERY REQUEST                                  34
  107.      4.4.5  DATAGRAM POSITIVE AND NEGATIVE QUERY RESPONSE           34
  108.  
  109. 5.  PROTOCOL DESCRIPTIONS                                           35
  110.   5.1  NAME SERVICE PROTOCOLS                                       35
  111.      5.1.1  B-NODE ACTIVITY                                         35
  112.  
  113.  
  114.  
  115. NetBIOS Working Group                                           [Page 2]
  116.  
  117.  
  118. RFC 1002                                                      March 1987
  119.  
  120.  
  121.        5.1.1.1  B-NODE ADD NAME                                     35
  122.        5.1.1.2  B-NODE ADD_GROUP NAME                               37
  123.        5.1.1.3  B-NODE FIND_NAME                                    37
  124.        5.1.1.4  B NODE NAME RELEASE                                 38
  125.        5.1.1.5  B-NODE INCOMING PACKET PROCESSING                   39
  126.      5.1.2  P-NODE ACTIVITY                                         42
  127.        5.1.2.1  P-NODE ADD_NAME                                     42
  128.        5.1.2.2  P-NODE ADD GROUP NAME                               45
  129.        5.1.2.3  P-NODE FIND NAME                                    45
  130.        5.1.2.4  P-NODE DELETE_NAME                                  46
  131.        5.1.2.5  P-NODE INCOMING PACKET PROCESSING                   47
  132.        5.1.2.6  P-NODE TIMER INITIATED PROCESSING                   49
  133.      5.1.3  M-NODE ACTIVITY                                         50
  134.        5.1.3.1  M-NODE ADD NAME                                     50
  135.        5.1.3.2  M-NODE ADD GROUP NAME                               54
  136.        5.1.3.3  M-NODE FIND NAME                                    55
  137.        5.1.3.4  M-NODE DELETE NAME                                  56
  138.        5.1.3.5  M-NODE INCOMING PACKET PROCESSING                   58
  139.        5.1.3.6  M-NODE TIMER INITIATED PROCESSING                   60
  140.      5.1.4  NBNS ACTIVITY                                           60
  141.        5.1.4.1  NBNS INCOMING PACKET PROCESSING                     61
  142.        5.1.4.2  NBNS TIMER INITIATED PROCESSING                     66
  143.   5.2  SESSION SERVICE PROTOCOLS                                    67
  144.      5.2.1  SESSION ESTABLISHMENT PROTOCOLS                         67
  145.        5.2.1.1  USER REQUEST PROCESSING                             67
  146.        5.2.1.2  RECEIVED PACKET PROCESSING                          71
  147.      5.2.2  SESSION DATA TRANSFER PROTOCOLS                         72
  148.        5.2.2.1  USER REQUEST PROCESSING                             72
  149.        5.2.2.2  RECEIVED PACKET PROCESSING                          72
  150.        5.2.2.3  PROCESSING INITIATED BY TIMER                       73
  151.      5.2.3  SESSION TERMINATION PROTOCOLS                           73
  152.        5.2.3.1  USER REQUEST PROCESSING                             73
  153.        5.2.3.2  RECEPTION INDICATION PROCESSING                     73
  154.   5.3  NetBIOS DATAGRAM SERVICE PROTOCOLS                           74
  155.      5.3.1  B NODE TRANSMISSION OF NetBIOS DATAGRAMS                74
  156.      5.3.2  P AND M NODE TRANSMISSION OF NetBIOS DATAGRAMS          76
  157.      5.3.3  RECEPTION OF NetBIOS DATAGRAMS BY ALL NODES             78
  158.      5.3.4  PROTOCOLS FOR THE NBDD                                  80
  159.  
  160. 6.  DEFINED CONSTANTS AND VARIABLES                                 83
  161.  
  162. REFERENCES                                                          85
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. NetBIOS Working Group                                           [Page 3]
  176.  
  177.  
  178. RFC 1002                                                      March 1987
  179.  
  180.  
  181.              PROTOCOL STANDARD FOR A NetBIOS SERVICE
  182.                      ON A TCP/UDP TRANSPORT:
  183.                      DETAILED SPECIFICATIONS
  184.  
  185.  
  186. 1.  STATUS OF THIS MEMO
  187.  
  188.    This RFC specifies a proposed standard for the DARPA Internet
  189.    community.  Since this topic is new to the Internet community,
  190.    discussions and suggestions are specifically requested.
  191.  
  192.    Please send written comments to:
  193.  
  194.            Karl Auerbach
  195.            Epilogue Technology Corporation
  196.            P.O. Box 5432
  197.            Redwood City, CA   94063
  198.  
  199.    Please send online comments to:
  200.  
  201.            Avnish Aggarwal
  202.                    Internet: mtxinu!excelan!avnish@ucbvax.berkeley.edu
  203.                    Usenet:   ucbvax!mtxinu!excelan!avnish
  204.  
  205.    Distribution of this memorandum is unlimited.
  206.  
  207. 2.  ACKNOWLEDGEMENTS
  208.  
  209.    This RFC has been developed under the auspices of the Internet
  210.    Activities Board.
  211.  
  212.    The following individuals have contributed to the development of
  213.    this RFC:
  214.  
  215.    Avnish Aggarwal       Arvind Agrawal        Lorenzo Aguilar
  216.    Geoffrey Arnold       Karl Auerbach         K. Ramesh Babu
  217.    Keith Ball            Amatzia Ben-Artzi     Vint Cerf
  218.    Richard Cherry        David Crocker         Steve Deering
  219.    Greg Ennis            Steve Holmgren        Jay Israel
  220.    David Kaufman         Lee LaBarre           James Lau
  221.    Dan Lynch             Gaylord Miyata        David Stevens
  222.    Steve Thomas          Ishan Wu
  223.  
  224.    The system proposed by this RFC does not reflect any existing
  225.    Netbios-over-TCP implementation.  However, the design
  226.    incorporates considerable knowledge obtained from prior
  227.    implementations.  Special thanks goes to the following
  228.    organizations which have provided this invaluable information:
  229.  
  230.    CMC/Syros      Excelan        Sytek          Ungermann-Bass
  231.  
  232.  
  233.  
  234.  
  235. NetBIOS Working Group                                           [Page 4]
  236.  
  237.  
  238. RFC 1002                                                      March 1987
  239.  
  240.  
  241. 3.  INTRODUCTION
  242.  
  243.    This RFC contains the detailed packet formats and protocol
  244.    specifications for NetBIOS-over-TCP.  This RFC is a companion to
  245.    RFC 1001, "Protocol Standard For a NetBIOS Service on a TCP/UDP
  246.    Transport: Concepts and Methods" [1].
  247.  
  248. 4.  PACKET DESCRIPTIONS
  249.  
  250.    Bit and byte ordering are defined by the most recent version of
  251.    "Assigned Numbers" [2].
  252.  
  253. 4.1.  NAME FORMAT
  254.  
  255.    The NetBIOS name representation in all NetBIOS packets (for NAME,
  256.    SESSION, and DATAGRAM services) is defined in the Domain Name
  257.    Service RFC 883[3] as "compressed" name messages.  This format is
  258.    called "second-level encoding" in the section entitled
  259.    "Representation of NetBIOS Names" in the Concepts and Methods
  260.    document.
  261.  
  262.    For ease of description, the first two paragraphs from page 31,
  263.    the section titled "Domain name representation and compression",
  264.    of RFC 883 are replicated here:
  265.  
  266.         Domain names messages are expressed in terms of a sequence
  267.         of labels.  Each label is represented as a one octet length
  268.         field followed by that number of octets.  Since every domain
  269.         name ends with the null label of the root, a compressed
  270.         domain name is terminated by a length byte of zero.  The
  271.         high order two bits of the length field must be zero, and
  272.         the remaining six bits of the length field limit the label
  273.         to 63 octets or less.
  274.  
  275.         To simplify implementations, the total length of label
  276.         octets and label length octets that make up a domain name is
  277.         restricted to 255 octets or less.
  278.  
  279.    The following is the uncompressed representation of the NetBIOS name
  280.    "FRED ", which is the 4 ASCII characters, F, R, E, D, followed by 12
  281.    space characters (0x20).  This name has the SCOPE_ID: "NETBIOS.COM"
  282.  
  283.            EGFCEFEECACACACACACACACACACACACA.NETBIOS.COM
  284.  
  285.    This uncompressed representation of names is called "first-level
  286.    encoding" in the section entitled "Representation of NetBIOS Names"
  287.    in the Concepts and Methods document.
  288.  
  289.    The following is a pictographic representation of the compressed
  290.    representation of the previous uncompressed Domain Name
  291.    representation.
  292.  
  293.  
  294.  
  295. NetBIOS Working Group                                           [Page 5]
  296.  
  297.  
  298. RFC 1002                                                      March 1987
  299.  
  300.  
  301.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  302.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  303.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  304.    |      0x20     |    E (0x45)   |    G (0x47)   |    F (0x46)   |
  305.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  306.    |    C (0x43)   |    E (0x45)   |    F (0x46)   |    E (0x45)   |
  307.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  308.    |    E (0x45)   |    C (0x43)   |    A (0x41)   |    C (0x43)   |
  309.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  310.    |    A (0x41)   |    C (0x43)   |    A (0x41)   |    C (0x43)   |
  311.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  312.    |    A (0x41)   |    C (0x43)   |    A (0x41)   |    C (0x43)   |
  313.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  314.    |    A (0x41)   |    C (0x43)   |    A (0x41)   |    C (0x43)   |
  315.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  316.    |    A (0x41)   |    C (0x43)   |    A (0x41)   |    C (0x43)   |
  317.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  318.    |    A (0x41)   |    C (0x43)   |    A (0x41)   |    C (0x43)   |
  319.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  320.    |    A (0X41)   |      0x07     |    N (0x4E)   |    E (0x45)   |
  321.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  322.    |    T (0x54)   |    B (0x42)   |    I (0x49)   |    O (0x4F)   |
  323.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  324.    |    S (0x53)   |      0x03     |    C (0x43)   |    O (0x4F)   |
  325.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  326.    |    M (0x4D)   |      0x00     |
  327.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  328.  
  329.    Each section of a domain name is called a label [7 (page 31)].  A
  330.    label can be a maximum of 63 bytes.  The first byte of a label in
  331.    compressed representation is the number of bytes in the label.  For
  332.    the above example, the first 0x20 is the number of bytes in the
  333.    left-most label, EGFCEFEECACACACACACACACACACACACA, of the domain
  334.    name.  The bytes following the label length count are the characters
  335.    of the label.  The following labels are in sequence after the first
  336.    label, which is the encoded NetBIOS name, until a zero (0x00) length
  337.    count.  The zero length count represents the root label, which is
  338.    always null.
  339.  
  340.    A label length count is actually a 6-bit field in the label length
  341.    field.  The most significant 2 bits of the field, bits 7 and 6, are
  342.    flags allowing an escape from the above compressed representation.
  343.    If bits 7 and 6 are both set (11), the following 14 bits are an
  344.    offset pointer into the full message to the actual label string from
  345.    another domain name that belongs in this name.  This label pointer
  346.    allows for a further compression of a domain name in a packet.
  347.  
  348.    NetBIOS implementations can only use label string pointers in Name
  349.    Service packets.  They cannot be used in Session or Datagram Service
  350.    packets.
  351.  
  352.  
  353.  
  354.  
  355. NetBIOS Working Group                                           [Page 6]
  356.  
  357.  
  358. RFC 1002                                                      March 1987
  359.  
  360.  
  361.    The other two possible values for bits 7 and 6 (01 and 10) of a label
  362.    length field are reserved for future use by RFC 883[2 (page 32)].
  363.  
  364.    Note that the first octet of a compressed name must contain one of
  365.    the following bit patterns.  (An "x" indicates a bit whose value may
  366.    be either 0 or 1.):
  367.  
  368.            00100000 -  Netbios name, length must be 32 (decimal)
  369.            11xxxxxx -  Label string pointer
  370.            10xxxxxx -  Reserved
  371.            01xxxxxx -  Reserved
  372.  
  373. 4.2.  NAME SERVICE PACKETS
  374.  
  375. 4.2.1.  GENERAL FORMAT OF NAME SERVICE PACKETS
  376.  
  377.    The NetBIOS Name Service packets follow the packet structure defined
  378.    in the Domain Name Service (DNS) RFC 883 [7 (pg 26-31)].  The
  379.    structures are compatible with the existing DNS packet formats,
  380.    however, additional types and codes have been added to work with
  381.    NetBIOS.
  382.  
  383.    If Name Service packets are sent over a TCP connection they are
  384.    preceded by a 16 bit unsigned integer representing the length of the
  385.    Name Service packet.
  386.  
  387.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  388.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  389.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  390.    |                                                               |
  391.    + ------                                                ------- +
  392.    |                            HEADER                             |
  393.    + ------                                                ------- +
  394.    |                                                               |
  395.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  396.    |                                                               |
  397.    /                       QUESTION ENTRIES                        /
  398.    |                                                               |
  399.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  400.    |                                                               |
  401.    /                    ANSWER RESOURCE RECORDS                    /
  402.    |                                                               |
  403.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  404.    |                                                               |
  405.    /                  AUTHORITY RESOURCE RECORDS                   /
  406.    |                                                               |
  407.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  408.    |                                                               |
  409.    /                  ADDITIONAL RESOURCE RECORDS                  /
  410.    |                                                               |
  411.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  412.  
  413.  
  414.  
  415. NetBIOS Working Group                                           [Page 7]
  416.  
  417.  
  418. RFC 1002                                                      March 1987
  419.  
  420.  
  421. 4.2.1.1.  HEADER
  422.  
  423.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  424.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  425.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  426.    |         NAME_TRN_ID           | OPCODE  |   NM_FLAGS  | RCODE |
  427.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  428.    |          QDCOUNT              |           ANCOUNT             |
  429.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  430.    |          NSCOUNT              |           ARCOUNT             |
  431.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  432.  
  433.    Field     Description
  434.  
  435.    NAME_TRN_ID      Transaction ID for Name Service Transaction.
  436.                     Requestor places a unique value for each active
  437.                     transaction.  Responder puts NAME_TRN_ID value
  438.                     from request packet in response packet.
  439.  
  440.    OPCODE           Packet type code, see table below.
  441.  
  442.    NM_FLAGS         Flags for operation, see table below.
  443.  
  444.    RCODE            Result codes of request.  Table of RCODE values
  445.                     for each response packet below.
  446.  
  447.    QDCOUNT          Unsigned 16 bit integer specifying the number of
  448.                     entries in the question section of a Name
  449.  
  450.                     Service packet.  Always zero (0) for responses.
  451.                     Must be non-zero for all NetBIOS Name requests.
  452.  
  453.    ANCOUNT          Unsigned 16 bit integer specifying the number of
  454.                     resource records in the answer section of a Name
  455.                     Service packet.
  456.  
  457.    NSCOUNT          Unsigned 16 bit integer specifying the number of
  458.                     resource records in the authority section of a
  459.                     Name Service packet.
  460.  
  461.    ARCOUNT          Unsigned 16 bit integer specifying the number of
  462.                     resource records in the additional records
  463.                     section of a Name Service packet.
  464.  
  465.    The OPCODE field is defined as:
  466.  
  467.      0   1   2   3   4
  468.    +---+---+---+---+---+
  469.    | R |    OPCODE     |
  470.    +---+---+---+---+---+
  471.  
  472.  
  473.  
  474.  
  475. NetBIOS Working Group                                           [Page 8]
  476.  
  477.  
  478. RFC 1002                                                      March 1987
  479.  
  480.  
  481.    Symbol     Bit(s)   Description
  482.  
  483.    OPCODE        1-4   Operation specifier:
  484.                          0 = query
  485.                          5 = registration
  486.                          6 = release
  487.                          7 = WACK
  488.                          8 = refresh
  489.  
  490.    R               0   RESPONSE flag:
  491.                          if bit == 0 then request packet
  492.                          if bit == 1 then response packet.
  493.  
  494.    The NM_FLAGS field is defined as:
  495.  
  496.  
  497.      0   1   2   3   4   5   6
  498.    +---+---+---+---+---+---+---+
  499.    |AA |TC |RD |RA | 0 | 0 | B |
  500.    +---+---+---+---+---+---+---+
  501.  
  502.    Symbol     Bit(s)   Description
  503.  
  504.    B               6   Broadcast Flag.
  505.                          = 1: packet was broadcast or multicast
  506.                          = 0: unicast
  507.  
  508.    RA              3   Recursion Available Flag.
  509.  
  510.                        Only valid in responses from a NetBIOS Name
  511.                        Server -- must be zero in all other
  512.                        responses.
  513.  
  514.                        If one (1) then the NBNS supports recursive
  515.                        query, registration, and release.
  516.  
  517.                        If zero (0) then the end-node must iterate
  518.                        for query and challenge for registration.
  519.  
  520.    RD              2   Recursion Desired Flag.
  521.  
  522.                        May only be set on a request to a NetBIOS
  523.                        Name Server.
  524.  
  525.                        The NBNS will copy its state into the
  526.                        response packet.
  527.  
  528.                        If one (1) the NBNS will iterate on the
  529.                        query, registration, or release.
  530.  
  531.    TC              1   Truncation Flag.
  532.  
  533.  
  534.  
  535. NetBIOS Working Group                                           [Page 9]
  536.  
  537.  
  538. RFC 1002                                                      March 1987
  539.  
  540.  
  541.                        Set if this message was truncated because the
  542.                        datagram carrying it would be greater than
  543.                        576 bytes in length.  Use TCP to get the
  544.                        information from the NetBIOS Name Server.
  545.  
  546.    AA              0   Authoritative Answer flag.
  547.  
  548.                        Must be zero (0) if R flag of OPCODE is zero
  549.                        (0).
  550.  
  551.                        If R flag is one (1) then if AA is one (1)
  552.                        then the node responding is an authority for
  553.                        the domain name.
  554.  
  555.                        End nodes responding to queries always set
  556.                        this bit in responses.
  557.  
  558. 4.2.1.2.  QUESTION SECTION
  559.  
  560.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  561.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  562.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  563.    |                                                               |
  564.    /                         QUESTION_NAME                         /
  565.    /                                                               /
  566.    |                                                               |
  567.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  568.    |         QUESTION_TYPE         |        QUESTION_CLASS         |
  569.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  570.  
  571.    Field            Description
  572.  
  573.    QUESTION_NAME    The compressed name representation of the
  574.                     NetBIOS name for the request.
  575.  
  576.    QUESTION_TYPE    The type of request.  The values for this field
  577.                     are specified for each request.
  578.  
  579.    QUESTION_CLASS   The class of the request.  The values for this
  580.                     field are specified for each request.
  581.  
  582.    QUESTION_TYPE is defined as:
  583.  
  584.    Symbol      Value   Description:
  585.  
  586.    NB         0x0020   NetBIOS general Name Service Resource Record
  587.    NBSTAT     0x0021   NetBIOS NODE STATUS Resource Record (See NODE
  588.                        STATUS REQUEST)
  589.  
  590.    QUESTION_CLASS is defined as:
  591.  
  592.  
  593.  
  594.  
  595. NetBIOS Working Group                                          [Page 10]
  596.  
  597.  
  598. RFC 1002                                                      March 1987
  599.  
  600.  
  601.    Symbol      Value   Description:
  602.  
  603.    IN         0x0001   Internet class
  604.  
  605. 4.2.1.3.  RESOURCE RECORD
  606.  
  607.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  608.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  609.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  610.    |                                                               |
  611.    /                            RR_NAME                            /
  612.    /                                                               /
  613.    |                                                               |
  614.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  615.    |           RR_TYPE             |          RR_CLASS             |
  616.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  617.    |                              TTL                              |
  618.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  619.    |           RDLENGTH            |                               |
  620.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
  621.    /                                                               /
  622.    /                             RDATA                             /
  623.    |                                                               |
  624.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  625.  
  626.    Field            Description
  627.  
  628.    RR_NAME          The compressed name representation of the
  629.                     NetBIOS name corresponding to this resource
  630.                     record.
  631.  
  632.    RR_TYPE          Resource record type code
  633.  
  634.    RR_CLASS         Resource record class code
  635.  
  636.    TTL              The Time To Live of a the resource record's
  637.                     name.
  638.  
  639.    RDLENGTH         Unsigned 16 bit integer that specifies the
  640.                     number of bytes in the RDATA field.
  641.  
  642.    RDATA            RR_CLASS and RR_TYPE dependent field.  Contains
  643.                     the resource information for the NetBIOS name.
  644.  
  645.    RESOURCE RECORD RR_TYPE field definitions:
  646.  
  647.    Symbol      Value   Description:
  648.  
  649.    A          0x0001   IP address Resource Record (See REDIRECT NAME
  650.                        QUERY RESPONSE)
  651.    NS         0x0002   Name Server Resource Record (See REDIRECT
  652.  
  653.  
  654.  
  655. NetBIOS Working Group                                          [Page 11]
  656.  
  657.  
  658. RFC 1002                                                      March 1987
  659.  
  660.  
  661.                        NAME QUERY RESPONSE)
  662.    NULL       0x000A   NULL Resource Record (See WAIT FOR
  663.                        ACKNOWLEDGEMENT RESPONSE)
  664.    NB         0x0020   NetBIOS general Name Service Resource Record
  665.                        (See NB_FLAGS and NB_ADDRESS, below)
  666.    NBSTAT     0x0021   NetBIOS NODE STATUS Resource Record (See NODE
  667.                        STATUS RESPONSE)
  668.  
  669.    RESOURCE RECORD RR_CLASS field definitions:
  670.  
  671.    Symbol      Value   Description:
  672.  
  673.    IN         0x0001   Internet class
  674.  
  675.    NB_FLAGS field of the RESOURCE RECORD RDATA field for RR_TYPE of
  676.    "NB":
  677.  
  678.                                              1   1   1   1   1   1
  679.      0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
  680.    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  681.    | G |  ONT  |                RESERVED                           |
  682.    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  683.  
  684.    Symbol     Bit(s)   Description:
  685.  
  686.    RESERVED     3-15   Reserved for future use.  Must be zero (0).
  687.    ONT           1,2   Owner Node Type:
  688.                           00 = B node
  689.                           01 = P node
  690.                           10 = M node
  691.                           11 = Reserved for future use
  692.                        For registration requests this is the
  693.                        claimant's type.
  694.                        For responses this is the actual owner's
  695.                        type.
  696.  
  697.    G               0   Group Name Flag.
  698.                        If one (1) then the RR_NAME is a GROUP
  699.                        NetBIOS name.
  700.                        If zero (0) then the RR_NAME is a UNIQUE
  701.                        NetBIOS name.
  702.  
  703.    The NB_ADDRESS field of the RESOURCE RECORD RDATA field for
  704.    RR_TYPE of "NB" is the IP address of the name's owner.
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715. NetBIOS Working Group                                          [Page 12]
  716.  
  717.  
  718. RFC 1002                                                      March 1987
  719.  
  720.  
  721. 4.2.2.  NAME REGISTRATION REQUEST
  722.  
  723.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  724.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  725.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  726.    |         NAME_TRN_ID           |0|  0x5  |0|0|1|0|0 0|B|  0x0  |
  727.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  728.    |          0x0001               |           0x0000              |
  729.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  730.    |          0x0000               |           0x0001              |
  731.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  732.    |                                                               |
  733.    /                         QUESTION_NAME                         /
  734.    /                                                               /
  735.    |                                                               |
  736.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  737.    |           NB (0x0020)         |        IN (0x0001)            |
  738.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  739.    |                                                               |
  740.    /                            RR_NAME                            /
  741.    /                                                               /
  742.    |                                                               |
  743.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  744.    |           NB (0x0020)         |         IN (0x0001)           |
  745.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  746.    |                              TTL                              |
  747.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  748.    |           0x0006              |          NB_FLAGS             |
  749.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  750.    |                          NB_ADDRESS                           |
  751.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  752.  
  753.    Since the RR_NAME is the same name as the QUESTION_NAME, the
  754.    RR_NAME representation must use pointers to the QUESTION_NAME
  755.    name's labels to guarantee the length of the datagram is less
  756.    than the maximum 576 bytes.  See section above on name formats
  757.    and also page 31 and 32 of RFC 883, Domain Names - Implementation
  758.    and Specification, for a complete description of compressed name
  759.    label pointers.
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775. NetBIOS Working Group                                          [Page 13]
  776.  
  777.  
  778. RFC 1002                                                      March 1987
  779.  
  780.  
  781. 4.2.3.  NAME OVERWRITE REQUEST & DEMAND
  782.  
  783.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  784.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  785.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  786.    |         NAME_TRN_ID           |0|  0x5  |0|0|0|0|0 0|B|  0x0  |
  787.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  788.    |          0x0001               |           0x0000              |
  789.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  790.    |          0x0000               |           0x0001              |
  791.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  792.    |                                                               |
  793.    /                         QUESTION_NAME                         /
  794.    /                                                               /
  795.    |                                                               |
  796.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  797.    |           NB (0x0020)         |        IN (0x0001)            |
  798.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  799.    |                                                               |
  800.    /                            RR_NAME                            /
  801.    /                                                               /
  802.    |                                                               |
  803.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  804.    |           NB (0x0020)         |         IN (0x0001)           |
  805.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  806.    |                              TTL                              |
  807.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  808.    |           0x0006              |          NB_FLAGS             |
  809.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  810.    |                          NB_ADDRESS                           |
  811.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835. NetBIOS Working Group                                          [Page 14]
  836.  
  837.  
  838. RFC 1002                                                      March 1987
  839.  
  840.  
  841. 4.2.4.  NAME REFRESH REQUEST
  842.  
  843.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  844.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  845.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  846.    |         NAME_TRN_ID           |0|  0x9  |0|0|0|0|0 0|B|  0x0  |
  847.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  848.    |          0x0001               |           0x0000              |
  849.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  850.    |          0x0000               |           0x0001              |
  851.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  852.    |                                                               |
  853.    /                         QUESTION_NAME                         /
  854.    /                                                               /
  855.    |                                                               |
  856.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  857.    |           NB (0x0020)         |        IN (0x0001)            |
  858.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  859.    |                                                               |
  860.    /                            RR_NAME                            /
  861.    /                                                               /
  862.    |                                                               |
  863.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  864.    |           NB (0x0020)         |         IN (0x0001)           |
  865.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  866.    |                              TTL                              |
  867.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  868.    |           0x0006              |          NB_FLAGS             |
  869.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  870.    |                          NB_ADDRESS                           |
  871.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895. NetBIOS Working Group                                          [Page 15]
  896.  
  897.  
  898. RFC 1002                                                      March 1987
  899.  
  900.  
  901. 4.2.5.  POSITIVE NAME REGISTRATION RESPONSE
  902.  
  903.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  904.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  905.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  906.    |         NAME_TRN_ID           |1|  0x5  |1|0|1|1|0 0|0|  0x0  |
  907.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  908.    |          0x0000               |           0x0001              |
  909.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  910.    |          0x0000               |           0x0000              |
  911.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  912.    |                                                               |
  913.    /                            RR_NAME                            /
  914.    /                                                               /
  915.    |                                                               |
  916.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  917.    |           NB (0x0020)         |         IN (0x0001)           |
  918.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  919.    |                              TTL                              |
  920.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  921.    |           0x0006              |          NB_FLAGS             |
  922.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  923.    |                          NB_ADDRESS                           |
  924.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  925.  
  926. 4.2.6.  NEGATIVE NAME REGISTRATION RESPONSE
  927.  
  928.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  929.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  930.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  931.    |         NAME_TRN_ID           |1|  0x5  |1|0|1|1|0 0|0| RCODE |
  932.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  933.    |          0x0000               |           0x0001              |
  934.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  935.    |          0x0000               |           0x0000              |
  936.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  937.    |                                                               |
  938.    /                            RR_NAME                            /
  939.    /                                                               /
  940.    |                                                               |
  941.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  942.    |           NB (0x0020)         |         IN (0x0001)           |
  943.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  944.    |                              TTL                              |
  945.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  946.    |           0x0006              |          NB_FLAGS             |
  947.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  948.    |                          NB_ADDRESS                           |
  949.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  950.  
  951.  
  952.  
  953.  
  954.  
  955. NetBIOS Working Group                                          [Page 16]
  956.  
  957.  
  958. RFC 1002                                                      March 1987
  959.  
  960.  
  961.    RCODE field values:
  962.  
  963.    Symbol      Value   Description:
  964.  
  965.    FMT_ERR       0x1   Format Error.  Request was invalidly
  966.                        formatted.
  967.    SRV_ERR       0x2   Server failure.  Problem with NBNS, cannot
  968.                        process name.
  969.    IMP_ERR       0x4   Unsupported request error.  Allowable only
  970.                        for challenging NBNS when gets an Update type
  971.                        registration request.
  972.    RFS_ERR       0x5   Refused error.  For policy reasons server
  973.                        will not register this name from this host.
  974.    ACT_ERR       0x6   Active error.  Name is owned by another node.
  975.    CFT_ERR       0x7   Name in conflict error.  A UNIQUE name is
  976.                        owned by more than one node.
  977.  
  978. 4.2.7.  END-NODE CHALLENGE REGISTRATION RESPONSE
  979.  
  980.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  981.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  982.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  983.    |         NAME_TRN_ID           |1|  0x5  |1|0|1|0|0 0|0|  0x0  |
  984.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  985.    |          0x0000               |           0x0001              |
  986.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  987.    |          0x0000               |           0x0000              |
  988.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  989.    |                                                               |
  990.    /                            RR_NAME                            /
  991.    /                                                               /
  992.    |                                                               |
  993.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  994.    |           NB (0x0020)         |         IN (0x0001)           |
  995.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  996.    |                              TTL                              |
  997.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  998.    |           0x0006              |          NB_FLAGS             |
  999.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1000.    |                          NB_ADDRESS                           |
  1001.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015. NetBIOS Working Group                                          [Page 17]
  1016.  
  1017.  
  1018. RFC 1002                                                      March 1987
  1019.  
  1020.  
  1021. 4.2.8.  NAME CONFLICT DEMAND
  1022.  
  1023.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1024.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1025.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1026.    |         NAME_TRN_ID           |1|  0x5  |1|0|1|1|0 0|0|  0x7  |
  1027.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1028.    |          0x0000               |           0x0001              |
  1029.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1030.    |          0x0000               |           0x0000              |
  1031.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1032.    |                                                               |
  1033.    /                            RR_NAME                            /
  1034.    /                                                               /
  1035.    |                                                               |
  1036.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1037.    |           NB (0x0020)         |         IN (0x0001)           |
  1038.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1039.    |                          0x00000000                           |
  1040.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1041.    |           0x0006              |0|ONT|0|     0x000             |
  1042.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1043.    |                          0x00000000                           |
  1044.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1045.  
  1046.    This packet is identical to a NEGATIVE NAME REGISTRATION RESPONSE
  1047.    with RCODE = CFT_ERR.
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075. NetBIOS Working Group                                          [Page 18]
  1076.  
  1077.  
  1078. RFC 1002                                                      March 1987
  1079.  
  1080.  
  1081. 4.2.9.  NAME RELEASE REQUEST & DEMAND
  1082.  
  1083.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1084.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1085.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1086.    |         NAME_TRN_ID           |0|  0x6  |0|0|0|0|0 0|B|  0x0  |
  1087.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1088.    |          0x0001               |           0x0000              |
  1089.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1090.    |          0x0000               |           0x0001              |
  1091.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1092.    |                                                               |
  1093.    /                         QUESTION_NAME                         /
  1094.    /                                                               /
  1095.    |                                                               |
  1096.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1097.    |           NB (0x0020)         |        IN (0x0001)            |
  1098.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1099.    |                                                               |
  1100.    /                            RR_NAME                            /
  1101.    /                                                               /
  1102.    |                                                               |
  1103.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1104.    |           NB (0x0020)         |         IN (0x0001)           |
  1105.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1106.    |                          0x00000000                           |
  1107.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1108.    |           0x0006              |          NB_FLAGS             |
  1109.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1110.    |                          NB_ADDRESS                           |
  1111.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1112.  
  1113.    Since the RR_NAME is the same name as the QUESTION_NAME, the
  1114.    RR_NAME representation must use label string pointers to the
  1115.    QUESTION_NAME labels to guarantee the length of the datagram is
  1116.    less than the maximum 576 bytes.  This is the same condition as
  1117.    with the NAME REGISTRATION REQUEST.
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135. NetBIOS Working Group                                          [Page 19]
  1136.  
  1137.  
  1138. RFC 1002                                                      March 1987
  1139.  
  1140.  
  1141. 4.2.10.  POSITIVE NAME RELEASE RESPONSE
  1142.  
  1143.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1144.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1145.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1146.    |         NAME_TRN_ID           |1|  0x6  |1|0|0|0|0 0|0|  0x0  |
  1147.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1148.    |          0x0000               |           0x0001              |
  1149.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1150.    |          0x0000               |           0x0000              |
  1151.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1152.    |                                                               |
  1153.    /                            RR_NAME                            /
  1154.    /                                                               /
  1155.    |                                                               |
  1156.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1157.    |           NB (0x0020)         |         IN (0x0001)           |
  1158.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1159.    |                              TTL                              |
  1160.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1161.    |           0x0006              |          NB_FLAGS             |
  1162.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1163.    |                          NB_ADDRESS                           |
  1164.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1165.  
  1166. 4.2.11.  NEGATIVE NAME RELEASE RESPONSE
  1167.  
  1168.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1169.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1170.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1171.    |         NAME_TRN_ID           |1|  0x6  |1|0|0|0|0 0|0| RCODE |
  1172.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1173.    |          0x0000               |           0x0001              |
  1174.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1175.    |          0x0000               |           0x0000              |
  1176.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1177.    |                                                               |
  1178.    /                            RR_NAME                            /
  1179.    /                                                               /
  1180.    |                                                               |
  1181.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1182.    |           NB (0x0020)         |         IN (0x0001)           |
  1183.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1184.    |                              TTL                              |
  1185.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1186.    |           0x0006              |          NB_FLAGS             |
  1187.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1188.    |                          NB_ADDRESS                           |
  1189.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195. NetBIOS Working Group                                          [Page 20]
  1196.  
  1197.  
  1198. RFC 1002                                                      March 1987
  1199.  
  1200.  
  1201.    RCODE field values:
  1202.  
  1203.    Symbol      Value   Description:
  1204.  
  1205.    FMT_ERR       0x1   Format Error.  Request was invalidly
  1206.                        formatted.
  1207.  
  1208.    SRV_ERR       0x2   Server failure.  Problem with NBNS, cannot
  1209.                        process name.
  1210.  
  1211.    RFS_ERR       0x5   Refused error.  For policy reasons server
  1212.                        will not release this name from this host.
  1213.  
  1214.    ACT_ERR       0x6   Active error.  Name is owned by another node.
  1215.                        Only that node may release it.  A NetBIOS
  1216.                        Name Server can optionally allow a node to
  1217.                        release a name it does not own.  This would
  1218.                        facilitate detection of inactive names for
  1219.                        nodes that went down silently.
  1220.  
  1221. 4.2.12.  NAME QUERY REQUEST
  1222.  
  1223.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1224.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1225.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1226.    |         NAME_TRN_ID           |0|  0x0  |0|0|1|0|0 0|B|  0x0  |
  1227.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1228.    |          0x0001               |           0x0000              |
  1229.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1230.    |          0x0000               |           0x0000              |
  1231.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1232.    |                                                               |
  1233.    /                         QUESTION_NAME                         /
  1234.    /                                                               /
  1235.    |                                                               |
  1236.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1237.    |           NB (0x0020)         |        IN (0x0001)            |
  1238.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255. NetBIOS Working Group                                          [Page 21]
  1256.  
  1257.  
  1258. RFC 1002                                                      March 1987
  1259.  
  1260.  
  1261. 4.2.13.  POSITIVE NAME QUERY RESPONSE
  1262.  
  1263.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1264.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1265.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1266.    |         NAME_TRN_ID           |1|  0x0  |1|T|1|?|0 0|0|  0x0  |
  1267.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1268.    |          0x0000               |           0x0001              |
  1269.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1270.    |          0x0000               |           0x0000              |
  1271.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1272.    |                                                               |
  1273.    /                            RR_NAME                            /
  1274.    /                                                               /
  1275.    |                                                               |
  1276.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1277.    |           NB (0x0020)         |         IN (0x0001)           |
  1278.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1279.    |                              TTL                              |
  1280.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1281.    |           RDLENGTH            |                               |
  1282.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
  1283.    |                                                               |
  1284.    /                       ADDR_ENTRY ARRAY                        /
  1285.    /                                                               /
  1286.    |                                                               |
  1287.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1288.  
  1289.    The ADDR_ENTRY ARRAY a sequence of zero or more ADDR_ENTRY
  1290.    records.  Each ADDR_ENTRY record represents an owner of a name.
  1291.    For group names there may be multiple entries.  However, the list
  1292.    may be incomplete due to packet size limitations.  Bit 22, "T",
  1293.    will be set to indicate truncated data.
  1294.  
  1295.    Each ADDR_ENTRY has the following format:
  1296.  
  1297.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1298.    |          NB_FLAGS             |          NB_ADDRESS           |
  1299.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1300.    |   NB_ADDRESS (continued)      |
  1301.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315. NetBIOS Working Group                                          [Page 22]
  1316.  
  1317.  
  1318. RFC 1002                                                      March 1987
  1319.  
  1320.  
  1321. 4.2.14.  NEGATIVE NAME QUERY RESPONSE
  1322.  
  1323.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1324.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1325.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1326.    |         NAME_TRN_ID           |1|  0x0  |1|0|1|?|0 0|0| RCODE |
  1327.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1328.    |          0x0000               |           0x0000              |
  1329.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1330.    |          0x0000               |           0x0000              |
  1331.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1332.    |                                                               |
  1333.    /                            RR_NAME                            /
  1334.    /                                                               /
  1335.    |                                                               |
  1336.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1337.    |           NULL (0x000A)       |         IN (0x0001)           |
  1338.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1339.    |                          0x00000000                           |
  1340.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1341.    |           0x0000              |
  1342.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1343.  
  1344.    RCODE field values:
  1345.  
  1346.    Symbol      Value   Description
  1347.  
  1348.    FMT_ERR       0x1   Format Error.  Request was invalidly
  1349.                        formatted.
  1350.    SRV_ERR       0x2   Server failure.  Problem with NBNS, cannot
  1351.                        process name.
  1352.    NAM_ERR       0x3   Name Error.  The name requested does not
  1353.                        exist.
  1354.    IMP_ERR       0x4   Unsupported request error.  Allowable only
  1355.                        for challenging NBNS when gets an Update type
  1356.                        registration request.
  1357.    RFS_ERR       0x5   Refused error.  For policy reasons server
  1358.                        will not register this name from this host.
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375. NetBIOS Working Group                                          [Page 23]
  1376.  
  1377.  
  1378. RFC 1002                                                      March 1987
  1379.  
  1380.  
  1381. 4.2.15.  REDIRECT NAME QUERY RESPONSE
  1382.  
  1383.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1384.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1385.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1386.    |         NAME_TRN_ID           |1|  0x0  |0|0|1|0|0 0|0|  0x0  |
  1387.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1388.    |          0x0000               |           0x0000              |
  1389.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1390.    |          0x0001               |           0x0001              |
  1391.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1392.    |                                                               |
  1393.    /                            RR_NAME                            /
  1394.    /                                                               /
  1395.    |                                                               |
  1396.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1397.    |           NS (0x0002)         |         IN (0x0001)           |
  1398.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1399.    |                              TTL                              |
  1400.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1401.    |           RDLENGTH            |                               |
  1402.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
  1403.    |                                                               |
  1404.    /                            NSD_NAME                           /
  1405.    /                                                               /
  1406.    |                                                               |
  1407.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1408.    |                                                               |
  1409.    /                            RR_NAME                            /
  1410.    /                                                               /
  1411.    |                                                               |
  1412.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1413.    |           A (0x0001)          |         IN (0x0001)           |
  1414.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1415.    |                              TTL                              |
  1416.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1417.    |             0x0004            |           NSD_IP_ADDR         |
  1418.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1419.    |     NSD_IP_ADDR, continued    |
  1420.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1421.  
  1422.    An end node responding to a NAME QUERY REQUEST always responds
  1423.    with the AA and RA bits set for both the NEGATIVE and POSITIVE
  1424.    NAME QUERY RESPONSE packets.  An end node never sends a REDIRECT
  1425.    NAME QUERY RESPONSE packet.
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435. NetBIOS Working Group                                          [Page 24]
  1436.  
  1437.  
  1438. RFC 1002                                                      March 1987
  1439.  
  1440.  
  1441.    When the requestor receives the REDIRECT NAME QUERY RESPONSE it
  1442.    must reiterate the NAME QUERY REQUEST to the NBNS specified by
  1443.    the NSD_IP_ADDR field of the A type RESOURCE RECORD in the
  1444.    ADDITIONAL section of the response packet.  This is an optional
  1445.    packet for the NBNS.
  1446.  
  1447.    The NSD_NAME and the RR_NAME in the ADDITIONAL section of the
  1448.    response packet are the same name.  Space can be optimized if
  1449.    label string pointers are used in the RR_NAME which point to the
  1450.    labels in the NSD_NAME.
  1451.  
  1452.    The RR_NAME in the AUTHORITY section is the name of the domain
  1453.    the NBNS called by NSD_NAME has authority over.
  1454.  
  1455. 4.2.16.  WAIT FOR ACKNOWLEDGEMENT (WACK) RESPONSE
  1456.  
  1457.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1458.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1459.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1460.    |         NAME_TRN_ID           |1|  0x7  |1|0|0|0|0 0|0|  0x0  |
  1461.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1462.    |          0x0000               |           0x0001              |
  1463.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1464.    |          0x0000               |           0x0000              |
  1465.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1466.    |                                                               |
  1467.    /                            RR_NAME                            /
  1468.    /                                                               /
  1469.    |                                                               |
  1470.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1471.    |          NULL (0x0020)        |         IN (0x0001)           |
  1472.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1473.    |                              TTL                              |
  1474.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1475.    |           0x0002              | OPCODE  |   NM_FLAGS  |  0x0  |
  1476.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495. NetBIOS Working Group                                          [Page 25]
  1496.  
  1497.  
  1498. RFC 1002                                                      March 1987
  1499.  
  1500.  
  1501.    The NAME_TRN_ID of the WACK RESPONSE packet is the same
  1502.    NAME_TRN_ID of the request that the NBNS is telling the requestor
  1503.    to wait longer to complete.  The RR_NAME is the name from the
  1504.    request, if any.  If no name is available from the request then
  1505.    it is a null name, single byte of zero.
  1506.  
  1507.    The TTL field of the ResourceRecord is the new time to wait, in
  1508.    seconds, for the request to complete.  The RDATA field contains
  1509.    the OPCODE and NM_FLAGS of the request.
  1510.  
  1511.    A TTL value of 0 means that the NBNS can not estimate the time it
  1512.    may take to complete a response.
  1513.  
  1514. 4.2.17.  NODE STATUS REQUEST
  1515.  
  1516.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1517.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1518.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1519.    |         NAME_TRN_ID           |0|  0x0  |0|0|0|0|0 0|B|  0x0  |
  1520.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1521.    |          0x0001               |           0x0000              |
  1522.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1523.    |          0x0000               |           0x0000              |
  1524.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1525.    |                                                               |
  1526.    /                         QUESTION_NAME                         /
  1527.    |                                                               |
  1528.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1529.    |         NBSTAT (0x0021)       |        IN (0x0001)            |
  1530.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555. NetBIOS Working Group                                          [Page 26]
  1556.  
  1557.  
  1558. RFC 1002                                                      March 1987
  1559.  
  1560.  
  1561. 4.2.18.  NODE STATUS RESPONSE
  1562.  
  1563.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1564.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1565.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1566.    |         NAME_TRN_ID           |1|  0x0  |1|0|0|0|0 0|0|  0x0  |
  1567.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1568.    |          0x0000               |           0x0001              |
  1569.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1570.    |          0x0000               |           0x0000              |
  1571.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1572.    |                                                               |
  1573.    /                            RR_NAME                            /
  1574.    |                                                               |
  1575.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1576.    |        NBSTAT (0x0021)        |         IN (0x0001)           |
  1577.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1578.    |                          0x00000000                           |
  1579.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1580.    |          RDLENGTH             |   NUM_NAMES   |               |
  1581.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
  1582.    |                                                               |
  1583.    +                                                               +
  1584.    /                         NODE_NAME ARRAY                       /
  1585.    +                                                               +
  1586.    |                                                               |
  1587.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1588.    |                                                               |
  1589.    +                                                               +
  1590.    /                           STATISTICS                          /
  1591.    +                                                               +
  1592.    |                                                               |
  1593.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1594.  
  1595.    The NODE_NAME ARRAY is an array of zero or more NUM_NAMES entries
  1596.    of NODE_NAME records.  Each NODE_NAME entry represents an active
  1597.    name in the same NetBIOS scope as the requesting name in the
  1598.    local name table of the responder.  RR_NAME is the requesting
  1599.    name.
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615. NetBIOS Working Group                                          [Page 27]
  1616.  
  1617.  
  1618. RFC 1002                                                      March 1987
  1619.  
  1620.  
  1621.    NODE_NAME Entry:
  1622.  
  1623.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1624.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1625.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1626.    |                                                               |
  1627.    +---                                                         ---+
  1628.    |                                                               |
  1629.    +---                    NETBIOS FORMAT NAME                  ---+
  1630.    |                                                               |
  1631.    +---                                                         ---+
  1632.    |                                                               |
  1633.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1634.    |         NAME_FLAGS            |
  1635.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1636.  
  1637.    The NAME_FLAGS field:
  1638.  
  1639.                                              1   1   1   1   1   1
  1640.      0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
  1641.    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  1642.    | G |  ONT  |DRG|CNF|ACT|PRM|          RESERVED                 |
  1643.    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  1644.  
  1645.    The NAME_FLAGS field is defined as:
  1646.  
  1647.    Symbol     Bit(s)   Description:
  1648.  
  1649.    RESERVED     7-15   Reserved for future use.  Must be zero (0).
  1650.    PRM             6   Permanent Name Flag.  If one (1) then entry
  1651.                        is for the permanent node name.  Flag is zero
  1652.                        (0) for all other names.
  1653.    ACT             5   Active Name Flag.  All entries have this flag
  1654.                        set to one (1).
  1655.    CNF             4   Conflict Flag.  If one (1) then name on this
  1656.                        node is in conflict.
  1657.    DRG             3   Deregister Flag.  If one (1) then this name
  1658.                        is in the process of being deleted.
  1659.    ONT           1,2   Owner Node Type:
  1660.                           00 = B node
  1661.                           01 = P node
  1662.                           10 = M node
  1663.                           11 = Reserved for future use
  1664.    G               0   Group Name Flag.
  1665.                        If one (1) then the name is a GROUP NetBIOS
  1666.                        name.
  1667.                        If zero (0) then it is a UNIQUE NetBIOS name.
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675. NetBIOS Working Group                                          [Page 28]
  1676.  
  1677.  
  1678. RFC 1002                                                      March 1987
  1679.  
  1680.  
  1681.    STATISTICS Field of the NODE STATUS RESPONSE:
  1682.  
  1683.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1684.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1685.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1686.    |               UNIT_ID (Unique unit ID)                        |
  1687.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1688.    |       UNIT_ID,continued       |    JUMPERS    |  TEST_RESULT  |
  1689.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1690.    |       VERSION_NUMBER          |      PERIOD_OF_STATISTICS     |
  1691.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1692.    |       NUMBER_OF_CRCs          |     NUMBER_ALIGNMENT_ERRORS   |
  1693.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1694.    |       NUMBER_OF_COLLISIONS    |        NUMBER_SEND_ABORTS     |
  1695.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1696.    |                       NUMBER_GOOD_SENDS                       |
  1697.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1698.    |                      NUMBER_GOOD_RECEIVES                     |
  1699.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1700.    |       NUMBER_RETRANSMITS      | NUMBER_NO_RESOURCE_CONDITIONS |
  1701.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1702.    |  NUMBER_FREE_COMMAND_BLOCKS   |  TOTAL_NUMBER_COMMAND_BLOCKS  |
  1703.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1704.    |MAX_TOTAL_NUMBER_COMMAND_BLOCKS|    NUMBER_PENDING_SESSIONS    |
  1705.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1706.    |  MAX_NUMBER_PENDING_SESSIONS  |  MAX_TOTAL_SESSIONS_POSSIBLE  |
  1707.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1708.    |   SESSION_DATA_PACKET_SIZE    |
  1709.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1710.  
  1711. 4.3.  SESSION SERVICE PACKETS
  1712.  
  1713. 4.3.1.  GENERAL FORMAT OF SESSION PACKETS
  1714.  
  1715.    All session service messages are sent over a TCP connection.
  1716.  
  1717.    All session packets are of the following general structure:
  1718.  
  1719.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1720.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1721.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1722.    |      TYPE     |     FLAGS     |            LENGTH             |
  1723.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1724.    |                                                               |
  1725.    /               TRAILER (Packet Type Dependent)                 /
  1726.    |                                                               |
  1727.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1728.  
  1729.    The TYPE, FLAGS, and LENGTH fields are present in every session
  1730.    packet.
  1731.  
  1732.  
  1733.  
  1734.  
  1735. NetBIOS Working Group                                          [Page 29]
  1736.  
  1737.  
  1738. RFC 1002                                                      March 1987
  1739.  
  1740.  
  1741.    The LENGTH field is the number of bytes following the LENGTH
  1742.    field.  In other words, LENGTH is the combined size of the
  1743.    TRAILER field(s).  For example, the POSITIVE SESSION RESPONSE
  1744.    packet always has a LENGTH field value of zero (0000) while the
  1745.    RETARGET SESSION RESPONSE always has a LENGTH field value of six
  1746.    (0006).
  1747.  
  1748.    One of the bits of the FLAGS field acts as an additional, high-
  1749.    order bit for the LENGTH field.  Thus the cumulative size of the
  1750.    trailer field(s) may range from 0 to 128K bytes.
  1751.  
  1752.    Session Packet Types (in hexidecimal):
  1753.  
  1754.            00 -  SESSION MESSAGE
  1755.            81 -  SESSION REQUEST
  1756.            82 -  POSITIVE SESSION RESPONSE
  1757.            83 -  NEGATIVE SESSION RESPONSE
  1758.            84 -  RETARGET SESSION RESPONSE
  1759.            85 -  SESSION KEEP ALIVE
  1760.  
  1761.    Bit definitions of the FLAGS field:
  1762.  
  1763.      0   1   2   3   4   5   6   7
  1764.    +---+---+---+---+---+---+---+---+
  1765.    | 0 | 0 | 0 | 0 | 0 | 0 | 0 | E |
  1766.    +---+---+---+---+---+---+---+---+
  1767.  
  1768.    Symbol     Bit(s)   Description
  1769.  
  1770.    E               7   Length extension, used as an additional,
  1771.                        high-order bit on the LENGTH field.
  1772.  
  1773.    RESERVED      0-6   Reserved, must be zero (0)
  1774.  
  1775. 4.3.2.  SESSION REQUEST PACKET
  1776.  
  1777.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1778.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1779.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1780.    |      TYPE     |     FLAGS     |            LENGTH             |
  1781.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1782.    |                                                               |
  1783.    /                          CALLED NAME                          /
  1784.    |                                                               |
  1785.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1786.    |                                                               |
  1787.    /                          CALLING NAME                         /
  1788.    |                                                               |
  1789.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795. NetBIOS Working Group                                          [Page 30]
  1796.  
  1797.  
  1798. RFC 1002                                                      March 1987
  1799.  
  1800.  
  1801. 4.3.3.  POSITIVE SESSION RESPONSE PACKET
  1802.  
  1803.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1804.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1805.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1806.    |      TYPE     |     FLAGS     |            LENGTH             |
  1807.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1808.  
  1809. 4.3.4.  NEGATIVE SESSION RESPONSE PACKET
  1810.  
  1811.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1812.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1813.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1814.    |      TYPE     |     FLAGS     |            LENGTH             |
  1815.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1816.    |   ERROR_CODE  |
  1817.    +-+-+-+-+-+-+-+-+
  1818.  
  1819.    NEGATIVE SESSION RESPONSE packet error code values (in
  1820.    hexidecimal):
  1821.  
  1822.            80 -  Not listening on called name
  1823.            81 -  Not listening for calling name
  1824.            82 -  Called name not present
  1825.            83 -  Called name present, but insufficient resources
  1826.            8F -  Unspecified error
  1827.  
  1828. 4.3.5.  SESSION RETARGET RESPONSE PACKET
  1829.  
  1830.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1831.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1832.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1833.    |      TYPE     |     FLAGS     |            LENGTH             |
  1834.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1835.    |                      RETARGET_IP_ADDRESS                      |
  1836.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1837.    |           PORT                |
  1838.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855. NetBIOS Working Group                                          [Page 31]
  1856.  
  1857.  
  1858. RFC 1002                                                      March 1987
  1859.  
  1860.  
  1861. 4.3.6.  SESSION MESSAGE PACKET
  1862.  
  1863.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1864.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1865.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1866.    |      TYPE     |     FLAGS     |            LENGTH             |
  1867.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1868.    |                                                               |
  1869.    /                                                               /
  1870.    /                           USER_DATA                           /
  1871.    /                                                               /
  1872.    |                                                               |
  1873.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1874.  
  1875. 4.3.7.  SESSION KEEP ALIVE PACKET
  1876.  
  1877.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1878.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1879.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1880.    |      TYPE     |     FLAGS     |            LENGTH             |
  1881.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1882.  
  1883. 4.4.  DATAGRAM SERVICE PACKETS
  1884.  
  1885. 4.4.1.  NetBIOS DATAGRAM HEADER
  1886.  
  1887.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1888.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1889.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1890.    |   MSG_TYPE    |     FLAGS     |           DGM_ID              |
  1891.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1892.    |                           SOURCE_IP                           |
  1893.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1894.    |          SOURCE_PORT          |          DGM_LENGTH           |
  1895.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1896.    |         PACKET_OFFSET         |
  1897.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1898.  
  1899.    MSG_TYPE values (in hexidecimal):
  1900.  
  1901.            10 -  DIRECT_UNIQUE DATAGRAM
  1902.            11 -  DIRECT_GROUP DATAGRAM
  1903.            12 -  BROADCAST DATAGRAM
  1904.            13 -  DATAGRAM ERROR
  1905.            14 -  DATAGRAM QUERY REQUEST
  1906.            15 -  DATAGRAM POSITIVE QUERY RESPONSE
  1907.            16 -  DATAGRAM NEGATIVE QUERY RESPONSE
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915. NetBIOS Working Group                                          [Page 32]
  1916.  
  1917.  
  1918. RFC 1002                                                      March 1987
  1919.  
  1920.  
  1921.    Bit definitions of the FLAGS field:
  1922.  
  1923.      0   1   2   3   4   5   6   7
  1924.    +---+---+---+---+---+---+---+---+
  1925.    | 0 | 0 | 0 | 0 |  SNT  | F | M |
  1926.    +---+---+---+---+---+---+---+---+
  1927.  
  1928.    Symbol     Bit(s)   Description
  1929.  
  1930.    M               7   MORE flag, If set then more NetBIOS datagram
  1931.                        fragments follow.
  1932.  
  1933.    F               6   FIRST packet flag,  If set then this is first
  1934.                        (and possibly only) fragment of NetBIOS
  1935.                        datagram
  1936.  
  1937.    SNT           4,5   Source End-Node type:
  1938.                           00 = B node
  1939.                           01 = P node
  1940.                           10 = M node
  1941.                           11 = NBDD
  1942.    RESERVED      0-3   Reserved, must be zero (0)
  1943.  
  1944. 4.4.2.  DIRECT_UNIQUE, DIRECT_GROUP, & BROADCAST DATAGRAM
  1945.  
  1946.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1947.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1948.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1949.    |   MSG_TYPE    |     FLAGS     |           DGM_ID              |
  1950.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1951.    |                           SOURCE_IP                           |
  1952.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1953.    |          SOURCE_PORT          |          DGM_LENGTH           |
  1954.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1955.    |         PACKET_OFFSET         |                               |
  1956.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
  1957.    |                                                               |
  1958.    /                          SOURCE_NAME                          /
  1959.    /                                                               /
  1960.    |                                                               |
  1961.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1962.    |                                                               |
  1963.    /                       DESTINATION_NAME                        /
  1964.    /                                                               /
  1965.    |                                                               |
  1966.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1967.    |                                                               |
  1968.    /                           USER_DATA                           /
  1969.    /                                                               /
  1970.    |                                                               |
  1971.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1972.  
  1973.  
  1974.  
  1975. NetBIOS Working Group                                          [Page 33]
  1976.  
  1977.  
  1978. RFC 1002                                                      March 1987
  1979.  
  1980.  
  1981.    4.4.3.  DATAGRAM ERROR PACKET
  1982.  
  1983.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  1984.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1985.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1986.    |   MSG_TYPE    |     FLAGS     |           DGM_ID              |
  1987.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1988.    |                           SOURCE_IP                           |
  1989.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1990.    |          SOURCE_PORT          |  ERROR_CODE   |
  1991.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1992.  
  1993.    ERROR_CODE values (in hexidecimal):
  1994.  
  1995.            82 -  DESTINATION NAME NOT PRESENT
  1996.            83 -  INVALID SOURCE NAME FORMAT
  1997.            84 -  INVALID DESTINATION NAME FORMAT
  1998.  
  1999. 4.4.4.  DATAGRAM QUERY REQUEST
  2000.  
  2001.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  2002.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  2003.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2004.    |   MSG_TYPE    |     FLAGS     |           DGM_ID              |
  2005.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2006.    |                           SOURCE_IP                           |
  2007.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2008.    |          SOURCE_PORT          |                               |
  2009.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
  2010.    |                                                               |
  2011.    /                       DESTINATION_NAME                        /
  2012.    /                                                               /
  2013.    |                                                               |
  2014.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2015.  
  2016. 4.4.5.  DATAGRAM POSITIVE AND NEGATIVE QUERY RESPONSE
  2017.  
  2018.                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
  2019.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  2020.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2021.    |   MSG_TYPE    |     FLAGS     |           DGM_ID              |
  2022.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2023.    |                           SOURCE_IP                           |
  2024.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2025.    |          SOURCE_PORT          |                               |
  2026.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
  2027.    |                                                               |
  2028.    /                       DESTINATION_NAME                        /
  2029.    /                                                               /
  2030.    |                                                               |
  2031.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  2032.  
  2033.  
  2034.  
  2035. NetBIOS Working Group                                          [Page 34]
  2036.  
  2037.  
  2038. RFC 1002                                                      March 1987
  2039.  
  2040.  
  2041. 5.  PROTOCOL DESCRIPTIONS
  2042.  
  2043. 5.1.  NAME SERVICE PROTOCOLS
  2044.  
  2045.    A REQUEST packet is always sent to the well known UDP port -
  2046.    NAME_SERVICE_UDP_PORT.  The destination address is normally
  2047.    either the IP broadcast address or the address of the NBNS - the
  2048.    address of the NBNS server it set up at initialization time.  In
  2049.    rare cases, a request packet will be sent to an end node, e.g.  a
  2050.    NAME QUERY REQUEST sent to "challenge" a node.
  2051.  
  2052.    A RESPONSE packet is always sent to the source UDP port and
  2053.    source IP address of the request packet.
  2054.  
  2055.    A DEMAND packet must always be sent to the well known UDP port -
  2056.    NAME_SERVICE_UDP_PORT.  There is no restriction on the target IP
  2057.    address.
  2058.  
  2059.    Terms used in this section:
  2060.  
  2061.    tid -            Transaction ID.  This is a value composed from
  2062.                     the requestor's IP address and a unique 16 bit
  2063.                     value generated by the originator of the
  2064.                     transaction.
  2065.  
  2066. 5.1.1.  B-NODE ACTIVITY
  2067.  
  2068. 5.1.1.1.  B-NODE ADD NAME
  2069.  
  2070.    PROCEDURE add_name(newname)
  2071.  
  2072.    /*
  2073.     * Host initiated processing for a B node
  2074.     */
  2075.    BEGIN
  2076.  
  2077.         REPEAT
  2078.  
  2079.              /* build name service packet */
  2080.  
  2081.              ONT = B_NODE; /* broadcast node */
  2082.              G = UNIQUE;   /* unique name */
  2083.              TTL = 0;
  2084.  
  2085.              broadcast NAME REGISTRATION REQUEST packet;
  2086.  
  2087.              /*
  2088.               * remote node(s) will send response packet
  2089.               * if applicable
  2090.               */
  2091.  
  2092.  
  2093.  
  2094.  
  2095. NetBIOS Working Group                                          [Page 35]
  2096.  
  2097.  
  2098. RFC 1002                                                      March 1987
  2099.  
  2100.  
  2101.              pause(BCAST_REQ_RETRY_TIMEOUT);
  2102.  
  2103.         UNTIL response packet is received or
  2104.              retransmit count has been exceeded
  2105.  
  2106.         IF no response packet was received THEN
  2107.         BEGIN /* no response */
  2108.              /*
  2109.               * build packet
  2110.               */
  2111.  
  2112.              ONT = B_NODE; /* broadcast node */
  2113.              G = UNIQUE;   /* unique name */
  2114.              TTL = 0;
  2115.  
  2116.              /*
  2117.               * Let other nodes known you have the name
  2118.               */
  2119.  
  2120.              broadcast NAME UPDATE REQUEST packet;
  2121.              /* name can be added to local name table */
  2122.              return success;
  2123.         END /* no response */
  2124.         ELSE
  2125.         BEGIN /* got response */
  2126.  
  2127.              /*
  2128.               * Match return transaction id
  2129.               * against tid sent in request
  2130.               */
  2131.  
  2132.             IF NOT response tid = request tid THEN
  2133.             BEGIN
  2134.              ignore response packet;
  2135.             END
  2136.             ELSE
  2137.             CASE packet type OF
  2138.  
  2139.             NEGATIVE NAME REGISTRATION RESPONSE:
  2140.  
  2141.                  return failure; /* name cannot be added */
  2142.  
  2143.             POSITIVE NAME REGISTRATION RESPONSE:
  2144.             END-NODE CHALLENGE NAME REGISTRATION RESPONSE:
  2145.  
  2146.                  /*
  2147.                   * B nodes should normally not get this
  2148.                   * response.
  2149.                   */
  2150.  
  2151.                   ignore packet;
  2152.  
  2153.  
  2154.  
  2155. NetBIOS Working Group                                          [Page 36]
  2156.  
  2157.  
  2158. RFC 1002                                                      March 1987
  2159.  
  2160.  
  2161.             END /* case */;
  2162.         END /* got response */
  2163.    END /* procedure */
  2164.  
  2165. 5.1.1.2.  B-NODE ADD_GROUP NAME
  2166.  
  2167.    PROCEDURE add_group_name(newname)
  2168.  
  2169.    /*
  2170.     * Host initiated processing for a B node
  2171.     */
  2172.  
  2173.    BEGIN
  2174.         /*
  2175.          * same as for a unique name with the
  2176.          * exception that the group bit (G) must
  2177.          * be set in the request packets.
  2178.          */
  2179.  
  2180.         ...
  2181.         G = GROUP;
  2182.         ...
  2183.         ...
  2184.  
  2185.         /*
  2186.          * broadcast request ...
  2187.          */
  2188.  
  2189.  
  2190.    END
  2191.  
  2192. 5.1.1.3.  B-NODE FIND_NAME
  2193.  
  2194.    PROCEDURE find_name(name)
  2195.  
  2196.    /*
  2197.     * Host initiated processing for a B node
  2198.     */
  2199.  
  2200.    BEGIN
  2201.  
  2202.         REPEAT
  2203.              /*
  2204.               * build packet
  2205.               */
  2206.              ONT = B;
  2207.              TTL = 0;
  2208.              G = DONT CARE;
  2209.  
  2210.              broadcast NAME QUERY REQUEST packet;
  2211.  
  2212.  
  2213.  
  2214.  
  2215. NetBIOS Working Group                                          [Page 37]
  2216.  
  2217.  
  2218. RFC 1002                                                      March 1987
  2219.  
  2220.  
  2221.              /*
  2222.               * a node might send response packet
  2223.               */
  2224.  
  2225.              pause(BCAST_REQ_RETRY_TIMEOUT);
  2226.         UNTIL response packet received OR
  2227.              max transmit threshold exceeded
  2228.  
  2229.         IF no response packet received THEN
  2230.              return failure;
  2231.         ELSE
  2232.         IF NOT response tid = request tid THEN
  2233.              ignore packet;
  2234.         ELSE
  2235.         CASE packet type OF
  2236.         POSITIVE NAME QUERY RESPONSE:
  2237.              /*
  2238.               * Start a timer to detect conflict.
  2239.               *
  2240.               * Be prepared to detect conflict if
  2241.               * any more response packets are received.
  2242.               *
  2243.               */
  2244.  
  2245.              save response as authoritative response;
  2246.              start_timer(CONFLICT_TIMER);
  2247.              return success;
  2248.  
  2249.         NEGATIVE NAME QUERY RESPONSE:
  2250.         REDIRECT NAME QUERY RESPONSE:
  2251.  
  2252.              /*
  2253.               * B Node should normally not get either
  2254.               * response.
  2255.               */
  2256.  
  2257.               ignore response packet;
  2258.  
  2259.         END /* case */
  2260.    END /* procedure */
  2261.  
  2262. 5.1.1.4.  B NODE NAME RELEASE
  2263.  
  2264.    PROCEDURE delete_name (name)
  2265.    BEGIN
  2266.  
  2267.         REPEAT
  2268.  
  2269.              /*
  2270.               * build packet
  2271.               */
  2272.  
  2273.  
  2274.  
  2275. NetBIOS Working Group                                          [Page 38]
  2276.  
  2277.  
  2278. RFC 1002                                                      March 1987
  2279.  
  2280.  
  2281.              ...
  2282.  
  2283.              /*
  2284.               * send request
  2285.               */
  2286.  
  2287.              broadcast NAME RELEASE REQUEST packet;
  2288.  
  2289.              /*
  2290.               * no response packet expected
  2291.               */
  2292.  
  2293.              pause(BCAST_REQ_RETRY_TIMEOUT);
  2294.  
  2295.         UNTIL retransmit count has been exceeded
  2296.    END /* procedure */
  2297.  
  2298. 5.1.1.5.  B-NODE INCOMING PACKET PROCESSING
  2299.  
  2300.    Following processing is done when broadcast or unicast packets
  2301.    are received at the NAME_SERVICE_UDP_PORT.
  2302.  
  2303.    PROCEDURE process_incoming_packet(packet)
  2304.  
  2305.    /*
  2306.     * Processing initiated by incoming packets for a B node
  2307.     */
  2308.  
  2309.    BEGIN
  2310.         /*
  2311.          * Note: response packets are always sent
  2312.          * to:
  2313.          * source IP address of request packet
  2314.          * source UDP port of request packet
  2315.          */
  2316.  
  2317.         CASE packet type OF
  2318.  
  2319.         NAME REGISTRATION REQUEST (UNIQUE):
  2320.              IF name exists in local name table THEN
  2321.                   send NEGATIVE NAME REGISTRATION RESPONSE ;
  2322.         NAME REGISTRATION REQUEST (GROUP):
  2323.              IF name exists in local name table THEN
  2324.              BEGIN
  2325.                   IF local entry is a unique name THEN
  2326.                       send NEGATIVE NAME REGISTRATION RESPONSE ;
  2327.              END
  2328.         NAME QUERY REQUEST:
  2329.              IF name exists in local name table THEN
  2330.              BEGIN
  2331.                   build response packet;
  2332.  
  2333.  
  2334.  
  2335. NetBIOS Working Group                                          [Page 39]
  2336.  
  2337.  
  2338. RFC 1002                                                      March 1987
  2339.  
  2340.  
  2341.                   send POSITIVE NAME QUERY RESPONSE;
  2342.         POSITIVE NAME QUERY RESPONSE:
  2343.              IF name conflict timer is not active THEN
  2344.              BEGIN
  2345.                   /*
  2346.                    * timer has expired already...  ignore this
  2347.                    * packet
  2348.                    */
  2349.  
  2350.                   return;
  2351.              END
  2352.              ELSE /* timer is active */
  2353.              IF a response for this name has previously been
  2354.                   received THEN
  2355.              BEGIN /* existing entry */
  2356.  
  2357.                   /*
  2358.                    * we sent out a request packet, and
  2359.                    * have already received (at least)
  2360.                    * one response
  2361.                    *
  2362.                    * Check if conflict exists.
  2363.                    * If so, send out a conflict packet.
  2364.                    *
  2365.                    * Note: detecting conflict does NOT
  2366.                    * affect any existing sessions.
  2367.                    *
  2368.                    */
  2369.  
  2370.                   /*
  2371.                    * Check for name conflict.
  2372.                    * See "Name Conflict" in Concepts and Methods
  2373.                    */
  2374.                   check saved authoritative response against
  2375.                        information in this response packet;
  2376.                   IF conflict detected THEN
  2377.                   BEGIN
  2378.                        unicast NAME CONFLICT DEMAND packet;
  2379.                        IF entry exists in cache THEN
  2380.                        BEGIN
  2381.                             remove entry from cache;
  2382.                        END
  2383.                   END
  2384.              END /* existing entry */
  2385.              ELSE
  2386.              BEGIN
  2387.                   /*
  2388.                    * Note: If this was the first response
  2389.                    * to a name query, it would have been
  2390.                    * handled in the
  2391.                    * find_name() procedure.
  2392.  
  2393.  
  2394.  
  2395. NetBIOS Working Group                                          [Page 40]
  2396.  
  2397.  
  2398. RFC 1002                                                      March 1987
  2399.  
  2400.  
  2401.                    */
  2402.  
  2403.                   ignore packet;
  2404.              END
  2405.         NAME CONFLICT DEMAND:
  2406.              IF name exists in local name table THEN
  2407.              BEGIN
  2408.                   mark name as conflict detected;
  2409.  
  2410.                   /*
  2411.                    * a name in the state "conflict detected"
  2412.                    * does not "logically" exist on that node.
  2413.                    * No further session will be accepted on
  2414.                    * that name.
  2415.                    * No datagrams can be sent against that name.
  2416.                    * Such an entry will not be used for
  2417.                    * purposes of processing incoming request
  2418.                    * packets.
  2419.                    * The only valid user NetBIOS operation
  2420.                    * against such a name is DELETE NAME.
  2421.                    */
  2422.              END
  2423.         NAME RELEASE REQUEST:
  2424.              IF caching is being done THEN
  2425.              BEGIN
  2426.                   remove entry from cache;
  2427.              END
  2428.         NAME UPDATE REQUEST:
  2429.              IF caching is being done THEN
  2430.              BEGIN
  2431.                   IF entry exists in cache already,
  2432.                        update cache;
  2433.                   ELSE IF name is "interesting" THEN
  2434.                   BEGIN
  2435.                        add entry to cache;
  2436.                   END
  2437.              END
  2438.  
  2439.         NODE STATUS REQUEST:
  2440.              IF name exists in local name table THEN
  2441.              BEGIN
  2442.                   /*
  2443.                    * send only those names that are
  2444.                    * in the same scope as the scope
  2445.                    * field in the request packet
  2446.                    */
  2447.  
  2448.                   send NODE STATUS RESPONSE;
  2449.              END
  2450.    END
  2451.  
  2452.  
  2453.  
  2454.  
  2455. NetBIOS Working Group                                          [Page 41]
  2456.  
  2457.  
  2458. RFC 1002                                                      March 1987
  2459.  
  2460.  
  2461. 5.1.2.  P-NODE ACTIVITY
  2462.  
  2463.    All packets sent or received by P nodes are unicast UDP packets.
  2464.    A P node sends name service requests to the NBNS node that is
  2465.    specified in the P-node configuration.
  2466.  
  2467. 5.1.2.1.  P-NODE ADD_NAME
  2468.  
  2469.    PROCEDURE add_name(newname)
  2470.  
  2471.    /*
  2472.     * Host initiated processing for a P node
  2473.     */
  2474.  
  2475.    BEGIN
  2476.  
  2477.         REPEAT
  2478.              /*
  2479.               * build packet
  2480.               */
  2481.  
  2482.              ONT = P;
  2483.              G = UNIQUE;
  2484.              ...
  2485.  
  2486.              /*
  2487.               * send request
  2488.               */
  2489.  
  2490.              unicast NAME REGISTRATION REQUEST packet;
  2491.  
  2492.              /*
  2493.               * NBNS will send response packet
  2494.               */
  2495.  
  2496.              IF receive a WACK RESPONSE THEN
  2497.                   pause(time from TTL field of response);
  2498.              ELSE
  2499.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  2500.         UNTIL response packet is received OR
  2501.              retransmit count has been exceeded
  2502.  
  2503.         IF no response packet was received THEN
  2504.         BEGIN /* no response */
  2505.              /*
  2506.               * NBNS is down.  Cannot claim name.
  2507.               */
  2508.  
  2509.              return failure; /* name cannot be claimed */
  2510.         END /* no response */
  2511.         ELSE
  2512.  
  2513.  
  2514.  
  2515. NetBIOS Working Group                                          [Page 42]
  2516.  
  2517.  
  2518. RFC 1002                                                      March 1987
  2519.  
  2520.  
  2521.         BEGIN /* response */
  2522.             IF NOT response tid = request tid THEN
  2523.             BEGIN
  2524.              /*  Packet may belong to another transaction  */
  2525.              ignore response packet;
  2526.             END
  2527.             ELSE
  2528.             CASE packet type OF
  2529.  
  2530.             POSITIVE NAME REGISTRATION RESPONSE:
  2531.  
  2532.                  /*
  2533.                   * name can be added
  2534.                   */
  2535.  
  2536.                  adjust refresh timeout value, TTL, for this name;
  2537.                  return success;      /* name can be added */
  2538.  
  2539.             NEGATIVE NAME REGISTRATION RESPONSE:
  2540.                  return failure; /* name cannot be added */
  2541.  
  2542.             END-NODE CHALLENGE REGISTRATION REQUEST:
  2543.             BEGIN /* end node challenge */
  2544.  
  2545.                  /*
  2546.                   * The response packet has in it the
  2547.                   * address of the presumed owner of the
  2548.                   * name.  Challenge that owner.
  2549.                   * If owner either does not
  2550.                   * respond or indicates that he no longer
  2551.                   * owns the name, claim the name.
  2552.                   * Otherwise, the name cannot be claimed.
  2553.                   *
  2554.                   */
  2555.  
  2556.                  REPEAT
  2557.                   /*
  2558.                    * build packet
  2559.                    */
  2560.                   ...
  2561.  
  2562.                   unicast NAME QUERY REQUEST packet to the
  2563.                        address contained in the END NODE
  2564.                        CHALLENGE RESPONSE packet;
  2565.  
  2566.                   /*
  2567.                    * remote node may send response packet
  2568.                    */
  2569.  
  2570.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  2571.  
  2572.  
  2573.  
  2574.  
  2575. NetBIOS Working Group                                          [Page 43]
  2576.  
  2577.  
  2578. RFC 1002                                                      March 1987
  2579.  
  2580.  
  2581.                  UNTIL response packet is received or
  2582.                      retransmit count has been exceeded
  2583.                  IF no response packet is received OR
  2584.                        NEGATIVE NAME QUERY RESPONSE packet
  2585.                        received THEN
  2586.                  BEGIN /* update */
  2587.  
  2588.                   /*
  2589.                    * name can be claimed
  2590.                    */
  2591.  
  2592.                   REPEAT
  2593.  
  2594.                       /*
  2595.                        * build packet
  2596.                        */
  2597.                        ...
  2598.  
  2599.                       unicast NAME UPDATE REQUEST to NBNS;
  2600.  
  2601.                       /*
  2602.                        * NBNS node will send response packet
  2603.                        */
  2604.  
  2605.                       IF receive a WACK RESPONSE THEN
  2606.                             pause(time from TTL field of response);
  2607.                       ELSE
  2608.                             pause(UCAST_REQ_RETRY_TIMEOUT);
  2609.                   UNTIL response packet is received or
  2610.                       retransmit count has been exceeded
  2611.                   IF no response packet received THEN
  2612.                   BEGIN /* no response */
  2613.  
  2614.                        /*
  2615.                         * name could not be claimed
  2616.                         */
  2617.  
  2618.                        return failure;
  2619.                   END /* no response */
  2620.                   ELSE
  2621.                   CASE packet type OF
  2622.                        POSITIVE NAME REGISTRATION RESPONSE:
  2623.                             /*
  2624.                              * add name
  2625.                              */
  2626.                             return success;
  2627.                        NEGATIVE NAME REGISTRATION RESPONSE:
  2628.  
  2629.                             /*
  2630.                              * you lose  ...
  2631.                              */
  2632.  
  2633.  
  2634.  
  2635. NetBIOS Working Group                                          [Page 44]
  2636.  
  2637.  
  2638. RFC 1002                                                      March 1987
  2639.  
  2640.  
  2641.                             return failure;
  2642.                        END /* case */
  2643.                  END /* update */
  2644.                  ELSE
  2645.  
  2646.                  /*
  2647.                   * received a positive response to the "challenge"
  2648.                   * Remote node still has name
  2649.                   */
  2650.  
  2651.                   return failure;
  2652.             END /* end node challenge */
  2653.         END /* response */
  2654.    END /* procedure */
  2655.  
  2656. 5.1.2.2.  P-NODE ADD GROUP NAME
  2657.  
  2658.    PROCEDURE add_group_name(newname)
  2659.  
  2660.    /*
  2661.     * Host initiated processing for a P node
  2662.     */
  2663.  
  2664.    BEGIN
  2665.         /*
  2666.          * same as for a unique name, except that the
  2667.          * request packet must indicate that a
  2668.          * group name claim is being made.
  2669.          */
  2670.  
  2671.         ...
  2672.         G = GROUP;
  2673.         ...
  2674.  
  2675.         /*
  2676.          * send packet
  2677.          */
  2678.          ...
  2679.  
  2680.  
  2681.    END
  2682.  
  2683.    5.1.2.3.  P-NODE FIND NAME
  2684.  
  2685.    PROCEDURE find_name(name)
  2686.  
  2687.    /*
  2688.     * Host initiated processing for a P node
  2689.     */
  2690.  
  2691.    BEGIN
  2692.  
  2693.  
  2694.  
  2695. NetBIOS Working Group                                          [Page 45]
  2696.  
  2697.  
  2698. RFC 1002                                                      March 1987
  2699.  
  2700.  
  2701.         REPEAT
  2702.              /*
  2703.               * build packet
  2704.               */
  2705.  
  2706.              ONT = P;
  2707.              G = DONT CARE;
  2708.  
  2709.              unicast NAME QUERY REQUEST packet;
  2710.  
  2711.              /*
  2712.               * a NBNS node might send response packet
  2713.               */
  2714.  
  2715.              IF receive a WACK RESPONSE THEN
  2716.                   pause(time from TTL field of response);
  2717.              ELSE
  2718.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  2719.         UNTIL response packet received OR
  2720.              max transmit threshold exceeded
  2721.  
  2722.         IF no response packet received THEN
  2723.              return failure;
  2724.         ELSE
  2725.         IF NOT response tid = request tid THEN
  2726.              ignore packet;
  2727.         ELSE
  2728.         CASE packet type OF
  2729.         POSITIVE NAME QUERY RESPONSE:
  2730.              return success;
  2731.  
  2732.         REDIRECT NAME QUERY RESPONSE:
  2733.  
  2734.              /*
  2735.               * NBNS node wants this end node
  2736.               * to use some other NBNS node
  2737.               * to resolve the query.
  2738.               */
  2739.  
  2740.               repeat query with NBNS address
  2741.                   in the response packet;
  2742.         NEGATIVE NAME QUERY RESPONSE:
  2743.              return failure;
  2744.  
  2745.         END /* case */
  2746.    END /* procedure */
  2747.  
  2748. 5.1.2.4.  P-NODE DELETE_NAME
  2749.  
  2750.    PROCEDURE delete_name (name)
  2751.  
  2752.  
  2753.  
  2754.  
  2755. NetBIOS Working Group                                          [Page 46]
  2756.  
  2757.  
  2758. RFC 1002                                                      March 1987
  2759.  
  2760.  
  2761.    /*
  2762.     * Host initiated processing for a P node
  2763.     */
  2764.  
  2765.    BEGIN
  2766.  
  2767.         REPEAT
  2768.  
  2769.              /*
  2770.               * build packet
  2771.               */
  2772.              ...
  2773.  
  2774.              /*
  2775.               * send request
  2776.               */
  2777.  
  2778.              unicast NAME RELEASE REQUEST packet;
  2779.              IF receive a WACK RESPONSE THEN
  2780.                   pause(time from TTL field of response);
  2781.              ELSE
  2782.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  2783.         UNTIL retransmit count has been exceeded
  2784.              or response been received
  2785.  
  2786.         IF response has been received THEN
  2787.         CASE packet type OF
  2788.         POSITIVE NAME RELEASE RESPONSE:
  2789.              return success;
  2790.         NEGATIVE NAME RELEASE RESPONSE:
  2791.  
  2792.              /*
  2793.               * NBNS does want node to delete this
  2794.               * name !!!
  2795.               */
  2796.  
  2797.              return failure;
  2798.         END /* case */
  2799.    END /* procedure */
  2800.  
  2801. 5.1.2.5.  P-NODE INCOMING PACKET PROCESSING
  2802.  
  2803.    Processing initiated by reception of packets at a P node
  2804.  
  2805.    PROCEDURE process_incoming_packet(packet)
  2806.  
  2807.    /*
  2808.     * Processing initiated by incoming packets at a P node
  2809.     */
  2810.  
  2811.    BEGIN
  2812.  
  2813.  
  2814.  
  2815. NetBIOS Working Group                                          [Page 47]
  2816.  
  2817.  
  2818. RFC 1002                                                      March 1987
  2819.  
  2820.  
  2821.         /*
  2822.          * always ignore UDP broadcast packets
  2823.          */
  2824.  
  2825.         IF packet was sent as a broadcast THEN
  2826.         BEGIN
  2827.              ignore packet;
  2828.              return;
  2829.         END
  2830.         CASE packet type of
  2831.  
  2832.         NAME CONFLICT DEMAND:
  2833.              IF name exists in local name table THEN
  2834.                   mark name as in conflict;
  2835.              return;
  2836.  
  2837.         NAME QUERY REQUEST:
  2838.              IF name exists in local name table THEN
  2839.              BEGIN /* name exists */
  2840.  
  2841.                   /*
  2842.                    * build packet
  2843.                    */
  2844.                   ...
  2845.  
  2846.                   /*
  2847.                    * send response to the IP address and port
  2848.                    * number from which the request was received.
  2849.                    */
  2850.  
  2851.                   send POSITIVE NAME QUERY RESPONSE ;
  2852.                   return;
  2853.              END /* exists */
  2854.              ELSE
  2855.              BEGIN /* does not exist */
  2856.  
  2857.                   /*
  2858.                    * send response to the requestor
  2859.                    */
  2860.  
  2861.                   send NEGATIVE NAME QUERY RESPONSE ;
  2862.                   return;
  2863.              END /* does not exist */
  2864.         NODE STATUS REQUEST:
  2865.              /*
  2866.               * Name of "*" may be used for force node to
  2867.               * divulge status for administrative purposes
  2868.               */
  2869.              IF name in local name table OR name = "*" THEN
  2870.              BEGIN
  2871.                   /*
  2872.  
  2873.  
  2874.  
  2875. NetBIOS Working Group                                          [Page 48]
  2876.  
  2877.  
  2878. RFC 1002                                                      March 1987
  2879.  
  2880.  
  2881.                    * Build response packet and
  2882.                    * send to requestor node
  2883.                    * Send only those names that are
  2884.                    * in the same scope as the scope
  2885.                    * in the request packet.
  2886.                    */
  2887.  
  2888.                   send NODE STATUS RESPONSE;
  2889.              END
  2890.  
  2891.         NAME RELEASE REQUEST:
  2892.              /*
  2893.               * This will be received if the NBNS wants to flush the
  2894.               * name from the local name table, or from the local
  2895.               * cache.
  2896.               */
  2897.  
  2898.              IF name exists in the local name table THEN
  2899.              BEGIN
  2900.                   delete name from local name table;
  2901.                   inform user that name has been deleted;
  2902.              END
  2903.              ELSE
  2904.                   IF name has been cached locally THEN
  2905.                   BEGIN
  2906.                        remove entry from cache:
  2907.                   END
  2908.  
  2909.         END /* case */
  2910.    END /* procedure */
  2911.  
  2912. 5.1.2.6.  P-NODE TIMER INITIATED PROCESSING
  2913.  
  2914.    Processing initiated by timer expiration.
  2915.  
  2916.    PROCEDURE timer_expired()
  2917.    /*
  2918.     * Processing initiated by the expiration of a timer on a P node
  2919.     */
  2920.    BEGIN
  2921.         /*
  2922.          * Send a NAME REFRESH REQUEST for each name which the
  2923.          * TTL which has expired.
  2924.          */
  2925.         REPEAT
  2926.              build NAME REFRESH REQUEST packet;
  2927.              REPEAT
  2928.                   send packet to NBNS;
  2929.  
  2930.                   IF receive a WACK RESPONSE THEN
  2931.                        pause(time from TTL field of response);
  2932.  
  2933.  
  2934.  
  2935. NetBIOS Working Group                                          [Page 49]
  2936.  
  2937.  
  2938. RFC 1002                                                      March 1987
  2939.  
  2940.  
  2941.                   ELSE
  2942.                        pause(UCAST_REQ_RETRY_TIMEOUT);
  2943.              UNTIL response packet is received or
  2944.                   retransmit count has been exceeded
  2945.  
  2946.              CASE packet type OF
  2947.                POSITIVE NAME REGISTRATION RESPONSE:
  2948.                   /* successfully refreshed */
  2949.                   reset TTL timer for this name;
  2950.  
  2951.                NEGATIVE NAME REGISTRATION RESPONSE:
  2952.                   /*
  2953.                    * refused, can't keep name
  2954.                    * assume in conflict
  2955.                    */
  2956.                   mark name as in conflict;
  2957.              END /* case */
  2958.  
  2959.         UNTIL request sent for all names for which TTL
  2960.              has expired
  2961.    END /* procedure */
  2962.  
  2963. 5.1.3.  M-NODE ACTIVITY
  2964.  
  2965.    M nodes behavior is similar to that of P nodes with the addition
  2966.    of some B node-like broadcast actions.  M node name service
  2967.    proceeds in two steps:
  2968.  
  2969.    1.Use broadcast UDP based name service.  Depending on the
  2970.      operation, goto step 2.
  2971.  
  2972.    2.Use directed UDP name service.
  2973.  
  2974.    The following code for M nodes is exactly the same as for a P
  2975.    node, with the exception that broadcast operations are done
  2976.    before P type operation is attempted.
  2977.  
  2978.    5.1.3.1.  M-NODE ADD NAME
  2979.  
  2980.    PROCEDURE add_name(newname)
  2981.  
  2982.    /*
  2983.     * Host initiated processing for a M node
  2984.     */
  2985.  
  2986.    BEGIN
  2987.  
  2988.         /*
  2989.          * check if name exists on the
  2990.          * broadcast area
  2991.          */
  2992.  
  2993.  
  2994.  
  2995. NetBIOS Working Group                                          [Page 50]
  2996.  
  2997.  
  2998. RFC 1002                                                      March 1987
  2999.  
  3000.  
  3001.         REPEAT
  3002.             /* build packet */
  3003.  
  3004.             ....
  3005.             broadcast NAME REGISTRATION REQUEST packet;
  3006.             pause(BCAST_REQ_RETRY_TIMEOUT);
  3007.  
  3008.         UNTIL response packet is received or
  3009.              retransmit count has been  exceeded
  3010.  
  3011.         IF valid response received THEN
  3012.         BEGIN
  3013.              /* cannot claim name */
  3014.  
  3015.              return failure;
  3016.         END
  3017.  
  3018.         /*
  3019.          * No objections received within the
  3020.          * broadcast area.
  3021.          * Send request to name server.
  3022.          */
  3023.  
  3024.         REPEAT
  3025.              /*
  3026.               * build packet
  3027.               */
  3028.  
  3029.              ONT = M;
  3030.              ...
  3031.  
  3032.              unicast NAME REGISTRATION REQUEST packet;
  3033.  
  3034.              /*
  3035.               * remote NBNS will send response packet
  3036.               */
  3037.  
  3038.              IF receive a WACK RESPONSE THEN
  3039.                   pause(time from TTL field of response);
  3040.              ELSE
  3041.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  3042.  
  3043.         UNTIL response packet is received or
  3044.              retransmit count has been exceeded
  3045.  
  3046.         IF no response packet was received THEN
  3047.         BEGIN /* no response */
  3048.              /*
  3049.               * NBNS is down.  Cannot claim name.
  3050.               */
  3051.  
  3052.  
  3053.  
  3054.  
  3055. NetBIOS Working Group                                          [Page 51]
  3056.  
  3057.  
  3058. RFC 1002                                                      March 1987
  3059.  
  3060.  
  3061.              return failure; /* name cannot be claimed */
  3062.         END /* no response */
  3063.         ELSE
  3064.         BEGIN /* response */
  3065.             IF NOT response tid = request tid THEN
  3066.             BEGIN
  3067.              ignore response packet;
  3068.             END
  3069.             ELSE
  3070.             CASE packet type OF
  3071.             POSITIVE NAME REGISTRATION RESPONSE:
  3072.  
  3073.                  /*
  3074.                   * name can be added
  3075.                   */
  3076.  
  3077.                  adjust refresh timeout value, TTL;
  3078.                  return success;      /* name can be added */
  3079.  
  3080.             NEGATIVE NAME REGISTRATION RESPONSE:
  3081.                  return failure; /* name cannot be added */
  3082.  
  3083.             END-NODE CHALLENGE REGISTRATION REQUEST:
  3084.             BEGIN /* end node challenge */
  3085.  
  3086.                  /*
  3087.                   * The response packet has in it the
  3088.                   * address of the presumed owner of the
  3089.                   * name.  Challenge that owner.
  3090.                   * If owner either does not
  3091.                   * respond or indicates that he no longer
  3092.                   * owns the name, claim the name.
  3093.                   * Otherwise, the name cannot be claimed.
  3094.                   *
  3095.                   */
  3096.  
  3097.                  REPEAT
  3098.                   /*
  3099.                    * build packet
  3100.                    */
  3101.                   ...
  3102.  
  3103.                   /*
  3104.                    * send packet to address contained in the
  3105.                    * response packet
  3106.                    */
  3107.  
  3108.                   unicast NAME QUERY REQUEST packet;
  3109.  
  3110.                   /*
  3111.                    * remote node may send response packet
  3112.  
  3113.  
  3114.  
  3115. NetBIOS Working Group                                          [Page 52]
  3116.  
  3117.  
  3118. RFC 1002                                                      March 1987
  3119.  
  3120.  
  3121.                    */
  3122.  
  3123.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  3124.  
  3125.                  UNTIL response packet is received or
  3126.                      retransmit count has been exceeded
  3127.                  IF no response packet is received THEN
  3128.                  BEGIN /* no response */
  3129.  
  3130.                   /*
  3131.                    * name can be claimed
  3132.                    */
  3133.                   REPEAT
  3134.  
  3135.                       /*
  3136.                        * build packet
  3137.                        */
  3138.                        ...
  3139.  
  3140.                       unicast NAME UPDATE REQUEST to NBNS;
  3141.  
  3142.                       /*
  3143.                        * NBNS node will send response packet
  3144.                        */
  3145.  
  3146.                       IF receive a WACK RESPONSE THEN
  3147.                             pause(time from TTL field of response);
  3148.                   ELSE
  3149.                        pause(UCAST_REQ_RETRY_TIMEOUT);
  3150.  
  3151.                   UNTIL response packet is received or
  3152.                       retransmit count has been exceeded
  3153.                   IF no response packet received THEN
  3154.                   BEGIN /* no response */
  3155.  
  3156.                        /*
  3157.                         * name could not be claimed
  3158.                         */
  3159.  
  3160.                        return failure;
  3161.                   END /* no response */
  3162.                   ELSE
  3163.                   CASE packet type OF
  3164.                   POSITIVE NAME REGISTRATION RESPONSE:
  3165.                        /*
  3166.                         * add name
  3167.                         */
  3168.  
  3169.                        return success;
  3170.                   NEGATIVE NAME REGISTRATION RESPONSE:
  3171.  
  3172.  
  3173.  
  3174.  
  3175. NetBIOS Working Group                                          [Page 53]
  3176.  
  3177.  
  3178. RFC 1002                                                      March 1987
  3179.  
  3180.  
  3181.                        /*
  3182.                         * you lose  ...
  3183.                         */
  3184.  
  3185.                        return failure;
  3186.                   END /* case */
  3187.                  END /* no response */
  3188.                  ELSE
  3189.                  IF NOT response tid = request tid THEN
  3190.                  BEGIN
  3191.                   ignore response packet;
  3192.                  END
  3193.  
  3194.                  /*
  3195.                   * received a response to the "challenge"
  3196.                   * packet
  3197.                   */
  3198.  
  3199.                  CASE packet type OF
  3200.                  POSITIVE NAME QUERY:
  3201.  
  3202.                   /*
  3203.                    * remote node still has name.
  3204.                    */
  3205.  
  3206.                   return failure;
  3207.                  NEGATIVE NAME QUERY:
  3208.  
  3209.                   /*
  3210.                    * remote node no longer has name
  3211.                    */
  3212.  
  3213.                   return success;
  3214.                  END /* case */
  3215.             END /* end node challenge */
  3216.             END /* case */
  3217.         END /* response */
  3218.    END /* procedure */
  3219.  
  3220. 5.1.3.2.  M-NODE ADD GROUP NAME
  3221.  
  3222.    PROCEDURE add_group_name(newname)
  3223.  
  3224.    /*
  3225.     * Host initiated processing for a P node
  3226.     */
  3227.  
  3228.    BEGIN
  3229.         /*
  3230.          * same as for a unique name, except that the
  3231.          * request packet must indicate that a
  3232.  
  3233.  
  3234.  
  3235. NetBIOS Working Group                                          [Page 54]
  3236.  
  3237.  
  3238. RFC 1002                                                      March 1987
  3239.  
  3240.  
  3241.          * group name claim is being made.
  3242.          */
  3243.  
  3244.         ...
  3245.         G = GROUP;
  3246.         ...
  3247.  
  3248.         /*
  3249.          * send packet
  3250.          */
  3251.          ...
  3252.  
  3253.  
  3254.    END
  3255.  
  3256. 5.1.3.3.  M-NODE FIND NAME
  3257.  
  3258.    PROCEDURE find_name(name)
  3259.  
  3260.    /*
  3261.     * Host initiated processing for a M node
  3262.     */
  3263.  
  3264.    BEGIN
  3265.         /*
  3266.          * check if any node on the broadcast
  3267.          * area has the name
  3268.          */
  3269.  
  3270.         REPEAT
  3271.              /* build packet */
  3272.              ...
  3273.  
  3274.              broadcast NAME QUERY REQUEST packet;
  3275.              pause(BCAST_REQ_RETRY_TIMEOUT);
  3276.         UNTIL response packet received OR
  3277.              max transmit threshold exceeded
  3278.  
  3279.         IF valid response received THEN
  3280.         BEGIN
  3281.              save response as authoritative response;
  3282.              start_timer(CONFLICT_TIMER);
  3283.              return success;
  3284.         END
  3285.  
  3286.         /*
  3287.          * no valid response on the b'cast segment.
  3288.          * Try the name server.
  3289.          */
  3290.  
  3291.         REPEAT
  3292.  
  3293.  
  3294.  
  3295. NetBIOS Working Group                                          [Page 55]
  3296.  
  3297.  
  3298. RFC 1002                                                      March 1987
  3299.  
  3300.  
  3301.              /*
  3302.               * build packet
  3303.               */
  3304.  
  3305.              ONT = M;
  3306.              G = DONT CARE;
  3307.  
  3308.              unicast NAME QUERY REQUEST packet to NBNS;
  3309.  
  3310.              /*
  3311.               * a NBNS node might send response packet
  3312.               */
  3313.  
  3314.              IF receive a WACK RESPONSE THEN
  3315.                   pause(time from TTL field of response);
  3316.              ELSE
  3317.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  3318.         UNTIL response packet received OR
  3319.              max transmit threshold exceeded
  3320.  
  3321.         IF no response packet received THEN
  3322.              return failure;
  3323.         ELSE
  3324.         IF NOT response tid = request tid THEN
  3325.              ignore packet;
  3326.         ELSE
  3327.         CASE packet type OF
  3328.         POSITIVE NAME QUERY RESPONSE:
  3329.              return success;
  3330.  
  3331.         REDIRECT NAME QUERY RESPONSE:
  3332.  
  3333.              /*
  3334.               * NBNS node wants this end node
  3335.               * to use some other NBNS node
  3336.               * to resolve the query.
  3337.               */
  3338.  
  3339.               repeat query with NBNS address
  3340.                   in the response packet;
  3341.         NEGATIVE NAME QUERY RESPONSE:
  3342.              return failure;
  3343.  
  3344.         END /* case */
  3345.    END /* procedure */
  3346.  
  3347. 5.1.3.4.  M-NODE DELETE NAME
  3348.  
  3349.    PROCEDURE delete_name (name)
  3350.  
  3351.    /*
  3352.  
  3353.  
  3354.  
  3355. NetBIOS Working Group                                          [Page 56]
  3356.  
  3357.  
  3358. RFC 1002                                                      March 1987
  3359.  
  3360.  
  3361.     * Host initiated processing for a P node
  3362.     */
  3363.  
  3364.    BEGIN
  3365.         /*
  3366.          * First, delete name on NBNS
  3367.          */
  3368.  
  3369.         REPEAT
  3370.  
  3371.              /*
  3372.               * build packet
  3373.               */
  3374.              ...
  3375.  
  3376.              /*
  3377.               * send request
  3378.               */
  3379.  
  3380.              unicast NAME RELEASE REQUEST packet to NBNS;
  3381.  
  3382.              IF receive a WACK RESPONSE THEN
  3383.                   pause(time from TTL field of response);
  3384.              ELSE
  3385.                   pause(UCAST_REQ_RETRY_TIMEOUT);
  3386.         UNTIL retransmit count has been exceeded
  3387.              or response been received
  3388.  
  3389.         IF response has been received THEN
  3390.         CASE packet type OF
  3391.         POSITIVE NAME RELEASE RESPONSE:
  3392.              /*
  3393.               * Deletion of name on b'cast segment is deferred
  3394.               * until after NBNS has deleted the name
  3395.               */
  3396.  
  3397.              REPEAT
  3398.                   /* build packet */
  3399.  
  3400.                   ...
  3401.                   broadcast NAME RELEASE REQUEST;
  3402.                   pause(BCAST_REQ_RETRY_TIMEOUT);
  3403.              UNTIL rexmt threshold exceeded
  3404.  
  3405.              return success;
  3406.         NEGATIVE NAME RELEASE RESPONSE:
  3407.  
  3408.              /*
  3409.               * NBNS does want node to delete this
  3410.               * name
  3411.               */
  3412.  
  3413.  
  3414.  
  3415. NetBIOS Working Group                                          [Page 57]
  3416.  
  3417.  
  3418. RFC 1002                                                      March 1987
  3419.  
  3420.  
  3421.              return failure;
  3422.         END /* case */
  3423.    END /* procedure */
  3424.  
  3425. 5.1.3.5.  M-NODE INCOMING PACKET PROCESSING
  3426.  
  3427.    Processing initiated by reception of packets at a M node
  3428.  
  3429.    PROCEDURE process_incoming_packet(packet)
  3430.  
  3431.    /*
  3432.     * Processing initiated by incoming packets at a M node
  3433.     */
  3434.  
  3435.    BEGIN
  3436.         CASE packet type of
  3437.  
  3438.         NAME CONFLICT DEMAND:
  3439.              IF name exists in local name table THEN
  3440.                   mark name as in conflict;
  3441.              return;
  3442.  
  3443.         NAME QUERY REQUEST:
  3444.              IF name exists in local name table THEN
  3445.              BEGIN /* name exists */
  3446.  
  3447.                   /*
  3448.                    * build packet
  3449.                    */
  3450.                   ...
  3451.  
  3452.                   /*
  3453.                    * send response to the IP address and port
  3454.                    * number from which the request was received.
  3455.                    */
  3456.  
  3457.                   send POSITIVE NAME QUERY RESPONSE ;
  3458.                   return;
  3459.              END /* exists */
  3460.              ELSE
  3461.              BEGIN /* does not exist */
  3462.  
  3463.                   /*
  3464.                    * send response to the requestor
  3465.                    */
  3466.  
  3467.                   IF request NOT broadcast THEN
  3468.                        /*
  3469.                         * Don't send negative responses to
  3470.                         * queries sent by B nodes
  3471.                         */
  3472.  
  3473.  
  3474.  
  3475. NetBIOS Working Group                                          [Page 58]
  3476.  
  3477.  
  3478. RFC 1002                                                      March 1987
  3479.  
  3480.  
  3481.                        send NEGATIVE NAME QUERY RESPONSE ;
  3482.                   return;
  3483.              END /* does not exist */
  3484.         NODE STATUS REQUEST:
  3485.              BEGIN
  3486.              /*
  3487.               * Name of "*" may be used for force node to
  3488.               * divulge status for administrative purposes
  3489.               */
  3490.              IF name in local name table OR name = "*" THEN
  3491.                   /*
  3492.                    * Build response packet and
  3493.                    * send to requestor node
  3494.                    * Send only those names that are
  3495.                    * in the same scope as the scope
  3496.                    * in the request packet.
  3497.                    */
  3498.  
  3499.                   send NODE STATUS RESPONSE;
  3500.              END
  3501.  
  3502.         NAME RELEASE REQUEST:
  3503.              /*
  3504.               * This will be received if the NBNS wants to flush the
  3505.               * name from the local name table, or from the local
  3506.               * cache.
  3507.               */
  3508.  
  3509.              IF name exists in the local name table THEN
  3510.              BEGIN
  3511.                   delete name from local name table;
  3512.                   inform user that name has been deleted;
  3513.              END
  3514.              ELSE
  3515.                   IF name has been cached locally THEN
  3516.                   BEGIN
  3517.                        remove entry from cache:
  3518.                   END
  3519.  
  3520.         NAME REGISTRATION REQUEST (UNIQUE):
  3521.              IF name exists in local name table THEN
  3522.                   send NEGATIVE NAME REGISTRATION RESPONSE ;
  3523.         NAME REGISTRATION REQUEST (GROUP):
  3524.              IF name exists in local name table THEN
  3525.              BEGIN
  3526.                   IF local entry is a unique name THEN
  3527.                       send NEGATIVE NAME REGISTRATION RESPONSE ;
  3528.              END
  3529.         END /* case */
  3530.    END /* procedure */
  3531.  
  3532.  
  3533.  
  3534.  
  3535. NetBIOS Working Group                                          [Page 59]
  3536.  
  3537.  
  3538. RFC 1002                                                      March 1987
  3539.  
  3540.  
  3541. 5.1.3.6.  M-NODE TIMER INITIATED PROCESSING
  3542.  
  3543.    Processing initiated by timer expiration:
  3544.  
  3545.    PROCEDURE timer_expired()
  3546.    /*
  3547.     * Processing initiated by the expiration of a timer on a M node
  3548.     */
  3549.    BEGIN
  3550.         /*
  3551.          * Send a NAME REFRESH REQUEST for each name which the
  3552.          * TTL which has expired.
  3553.          */
  3554.         REPEAT
  3555.              build NAME REFRESH REQUEST packet;
  3556.              REPEAT
  3557.                   send packet to NBNS;
  3558.  
  3559.                   IF receive a WACK RESPONSE THEN
  3560.                        pause(time from TTL field of response);
  3561.                   ELSE
  3562.                        pause(UCAST_REQ_RETRY_TIMEOUT);
  3563.              UNTIL response packet is received or
  3564.                   retransmit count has been exceeded
  3565.  
  3566.              CASE packet type OF
  3567.                POSITIVE NAME REGISTRATION RESPONSE:
  3568.                   /* successfully refreshed */
  3569.                   reset TTL timer for this name;
  3570.  
  3571.                NEGATIVE NAME REGISTRATION RESPONSE:
  3572.                   /*
  3573.                    * refused, can't keep name
  3574.                    * assume in conflict
  3575.                    */
  3576.                   mark name as in conflict;
  3577.              END /* case */
  3578.  
  3579.         UNTIL request sent for all names for which TTL
  3580.              has expired
  3581.    END /* procedure */
  3582.  
  3583. 5.1.4.  NBNS ACTIVITY
  3584.  
  3585.    A NBNS node will receive directed packets from P and M nodes.
  3586.    Reply packets are always sent as directed packets to the source
  3587.    IP address and UDP port number.  Received broadcast packets must
  3588.    be ignored.
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595. NetBIOS Working Group                                          [Page 60]
  3596.  
  3597.  
  3598. RFC 1002                                                      March 1987
  3599.  
  3600.  
  3601. 5.1.4.1.  NBNS INCOMING PACKET PROCESSING
  3602.  
  3603.    PROCEDURE process_incoming_packet(packet)
  3604.  
  3605.    /*
  3606.     * Incoming packet processing on a NS node
  3607.     */
  3608.  
  3609.    BEGIN
  3610.         IF packet was sent as a broadcast THEN
  3611.         BEGIN
  3612.              discard packet;
  3613.              return;
  3614.         END
  3615.         CASE packet type of
  3616.  
  3617.         NAME REGISTRATION REQUEST (UNIQUE):
  3618.              IF unique name exists in data base THEN
  3619.              BEGIN /* unique name exists */
  3620.                   /*
  3621.                    * NBNS node may be a "passive"
  3622.                    * server in that it expects the
  3623.                    * end node to do the challenge
  3624.                    * server.  Such a NBNS node is
  3625.                    * called a "non-secure" server.
  3626.                    * A "secure" server will do the
  3627.                    * challenging before it sends
  3628.                    * back a response packet.
  3629.                    */
  3630.  
  3631.                   IF non-secure THEN
  3632.                   BEGIN
  3633.                        /*
  3634.                         * build response packet
  3635.                         */
  3636.                        ...
  3637.  
  3638.  
  3639.                        /*
  3640.                         * let end node do the challenge
  3641.                         */
  3642.  
  3643.                        send END-NODE CHALLENGE NAME REGISTRATION
  3644.                             RESPONSE;
  3645.                        return;
  3646.                   END
  3647.                   ELSE
  3648.                   /*
  3649.                    * secure server - do the name
  3650.                    * challenge operation
  3651.                    */
  3652.  
  3653.  
  3654.  
  3655. NetBIOS Working Group                                          [Page 61]
  3656.  
  3657.  
  3658. RFC 1002                                                      March 1987
  3659.  
  3660.  
  3661.                   REPEAT
  3662.                       send NAME QUERY REQUEST;
  3663.                       pause(UCAST_REQ_RETRY_TIMEOUT);
  3664.                   UNTIL response has been received or
  3665.                        retransmit count has been exceeded
  3666.                   IF no response was received THEN
  3667.                   BEGIN
  3668.  
  3669.                        /* node down */
  3670.  
  3671.                        update data base - remove entry;
  3672.                        update data base - add new entry;
  3673.                        send POSITIVE NAME REGISTRATION RESPONSE;
  3674.                        return;
  3675.                   END
  3676.                   ELSE
  3677.                   BEGIN /* challenged node replied */
  3678.                       /*
  3679.                        * challenged node replied with
  3680.                        * a response packet
  3681.                        */
  3682.  
  3683.                       CASE packet type
  3684.  
  3685.                       POSITIVE NAME QUERY RESPONSE:
  3686.  
  3687.                        /*
  3688.                         * name still owned by the
  3689.                         * challenged node
  3690.                         *
  3691.                         * build packet and send response
  3692.                         */
  3693.                         ...
  3694.  
  3695.  
  3696.                        /*
  3697.                         * Note: The NBNS will need to
  3698.                         * keep track (based on transaction id) of
  3699.                         * the IP address and port number
  3700.                         * of the original requestor.
  3701.                         */
  3702.  
  3703.                        send NEGATIVE NAME REGISTRATION RESPONSE;
  3704.                        return;
  3705.                       NEGATIVE NAME QUERY RESPONSE:
  3706.  
  3707.                        update data base - remove entry;
  3708.                        update data base - add new  entry;
  3709.  
  3710.                        /*
  3711.                         * build response packet and send
  3712.  
  3713.  
  3714.  
  3715. NetBIOS Working Group                                          [Page 62]
  3716.  
  3717.  
  3718. RFC 1002                                                      March 1987
  3719.  
  3720.  
  3721.                         * response
  3722.                         */
  3723.                        send POSITIVE NAME REGISTRATION RESPONSE;
  3724.                        return;
  3725.                       END /* case */
  3726.                   END /* challenged node replied */
  3727.              END /* unique name exists in data base */
  3728.              ELSE
  3729.              IF group name exists in data base THEN
  3730.              BEGIN /* group names exists */
  3731.  
  3732.                   /*
  3733.                    * Members of a group name are NOT
  3734.                    * challenged.
  3735.                    * Make the assumption that
  3736.                    * at least some of the group members
  3737.                    * are still alive.
  3738.                    * Refresh mechanism will
  3739.                    * allow the NBNS to detect when all
  3740.                    * members of a group no longer use that
  3741.                    * name
  3742.                    */
  3743.  
  3744.                    send NEGATIVE NAME REGISTRATION RESPONSE;
  3745.              END /* group name exists */
  3746.              ELSE
  3747.              BEGIN /* name does not exist */
  3748.  
  3749.                   /*
  3750.                    * Name does not exist in data base
  3751.                    *
  3752.                    * This code applies to both non-secure
  3753.                    * and secure server.
  3754.                    */
  3755.  
  3756.                   update data base - add new entry;
  3757.                   send POSITIVE NAME REGISTRATION RESPONSE;
  3758.                   return;
  3759.              END
  3760.  
  3761.         NAME QUERY REQUEST:
  3762.              IF name exists in data base THEN
  3763.              BEGIN
  3764.                   /*
  3765.                    * build response packet and send to
  3766.                    * requestor
  3767.                    */
  3768.                    ...
  3769.  
  3770.                   send POSITIVE NAME QUERY RESPONSE;
  3771.                   return;
  3772.  
  3773.  
  3774.  
  3775. NetBIOS Working Group                                          [Page 63]
  3776.  
  3777.  
  3778. RFC 1002                                                      March 1987
  3779.  
  3780.  
  3781.              ELSE
  3782.              BEGIN
  3783.                   /*
  3784.                    * build response packet and send to
  3785.                    * requestor
  3786.                    */
  3787.                    ...
  3788.  
  3789.                   send NEGATIVE NAME QUERY RESPONSE;
  3790.                   return;
  3791.              END
  3792.  
  3793.         NAME REGISTRATION REQUEST (GROUP):
  3794.              IF name exists in data base THEN
  3795.              BEGIN
  3796.                   IF local entry is a unique name THEN
  3797.                   BEGIN /* local is unique */
  3798.  
  3799.                       IF non-secure THEN
  3800.                       BEGIN
  3801.                        send  END-NODE CHALLENGE NAME
  3802.                             REGISTRATION RESPONSE;
  3803.                        return;
  3804.                       END
  3805.  
  3806.                       REPEAT
  3807.                        send NAME QUERY REQUEST;
  3808.                        pause(UCAST_REQ_RETRY_TIMEOUT);
  3809.                       UNTIL response received or
  3810.                            retransmit count exceeded
  3811.                       IF no response received or
  3812.                            NEGATIVE NAME QUERY RESPONSE
  3813.                             received THEN
  3814.                       BEGIN
  3815.                        update data base - remove entry;
  3816.                        update data base - add new entry;
  3817.                        send POSITIVE NAME REGISTRATION RESPONSE;
  3818.                        return;
  3819.                       END
  3820.                       ELSE
  3821.                       BEGIN
  3822.                        /*
  3823.                         * name still being held
  3824.                         * by challenged node
  3825.                         */
  3826.  
  3827.                         send NEGATIVE NAME REGISTRATION RESPONSE;
  3828.                       END
  3829.                   END /* local is unique */
  3830.                   ELSE
  3831.                   BEGIN /* local is group  */
  3832.  
  3833.  
  3834.  
  3835. NetBIOS Working Group                                          [Page 64]
  3836.  
  3837.  
  3838. RFC 1002                                                      March 1987
  3839.  
  3840.  
  3841.                        /*
  3842.                         * existing entry is a group name
  3843.                         */
  3844.  
  3845.                        update data base - remove entry;
  3846.                        update data base - add new entry;
  3847.                        send POSITIVE NAME REGISTRATION RESPONSE;
  3848.                        return;
  3849.                   END /* local is group */
  3850.              END /* names exists */
  3851.              ELSE
  3852.              BEGIN /* does not exist */
  3853.  
  3854.                   /* name does not exist in data base */
  3855.  
  3856.                   update data base - add new entry;
  3857.                   send POSITIVE NAME REGISTRATION RESPONSE;
  3858.                   return;
  3859.              END /* does not exist */
  3860.  
  3861.         NAME RELEASE REQUEST:
  3862.  
  3863.              /*
  3864.               * secure server may choose to disallow
  3865.               * a node from deleting a name
  3866.               */
  3867.  
  3868.              update data base - remove entry;
  3869.              send POSITIVE NAME RELEASE RESPONSE;
  3870.              return;
  3871.  
  3872.         NAME UPDATE REQUEST:
  3873.  
  3874.              /*
  3875.               * End-node completed a successful challenge,
  3876.               * no update database
  3877.               */
  3878.  
  3879.              IF secure server THEN
  3880.                   send NEGATIVE NAME REGISTRATION RESPONSE;
  3881.              ELSE
  3882.              BEGIN /* new entry */
  3883.                   IF entry already exists THEN
  3884.                        update data base - remove entry;
  3885.                   update data base - add new entry;
  3886.                   send POSITIVE NAME REGISTRATION RESPONSE;
  3887.                   start_timer(TTL);
  3888.              END
  3889.  
  3890.         NAME REFRESH REQUEST:
  3891.              check for consistency;
  3892.  
  3893.  
  3894.  
  3895. NetBIOS Working Group                                          [Page 65]
  3896.  
  3897.  
  3898. RFC 1002                                                      March 1987
  3899.  
  3900.  
  3901.              IF node not allowed to have name THEN
  3902.              BEGIN
  3903.  
  3904.                   /*
  3905.                    * tell end node that it can't have name
  3906.                    */
  3907.                   send NEGATIVE NAME REGISTRATION RESPONSE;
  3908.              END
  3909.              ELSE
  3910.              BEGIN
  3911.  
  3912.                   /*
  3913.                    * send confirmation response to the
  3914.                    * end node.
  3915.                    */
  3916.                   send POSITIVE NAME REGISTRATION;
  3917.                   start_timer(TTL);
  3918.              END
  3919.              return;
  3920.         END /* case */
  3921.    END /* procedure */
  3922.  
  3923. 5.1.4.2.  NBNS TIMER INITIATED PROCESSING
  3924.  
  3925.    A NS node uses timers to flush out entries from the data base.
  3926.    Each entry in the data base is removed when its timer expires.
  3927.    This time value is a multiple of the refresh TTL established when
  3928.    the name was registered.
  3929.  
  3930.    PROCEDURE timer_expired()
  3931.  
  3932.    /*
  3933.     * processing initiated by expiration of TTL for a given name
  3934.     */
  3935.  
  3936.    BEGIN
  3937.         /*
  3938.          * NBNS can (optionally) ensure
  3939.          * that the node is actually down
  3940.          * by sending a NODE STATUS REQUEST.
  3941.          * If such a request is sent, and
  3942.          * no response is received, it can
  3943.          * be assumed that the node is down.
  3944.          */
  3945.         remove entry from data base;
  3946.    END
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955. NetBIOS Working Group                                          [Page 66]
  3956.  
  3957.  
  3958. RFC 1002                                                      March 1987
  3959.  
  3960.  
  3961. 5.2.  SESSION SERVICE PROTOCOLS
  3962.  
  3963.    The following are variables and should be configurable by the
  3964.    NetBIOS user.  The default values of these variables is found in
  3965.    "Defined Constants and Variables" in the Detailed
  3966.    Specification.):
  3967.  
  3968.    - SSN_RETRY_COUNT - The maximum number TCP connection attempts
  3969.      allowable per a single NetBIOS call request.
  3970.  
  3971.    - SSN_CLOSE_TIMEOUT is the time period to wait when closing the
  3972.      NetBIOS session before killing the TCP connection if session
  3973.      sends are outstanding.
  3974.  
  3975.    The following are Defined Constants for the NetBIOS Session
  3976.    Service.  (See "Defined Constants and Variables" in the Detailed
  3977.    Specification for the value of these constants):
  3978.  
  3979.    - SSN_SRVC_TCP_PORT - is the globally well-known TCP port
  3980.      allocated for the NetBIOS Session Service.  The service accepts
  3981.      TCP connections on this port to establish NetBIOS Sessions.
  3982.      The TCP connection established to this port by the caller is
  3983.      initially used for the exchange of NetBIOS control information.
  3984.      The actual NetBIOS data connection may also pass through this
  3985.      port or, through the retargetting facility, through another
  3986.      port.
  3987.  
  3988. 5.2.1.  SESSION ESTABLISHMENT PROTOCOLS
  3989.  
  3990. 5.2.1.1.  USER REQUEST PROCESSING
  3991.  
  3992.    PROCEDURE listen(listening name, caller name)
  3993.    /*
  3994.     * User initiated processing for B, P and M nodes
  3995.     *
  3996.     * This procedure assumes that an incoming session will be
  3997.     * retargetted here by a session server.
  3998.     */
  3999.    BEGIN
  4000.         Do TCP listen; /* Returns TCP port used */
  4001.         Register listen with Session Service, give names and
  4002.              TCP port;
  4003.  
  4004.         Wait for TCP connection to open;   /* Incoming call */
  4005.  
  4006.         Read SESSION REQUEST packet from connection
  4007.  
  4008.         Process session request (see section on
  4009.              processing initiated by the reception of session
  4010.              service packets);
  4011.  
  4012.  
  4013.  
  4014.  
  4015. NetBIOS Working Group                                          [Page 67]
  4016.  
  4017.  
  4018. RFC 1002                                                      March 1987
  4019.  
  4020.  
  4021.         Inform Session Service that NetBIOS listen is complete;
  4022.  
  4023.         IF session established THEN
  4024.              return success and session information to user;
  4025.         ELSE
  4026.              return failure;
  4027.    END /* procedure */
  4028.  
  4029.    PROCEDURE call(calling name, called name)
  4030.    /*
  4031.     * user initiated processing for B, P and M nodes
  4032.     */
  4033.  
  4034.    /*
  4035.     * This algorithm assumes that the called name is a unique name.
  4036.     * If the called name is a group name, the call() procedure
  4037.     * needs to cycle through the members of the group
  4038.     * until either (retry_count == SSN_RETRY_COUNT) or
  4039.     * the list has been exhausted.
  4040.     */
  4041.    BEGIN
  4042.         retry_count = 0;
  4043.         retarget = FALSE;   /* TRUE: caller is being retargetted */
  4044.         name_query = TRUE;  /* TRUE: caller must begin again with */
  4045.                             /*       name query. */
  4046.  
  4047.         REPEAT
  4048.              IF name_query THEN
  4049.              BEGIN
  4050.                   do name discovery, returns IP address;
  4051.                   TCP port = SSN_SRVC_TCP_PORT;
  4052.  
  4053.                   IF name discovery fails THEN
  4054.                        return failure;
  4055.                   ELSE
  4056.                        name_query = FALSE;
  4057.              END
  4058.  
  4059.              /*
  4060.               * now have IP address and TCP port of
  4061.               * remote party.
  4062.               */
  4063.  
  4064.              establish TCP connection with remote party, use an
  4065.                   ephemeral port as source TCP port;
  4066.              IF connection refused THEN
  4067.              BEGIN
  4068.                   IF retarget THEN
  4069.                   BEGIN
  4070.                        /* retry */
  4071.                        retarget = FALSE;
  4072.  
  4073.  
  4074.  
  4075. NetBIOS Working Group                                          [Page 68]
  4076.  
  4077.  
  4078. RFC 1002                                                      March 1987
  4079.  
  4080.  
  4081.                        use original IP address and TCP port;
  4082.                        goto LOOP;
  4083.                   END
  4084.  
  4085.                   /* retry for just missed TCP listen */
  4086.  
  4087.                   pause(SESSION_RETRY_TIMER);
  4088.                   establish TCP connection, again use ephemeral
  4089.                        port as source TCP port;
  4090.  
  4091.                   IF connection refused OR
  4092.                      connection timed out THEN
  4093.                        return failure;
  4094.              END
  4095.              ELSE
  4096.              IF connection timed out THEN
  4097.              BEGIN
  4098.                   IF retarget THEN
  4099.                   BEGIN
  4100.                        /* retry */
  4101.                        retarget = FALSE;
  4102.                        use original IP address and TCP port;
  4103.                        goto LOOP;
  4104.                   END
  4105.                   ELSE
  4106.                   BEGIN
  4107.                        /*
  4108.                         * incorrect name discovery was done,
  4109.                         * try again
  4110.                         */
  4111.  
  4112.                        inform name discovery process of
  4113.                             possible error;
  4114.                        name_query = TRUE;
  4115.                        goto LOOP;
  4116.                   END
  4117.              END
  4118.  
  4119.              /*
  4120.               * TCP connection has been established
  4121.               */
  4122.  
  4123.              wait for session response packet;
  4124.              CASE packet type OF
  4125.  
  4126.                 POSITIVE SESSION RESPONSE:
  4127.                   return success and session established
  4128.                        information;
  4129.  
  4130.                 NEGATIVE SESSION RESPONSE:
  4131.                 BEGIN
  4132.  
  4133.  
  4134.  
  4135. NetBIOS Working Group                                          [Page 69]
  4136.  
  4137.  
  4138. RFC 1002                                                      March 1987
  4139.  
  4140.  
  4141.                   CASE error OF
  4142.                      NOT LISTENING ON CALLED NAME:
  4143.                      NOT LISTENING FOR CALLING NAME:
  4144.                      BEGIN
  4145.                        kill TCP connection;
  4146.                        return failure;
  4147.                      END
  4148.  
  4149.                      CALLED NAME NOT PRESENT:
  4150.                      BEGIN
  4151.                        /*
  4152.                         * called name does not exist on
  4153.                         * remote node
  4154.                         */
  4155.  
  4156.                        inform name discovery procedure
  4157.                             of possible error;
  4158.  
  4159.                        IF this is a P or M node THEN
  4160.                        BEGIN
  4161.                             /*
  4162.                              * Inform NetBIOS Name Server
  4163.                              * it has returned incorrect
  4164.                              * information.
  4165.                              */
  4166.                             send NAME RELEASE REQUEST for called
  4167.                               name and IP address to
  4168.                               NetBIOS Name Server;
  4169.                        END
  4170.                        /* retry from beginning */
  4171.                        retarget = FALSE;
  4172.                        name_query = TRUE;
  4173.                        goto LOOP;
  4174.                      END /* called name not present */
  4175.                   END /* case */
  4176.                 END /* negative response */
  4177.  
  4178.                 RETARGET SESSION RESPONSE:
  4179.                 BEGIN
  4180.                   close TCP connection;
  4181.                   extract IP address and TCP port from
  4182.                        response;
  4183.                   retarget = TRUE;
  4184.                 END /* retarget response */
  4185.              END /* case */
  4186.  
  4187.    LOOP:          retry_count = retry_count + 1;
  4188.  
  4189.         UNTIL (retry_count > SSN_RETRY_COUNT);
  4190.         return failure;
  4191.    END /* procedure */
  4192.  
  4193.  
  4194.  
  4195. NetBIOS Working Group                                          [Page 70]
  4196.  
  4197.  
  4198. RFC 1002                                                      March 1987
  4199.  
  4200.  
  4201. 5.2.1.2.  RECEIVED PACKET PROCESSING
  4202.  
  4203.    These are packets received on a TCP connection before a session
  4204.    has been established.  The listen routines attached to a NetBIOS
  4205.    user process need not implement the RETARGET response section.
  4206.    The user process version, separate from a shared Session Service,
  4207.    need only accept (POSITIVE SESSION RESPONSE) or reject (NEGATIVE
  4208.    SESSION RESPONSE) a session request.
  4209.  
  4210.    PROCEDURE session_packet(packet)
  4211.    /*
  4212.     * processing initiated by receipt of a session service
  4213.     * packet for a session in the session establishment phase.
  4214.     * Assumes the TCP connection has been accepted.
  4215.     */
  4216.    BEGIN
  4217.         CASE packet type
  4218.  
  4219.            SESSION REQUEST:
  4220.            BEGIN
  4221.              IF called name does not exist on node THEN
  4222.              BEGIN
  4223.                   send NEGATIVE SESSION RESPONSE with CALLED
  4224.                        NAME NOT PRESENT error code;
  4225.                   close TCP connection;
  4226.              END
  4227.  
  4228.              Search for a listen with CALLING NAME for CALLED
  4229.                   NAME;
  4230.              IF matching listen is found THEN
  4231.              BEGIN
  4232.                   IF port of listener process is port TCP
  4233.                      connection is on THEN
  4234.                   BEGIN
  4235.                        send POSITIVE SESSION RESPONSE;
  4236.  
  4237.                        Hand off connection to client process
  4238.                             and/or inform user session is
  4239.                             established;
  4240.                   END
  4241.                   ELSE
  4242.                   BEGIN
  4243.                        send RETARGET SESSION RESPONSE with
  4244.                             listener's IP address and
  4245.                             TCP port;
  4246.                        close TCP connection;
  4247.                   END
  4248.              END
  4249.              ELSE
  4250.              BEGIN
  4251.                   /* no matching listen pending */
  4252.  
  4253.  
  4254.  
  4255. NetBIOS Working Group                                          [Page 71]
  4256.  
  4257.  
  4258. RFC 1002                                                      March 1987
  4259.  
  4260.  
  4261.                   send NEGATIVE SESSION RESPONSE with either
  4262.                        NOT LISTENING ON CALLED NAME or NOT
  4263.                        LISTENING FOR CALLING NAME error
  4264.                        code;
  4265.                   close TCP connection;
  4266.              END
  4267.            END /* session request */
  4268.         END /* case */
  4269.    END /* procedure */
  4270.  
  4271. 5.2.2.  SESSION DATA TRANSFER PROTOCOLS
  4272.  
  4273. 5.2.2.1.  USER REQUEST PROCESSING
  4274.  
  4275.    PROCEDURE send_message(user_message)
  4276.    BEGIN
  4277.         build SESSION MESSAGE header;
  4278.         send SESSION MESSAGE header;
  4279.         send user_message;
  4280.         reset and restart keep-alive timer;
  4281.         IF send fails THEN
  4282.         BEGIN
  4283.              /*
  4284.               * TCP connection has failed */
  4285.               */
  4286.              close NetBIOS session;
  4287.              inform user that session is lost;
  4288.              return failure;
  4289.         END
  4290.         ELSE
  4291.              return success;
  4292.    END
  4293.  
  4294.    5.2.2.2.  RECEIVED PACKET PROCESSING
  4295.  
  4296.    These are packets received after a session has been established.
  4297.  
  4298.    PROCEDURE session_packet(packet)
  4299.    /*
  4300.     * processing initiated by receipt of a session service
  4301.     * packet for a session in the data transfer phase.
  4302.     */
  4303.    BEGIN
  4304.         CASE packet type OF
  4305.  
  4306.            SESSION  MESSAGE:
  4307.            BEGIN
  4308.              process message header;
  4309.              read in user data;
  4310.              reset and restart keep-alive timer;
  4311.              deliver data to user;
  4312.  
  4313.  
  4314.  
  4315. NetBIOS Working Group                                          [Page 72]
  4316.  
  4317.  
  4318. RFC 1002                                                      March 1987
  4319.  
  4320.  
  4321.            END /* session message */
  4322.  
  4323.            SESSION KEEP ALIVE:
  4324.              discard packet;
  4325.  
  4326.         END /* case */
  4327.    END /* procedure */
  4328.  
  4329. 5.2.2.3.  PROCESSING INITIATED BY TIMER
  4330.  
  4331.    PROCEDURE session_ka_timer()
  4332.    /*
  4333.     * processing initiated when session keep alive timer expires
  4334.     */
  4335.    BEGIN
  4336.             send SESSION KEEP ALIVE, if configured;
  4337.             IF send fails THEN
  4338.             BEGIN
  4339.              /* remote node, or path to it, is down */
  4340.  
  4341.              abort TCP connection;
  4342.              close NetBIOS session;
  4343.              inform user that session is lost;
  4344.              return;
  4345.             END
  4346.    END /* procedure */
  4347.  
  4348. 5.2.3.  SESSION TERMINATION PROTOCOLS
  4349.  
  4350. 5.2.3.1.  USER REQUEST PROCESSING
  4351.  
  4352.    PROCEDURE close_session()
  4353.  
  4354.    /* initiated by a user request to close a session */
  4355.  
  4356.    BEGIN
  4357.         close gracefully the TCP connection;
  4358.  
  4359.         WAIT for the connection to close or SSN_CLOSE_TIMEOUT
  4360.              to expire;
  4361.  
  4362.         IF time out expired THEN
  4363.              abort TCP connection;
  4364.    END /* procedure */
  4365.  
  4366. 5.2.3.2.  RECEPTION INDICATION PROCESSING
  4367.  
  4368.    PROCEDURE close_indication()
  4369.    /*
  4370.     * initiated by a TCP indication of a close request from
  4371.     * the remote connection partner.
  4372.  
  4373.  
  4374.  
  4375. NetBIOS Working Group                                          [Page 73]
  4376.  
  4377.  
  4378. RFC 1002                                                      March 1987
  4379.  
  4380.  
  4381.     */
  4382.    BEGIN
  4383.         close gracefully TCP connection;
  4384.  
  4385.         close NetBIOS session;
  4386.  
  4387.         inform user session closed by remote partner;
  4388.    END /* procedure */
  4389.  
  4390. 5.3.  NetBIOS DATAGRAM SERVICE PROTOCOLS
  4391.  
  4392.    The following are GLOBAL variables and should be NetBIOS user
  4393.    configurable:
  4394.  
  4395.    - SCOPE_ID: the non-leaf section of the domain name preceded by a
  4396.      '.'  which represents the domain of the NetBIOS scope for the
  4397.      NetBIOS name.  The following protocol description only supports
  4398.      single scope operation.
  4399.  
  4400.    - MAX_DATAGRAM_LENGTH: the maximum length of an IP datagram.  The
  4401.      minimal maximum length defined in for IP is 576 bytes.  This
  4402.      value is used when determining whether to fragment a NetBIOS
  4403.      datagram.  Implementations are expected to be capable of
  4404.      receiving unfragmented NetBIOS datagrams up to their maximum
  4405.      size.
  4406.  
  4407.    - BROADCAST_ADDRESS: the IP address B-nodes use to send datagrams
  4408.      with group name destinations and broadcast datagrams.  The
  4409.      default is the IP broadcast address for a single IP network.
  4410.  
  4411.  
  4412.    The following are Defined Constants for the NetBIOS Datagram
  4413.    Service:
  4414.  
  4415.    - DGM_SRVC_UDP_PORT: the globally well-known UDP port allocated
  4416.      where the NetBIOS Datagram Service receives UDP packets.  See
  4417.      section 6, "Defined Constants", for its value.
  4418.  
  4419. 5.3.1.  B NODE TRANSMISSION OF NetBIOS DATAGRAMS
  4420.  
  4421.    PROCEDURE send_datagram(data, source, destination, broadcast)
  4422.  
  4423.    /*
  4424.     * user initiated processing on B node
  4425.     */
  4426.  
  4427.    BEGIN
  4428.         group = FALSE;
  4429.  
  4430.         do name discovery on destination name, returns name type and
  4431.              IP address;
  4432.  
  4433.  
  4434.  
  4435. NetBIOS Working Group                                          [Page 74]
  4436.  
  4437.  
  4438. RFC 1002                                                      March 1987
  4439.  
  4440.  
  4441.         IF name type is group name THEN
  4442.         BEGIN
  4443.              group = TRUE;
  4444.         END
  4445.  
  4446.         /*
  4447.          * build datagram service UDP packet;
  4448.          */
  4449.         convert source and destination NetBIOS names into
  4450.              half-ASCII, biased encoded name;
  4451.         SOURCE_NAME = cat(source, SCOPE_ID);
  4452.         SOURCE_IP = this nodes IP address;
  4453.         SOURCE_PORT =  DGM_SRVC_UDP_PORT;
  4454.  
  4455.         IF NetBIOS broadcast THEN
  4456.         BEGIN
  4457.              DESTINATION_NAME = cat("*", SCOPE_ID)
  4458.         END
  4459.         ELSE
  4460.         BEGIN
  4461.              DESTINATION_NAME = cat(destination, SCOPE_ID)
  4462.         END
  4463.  
  4464.         MSG_TYPE = select_one_from_set
  4465.              {BROADCAST, DIRECT_UNIQUE, DIRECT_GROUP}
  4466.         DGM_ID = next transaction id for Datagrams;
  4467.         DGM_LENGTH = length of data + length of second level encoded
  4468.              source and destination names;
  4469.  
  4470.         IF (length of the NetBIOS Datagram, including UDP and
  4471.             IP headers, > MAX_DATAGRAM_LENGTH) THEN
  4472.         BEGIN
  4473.              /*
  4474.               * fragment NetBIOS datagram into 2 UDP packets
  4475.               */
  4476.              Put names into 1st UDP packet and any data that fits
  4477.                   after names;
  4478.              Set MORE and FIRST bits in 1st UDP packet's FLAGS;
  4479.              OFFSET in 1st UDP = 0;
  4480.  
  4481.              Replicate NetBIOS Datagram header from 1st UDP packet
  4482.                   into 2nd UDP packet;
  4483.              Put rest of data in 2nd UDP packet;
  4484.              Clear MORE and FIRST bits in 2nd UDP packet's FLAGS;
  4485.              OFFSET in 2nd UDP = DGM_LENGTH - number of name and
  4486.                   data bytes in 1st UDP;
  4487.         END
  4488.         BEGIN
  4489.              /*
  4490.               * Only need one UDP packet
  4491.               */
  4492.  
  4493.  
  4494.  
  4495. NetBIOS Working Group                                          [Page 75]
  4496.  
  4497.  
  4498. RFC 1002                                                      March 1987
  4499.  
  4500.  
  4501.              USER_DATA = data;
  4502.              Clear MORE bit and set FIRST bit in FLAGS;
  4503.              OFFSET = 0;
  4504.         END
  4505.  
  4506.         IF (group == TRUE) OR (NetBIOS broadcast) THEN
  4507.         BEGIN
  4508.              send UDP packet(s) to BROADCAST_ADDRESS;
  4509.         END
  4510.         ELSE
  4511.         BEGIN
  4512.              send UDP packet(s) to IP address returned by name
  4513.                 discovery;
  4514.         END
  4515.    END /* procedure */
  4516.  
  4517. 5.3.2.  P AND M NODE TRANSMISSION OF NetBIOS DATAGRAMS
  4518.  
  4519.    PROCEDURE send_datagram(data, source, destination, broadcast)
  4520.  
  4521.    /*
  4522.     * User initiated processing on P and M node.
  4523.     *
  4524.     * This processing is the same as for B nodes except for
  4525.     * sending broadcast and multicast NetBIOS datagrams.
  4526.     */
  4527.  
  4528.    BEGIN
  4529.         group = FALSE;
  4530.  
  4531.         do name discovery on destination name, returns name type
  4532.              and IP address;
  4533.         IF name type is group name THEN
  4534.         BEGIN
  4535.              group = TRUE;
  4536.         END
  4537.  
  4538.         /*
  4539.          * build datagram service UDP packet;
  4540.          */
  4541.         convert source and destination NetBIOS names into
  4542.              half-ASCII, biased encoded name;
  4543.         SOURCE_NAME = cat(source, SCOPE_ID);
  4544.         SOURCE_IP = this nodes IP address;
  4545.         SOURCE_PORT =  DGM_SRVC_UDP_PORT;
  4546.  
  4547.         IF NetBIOS broadcast THEN
  4548.         BEGIN
  4549.              DESTINATION_NAME = cat("*", SCOPE_ID)
  4550.         END
  4551.         ELSE
  4552.  
  4553.  
  4554.  
  4555. NetBIOS Working Group                                          [Page 76]
  4556.  
  4557.  
  4558. RFC 1002                                                      March 1987
  4559.  
  4560.  
  4561.         BEGIN
  4562.              DESTINATION_NAME = cat(destination, SCOPE_ID)
  4563.         END
  4564.  
  4565.         MSG_TYPE = select_one_from_set
  4566.              {BROADCAST, DIRECT_UNIQUE, DIRECT_GROUP}
  4567.         DGM_ID = next transaction id for Datagrams;
  4568.         DGM_LENGTH = length of data + length of second level encoded
  4569.              source and destination names;
  4570.  
  4571.         IF (length of the NetBIOS Datagram, including UDP and
  4572.             IP headers, > MAX_DATAGRAM_LENGTH) THEN
  4573.         BEGIN
  4574.              /*
  4575.               * fragment NetBIOS datagram into 2 UDP packets
  4576.               */
  4577.              Put names into 1st UDP packet and any data that fits
  4578.                   after names;
  4579.              Set MORE and FIRST bits in 1st UDP packet's FLAGS;
  4580.  
  4581.              OFFSET in 1st UDP = 0;
  4582.  
  4583.              Replicate NetBIOS Datagram header from 1st UDP packet
  4584.                   into 2nd UDP packet;
  4585.              Put rest of data in 2nd UDP packet;
  4586.              Clear MORE and FIRST bits in 2nd UDP packet's FLAGS;
  4587.              OFFSET in 2nd UDP = DGM_LENGTH - number of name and
  4588.                   data bytes in 1st UDP;
  4589.         END
  4590.         BEGIN
  4591.              /*
  4592.               * Only need one UDP packet
  4593.               */
  4594.              USER_DATA = data;
  4595.              Clear MORE bit and set FIRST bit in FLAGS;
  4596.              OFFSET = 0;
  4597.         END
  4598.  
  4599.         IF (group == TRUE) OR (NetBIOS broadcast) THEN
  4600.         BEGIN
  4601.              /*
  4602.               * Sending of following query is optional.
  4603.               * Node may send datagram to NBDD immediately
  4604.               * but NBDD may discard the datagram.
  4605.               */
  4606.              send DATAGRAM QUERY REQUEST to NBDD;
  4607.              IF response is POSITIVE QUERY RESPONSE THEN
  4608.                   send UDP packet(s) to NBDD Server IP address;
  4609.              ELSE
  4610.              BEGIN
  4611.                   get list of destination nodes from NBNS;
  4612.  
  4613.  
  4614.  
  4615. NetBIOS Working Group                                          [Page 77]
  4616.  
  4617.  
  4618. RFC 1002                                                      March 1987
  4619.  
  4620.  
  4621.                   FOR EACH node in list
  4622.                   BEGIN
  4623.                        send UDP packet(s) to this node's
  4624.                             IP address;
  4625.                   END
  4626.              END
  4627.         END
  4628.         ELSE
  4629.         BEGIN
  4630.              send UDP packet(s) to IP address returned by name
  4631.                 discovery;
  4632.    END /* procedure */
  4633.  
  4634. 5.3.3.  RECEPTION OF NetBIOS DATAGRAMS BY ALL NODES
  4635.  
  4636.    The following algorithm discards out of order NetBIOS Datagram
  4637.    fragments.  An implementation which reassembles out of order
  4638.    NetBIOS Datagram fragments conforms to this specification.  The
  4639.    fragment discard timer is initialized to the value FRAGMENT_TO.
  4640.    This value should be user configurable.  The default value is
  4641.    given in Section 6, "Defined Constants and Variables".
  4642.  
  4643.    PROCEDURE datagram_packet(packet)
  4644.  
  4645.    /*
  4646.     * processing initiated by datagram packet reception
  4647.     * on B, P and M nodes
  4648.     */
  4649.    BEGIN
  4650.         /*
  4651.          * if this node is a P node, ignore
  4652.          * broadcast packets.
  4653.          */
  4654.  
  4655.         IF this is a P node AND incoming packet is
  4656.              a broadcast packet THEN
  4657.         BEGIN
  4658.              discard packet;
  4659.         END
  4660.  
  4661.         CASE packet type OF
  4662.  
  4663.            DATAGRAM SERVICE:
  4664.            BEGIN
  4665.              IF FIRST bit in FLAGS is set THEN
  4666.              BEGIN
  4667.                   IF MORE bit in FLAGS is set THEN
  4668.                   BEGIN
  4669.                        Save 1st UDP packet of the Datagram;
  4670.                        Set this Datagram's fragment discard
  4671.                          timer to FRAGMENT_TO;
  4672.  
  4673.  
  4674.  
  4675. NetBIOS Working Group                                          [Page 78]
  4676.  
  4677.  
  4678. RFC 1002                                                      March 1987
  4679.  
  4680.  
  4681.                        return;
  4682.                   END
  4683.                   ELSE
  4684.                        Datagram is composed of a single
  4685.                          UDP packet;
  4686.              END
  4687.              ELSE
  4688.              BEGIN
  4689.                   /* Have the second fragment of a Datagram */
  4690.  
  4691.                   Search for 1st fragment by source IP address
  4692.                      and DGM_ID;
  4693.                   IF found 1st fragment THEN
  4694.                        Process both UDP packets;
  4695.                   ELSE
  4696.                   BEGIN
  4697.                        discard 2nd fragment UDP packet;
  4698.                        return;
  4699.                   END
  4700.              END
  4701.  
  4702.              IF DESTINATION_NAME is '*' THEN
  4703.              BEGIN
  4704.                   /* NetBIOS broadcast */
  4705.  
  4706.                   deliver USER_DATA from UDP packet(s) to all
  4707.                        outstanding receive broadcast
  4708.                        datagram requests;
  4709.                   return;
  4710.              END
  4711.              ELSE
  4712.              BEGIN /* non-broadcast */
  4713.                   /* Datagram for Unique or Group Name */
  4714.  
  4715.                   IF DESTINATION_NAME is not present in the
  4716.                      local name table THEN
  4717.                   BEGIN
  4718.                        /* destination not present */
  4719.                        build DATAGRAM ERROR packet, clear
  4720.                             FIRST and MORE bit, put in
  4721.                             this nodes IP and PORT, set
  4722.                             ERROR_CODE;
  4723.                        send DATAGRAM ERROR packet to
  4724.                             source IP address and port
  4725.                             of UDP;
  4726.                        discard UDP packet(s);
  4727.                        return;
  4728.                   END
  4729.                   ELSE
  4730.                   BEGIN /* good */
  4731.                        /*
  4732.  
  4733.  
  4734.  
  4735. NetBIOS Working Group                                          [Page 79]
  4736.  
  4737.  
  4738. RFC 1002                                                      March 1987
  4739.  
  4740.  
  4741.                         * Replicate received NetBIOS datagram for
  4742.                         * each recipient
  4743.                         */
  4744.                        FOR EACH pending NetBIOS user's receive
  4745.                             datagram operation
  4746.                        BEGIN
  4747.                             IF source name of operation
  4748.                                matches destination name
  4749.                                of packet THEN
  4750.                             BEGIN
  4751.                                deliver USER_DATA from UDP
  4752.                                  packet(s);
  4753.                             END
  4754.                        END /* for each */
  4755.                        return;
  4756.                   END /* good */
  4757.              END /* non-broadcast */
  4758.             END /* datagram service */
  4759.  
  4760.            DATAGRAM ERROR:
  4761.            BEGIN
  4762.                 /*
  4763.                  * name service returned incorrect information
  4764.                  */
  4765.  
  4766.                 inform local name service that incorrect
  4767.                   information was provided;
  4768.  
  4769.                 IF this is a P or M node THEN
  4770.                 BEGIN
  4771.                      /*
  4772.                       * tell NetBIOS Name Server that it may
  4773.                       * have given incorrect information
  4774.                       */
  4775.  
  4776.                      send NAME RELEASE REQUEST with name
  4777.                        and incorrect IP address to NetBIOS
  4778.                        Name Server;
  4779.                 END
  4780.            END /* datagram error */
  4781.  
  4782.         END /* case */
  4783.    END
  4784.  
  4785. 5.3.4.  PROTOCOLS FOR THE NBDD
  4786.  
  4787.    The key to NetBIOS Datagram forwarding service is the packet
  4788.    delivered to the destination end node must have the same NetBIOS
  4789.    header as if the source end node sent the packet directly to the
  4790.    destination end node.  Consequently, the NBDD does not reassemble
  4791.    NetBIOS Datagrams.  It forwards the UDP packet as is.
  4792.  
  4793.  
  4794.  
  4795. NetBIOS Working Group                                          [Page 80]
  4796.  
  4797.  
  4798. RFC 1002                                                      March 1987
  4799.  
  4800.  
  4801.    PROCEDURE  datagram_packet(packet)
  4802.  
  4803.    /*
  4804.     * processing initiated by a incoming datagram service
  4805.     * packet on a NBDD node.
  4806.     */
  4807.  
  4808.    BEGIN
  4809.         CASE packet type OF
  4810.  
  4811.            DATAGRAM SERVICE:
  4812.            BEGIN
  4813.                 IF packet was sent as a directed
  4814.                    NetBIOS datagram THEN
  4815.                 BEGIN
  4816.                   /*
  4817.                    * provide group forwarding service
  4818.                    *
  4819.                    * Forward datagram to each member of the
  4820.                    * group.  Can forward via:
  4821.                    *   1) get list of group members and send
  4822.                    *   the DATAGRAM SERVICE packet unicast
  4823.                    *   to each
  4824.                    *   2) use Group Multicast, if available
  4825.                    *   3) combination of 1) and 2)
  4826.                    */
  4827.  
  4828.                   ...
  4829.  
  4830.                 END
  4831.  
  4832.                 ELSE
  4833.                 BEGIN
  4834.                   /*
  4835.                    * provide broadcast forwarding service
  4836.                    *
  4837.                    * Forward datagram to every node in the
  4838.                    * NetBIOS scope.  Can forward via:
  4839.                    *   1) get list of group members and send
  4840.                    *   the DATAGRAM SERVICE packet unicast
  4841.                    *   to each
  4842.                    *   2) use Group Multicast, if available
  4843.                    *   3) combination of 1) and 2)
  4844.                    */
  4845.  
  4846.                   ...
  4847.  
  4848.                 END
  4849.            END /* datagram service */
  4850.  
  4851.            DATAGRAM ERROR:
  4852.  
  4853.  
  4854.  
  4855. NetBIOS Working Group                                          [Page 81]
  4856.  
  4857.  
  4858. RFC 1002                                                      March 1987
  4859.  
  4860.  
  4861.            BEGIN
  4862.              /*
  4863.               * Should never receive these because Datagrams
  4864.               * forwarded have source end node IP address and
  4865.               * port in NetBIOS header.
  4866.               */
  4867.  
  4868.              send DELETE NAME REQUEST with incorrect name and
  4869.                   IP address to NetBIOS Name Server;
  4870.  
  4871.            END /* datagram error */
  4872.  
  4873.            DATAGRAM QUERY REQUEST:
  4874.            BEGIN
  4875.              IF can send packet to DESTINATION_NAME THEN
  4876.              BEGIN
  4877.                   /*
  4878.                    * NBDD is able to relay Datagrams for
  4879.                    * this name
  4880.                    */
  4881.  
  4882.                   send POSITIVE DATAGRAM QUERY RESPONSE to
  4883.                     REQUEST source IP address and UDP port
  4884.                     with request's DGM_ID;
  4885.              END
  4886.              ELSE
  4887.              BEGIN
  4888.                   /*
  4889.                    * NBDD is NOT able to relay Datagrams for
  4890.                    * this name
  4891.                    */
  4892.  
  4893.                   send NEGATIVE DATAGRAM QUERY RESPONSE to
  4894.                     REQUEST source IP address and UDP port
  4895.  
  4896.                     with request's DGM_ID;
  4897.              END
  4898.            END /* datagram query request */
  4899.  
  4900.         END /* case */
  4901.    END /* procedure */
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915. NetBIOS Working Group                                          [Page 82]
  4916.  
  4917.  
  4918. RFC 1002                                                      March 1987
  4919.  
  4920.  
  4921. 6.  DEFINED CONSTANTS AND VARIABLES
  4922.  
  4923.    GENERAL:
  4924.  
  4925.       SCOPE_ID                   The name of the NetBIOS scope.
  4926.  
  4927.                                  This is expressed as a character
  4928.                                  string meeting the requirements of
  4929.                                  the domain name system and without
  4930.                                  a leading or trailing "dot".
  4931.  
  4932.                                  An implementation may elect to make
  4933.                                  this a single global value for the
  4934.                                  node or allow it to be specified
  4935.                                  with each separate NetBIOS name
  4936.                                  (thus permitting cross-scope
  4937.                                  references.)
  4938.  
  4939.       BROADCAST_ADDRESS          An IP address composed of the
  4940.                                  nodes's network and subnetwork
  4941.                                  numbers with all remaining bits set
  4942.                                  to one.
  4943.  
  4944.                                  I.e. "Specific subnet" broadcast
  4945.                                  addressing according to section 2.3
  4946.                                  of RFC 950.
  4947.  
  4948.       BCAST_REQ_RETRY_TIMEOUT    250 milliseconds.
  4949.                                  An adaptive timer may be used.
  4950.  
  4951.       BCAST_REQ_RETRY_COUNT      3
  4952.  
  4953.       UCAST_REQ_RETRY_TIMEOUT    5 seconds
  4954.                                  An adaptive timer may be used.
  4955.  
  4956.       UCAST_REQ_RETRY_COUNT      3
  4957.  
  4958.       MAX_DATAGRAM_LENGTH        576 bytes (default)
  4959.  
  4960.  
  4961.  
  4962.    NAME SERVICE:
  4963.  
  4964.       REFRESH_TIMER              Negotiated with NBNS for each name.
  4965.  
  4966.       CONFLICT_TIMER             1 second
  4967.                                  Implementations may chose a longer
  4968.                                  value.
  4969.  
  4970.  
  4971.       NAME_SERVICE_TCP_PORT      137 (decimal)
  4972.  
  4973.  
  4974.  
  4975. NetBIOS Working Group                                          [Page 83]
  4976.  
  4977.  
  4978. RFC 1002                                                      March 1987
  4979.  
  4980.  
  4981.       NAME_SERVICE_UDP_PORT      137 (decimal)
  4982.  
  4983.       INFINITE_TTL               0
  4984.  
  4985.  
  4986.    SESSION SERVICE:
  4987.  
  4988.       SSN_SRVC_TCP_PORT          139 (decimal)
  4989.  
  4990.       SSN_RETRY_COUNT            4 (default)
  4991.                                  Re-configurable by user.
  4992.  
  4993.       SSN_CLOSE_TIMEOUT          30 seconds (default)
  4994.                                  Re-configurable by user.
  4995.  
  4996.       SSN_KEEP_ALIVE_TIMEOUT     60 seconds, recommended, may be set to
  4997.                                  a higher value.
  4998.                                  (Session keep-alives are used only
  4999.                                  if configured.)
  5000.  
  5001.    DATAGRAM SERVICE:
  5002.  
  5003.       DGM_SRVC_UDP_PORT          138 (decimal)
  5004.  
  5005.       FRAGMENT_TO                2 seconds (default)
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035. NetBIOS Working Group                                          [Page 84]
  5036.  
  5037.  
  5038. RFC 1002                                                      March 1987
  5039.  
  5040.  
  5041. REFERENCES
  5042.  
  5043.  
  5044.  
  5045.    [1]  "Protocol Standard For a NetBIOS Service on a TCP/UDP
  5046.         Transport: Concepts and Methods", RFC 1001, March 1987.
  5047.  
  5048.    [2]  J. Reynolds, J. Postel, "Assigned Numbers", RFC 990, November
  5049.         1986.
  5050.  
  5051.    [3]  P. Mockapetris, "Domain Names - Implementation and
  5052.         Specification", RFC 883, November 1983.
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095. NetBIOS Working Group                                          [Page 85]
  5096.  
  5097.  
  5098.  
  5099.