| 
 Q:  Given an AppleTalk network and the node address of a Macintosh, how can I
remotely retrieve the Network Name specified in the Sharing setup control
panel? A:  The only universal way to determine a Macintosh's "flagship" name is to target
a NPB lookup of type "workstation" to that particular node.This is Illustrated in the following Etherpeek packet trace. Packet #1
	| 
Long DDP Header - Datagram Delivery Protocol
  Unused:           %00
  Hop Count:        %0000
  Datagram Length:  59
  DDP Checksum:     0x0000
  Dest. Network:    43203
  Source Network:   43204
  Dest Node:        229
  Source Node:      213
  Dest. Socket:     2  NBP Socket
  Source Socket:    253
  DDP Type:         2  NBP
NBP - Name Binding Protocol
  Function:     2  LkUp - Lookup
  Tuple Count:  1
  NBP ID:       25
NBP Tuple #1
  Node Address: 43204.213
  Socket Number:253
  Enumerator:   0
  Object:       =
  Type:         workstation
  Zone:         Dev Support Center (DTS)
 |  and the target node replies with this packet: Packet #2
	| 
Long DDP Header - Datagram Delivery Protocol
  Unused:           %00
  Hop Count:        %0000
  Datagram Length:  46
  DDP Checksum:     0x0000
  Dest. Network:    43204
  Source Network:   43203
  Dest Node:        213
  Source Node:      229
  Dest. Socket:     253
  Source Socket:    2  NBP Socket
  DDP Type:         2  NBP
NBP - Name Binding Protocol
  Function:     3  LkUp-Reply
  Tuple Count:  1
  NBP ID:       25
NBP Tuple #1
  Node Address: 43203.229
  Socket Number:4
  Enumerator:   1
  Object:       Jill's IIfx
  Type:         Workstation
  Zone:         *
 |  At first glance, it would seem that we could get the desired result by using
the PConfirmNamecall (sincePConfirmNameallows us to direct the NBPLkUpto
the specific node by using theconfirmAddrfield, whereas thePLookupNamewould
broadcast it to an entire zone). ThePConfirmNamecall does not return the NBP
Tuple information to the application, however: under classic AppleTalk,PConfirmName's sole purpose is to confirm or deny the existence of a registered
NBP name. This leaves you with the following alternatives: Under classic AppleTalk:
Use the PLookupNamecall. This is a bit complicated becausePLookupNamerequires that you specify the "zone name" of the target node. You have to make
a call toGetZoneListand parse through the replies (illustrated in Inside
Mac: Networking, pg 4-7) to extract a list of zone name(s) that correspond
to your target's network number. (Note that if you are on an extended network
it is possible for a AppleTalk zone to have a range of network numbers.) Once you have a list of suspected network zones that the target is on, you can
then direct a PLookupNameto that zone. You will then have to parse through the
responses to find the one that matches your target's node address. Form the NBP LkUppacket yourself and send it via DDP.
 Under classic AppleTalk you can open and register your own DDP listener by
using the POpenSktcall, forming your own NBP-LkUppacket, and transmitting
that packet to the target node's NBP listener socket (socket #2) with thePWriteDDPcall. The target will respond to you with a NBP LkUp-Reply, which will call back your
DDP socket listener. You can parse the reply there. Writing a DDP socket listener is tricky, but it's illustrated in the Network
Watch (DMZ) sample available from DTS sample code library. Examine the doEchofunction in the files dMZAT.c and  SktListener.a. Writing a socket listener can be challenging under PowerPC because of classic
AppleTalk's 68Ks roots. If you are stuck with a classic AppleTalk system,
however, this is the recommended approach. Under Open Transport:You're in luck! If your code can run under Open Transport native, you can
specify the target address in the TLookupRequestdata structure used by theOTLookupNamefunction. Check out theDoSendLkUpReqfunction in DDPSample.cp,
found on any Open Transport SDK CD. Since the programming model is much simpler, you may want to investigate the
Open Transport approach. |