home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 1000s / rfc1002.txt < prev    next >
Text File  |  1993-03-20  |  165KB  |  5,013 lines

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