Shop OBEX P1 Docs P2 Docs Learn Events
Netbios Along with DHCP multisocket server. Own socket ? — Parallax Forums

Netbios Along with DHCP multisocket server. Own socket ?

Igor_RastIgor_Rast Posts: 357
edited 2012-11-22 15:29 in Accessories
Ok , So trying to get the Netbios name to redirect to my props page .
I was trying out first with the netbios unit test from mike g source
I adapted it allitle for it to use the dhcp to get its ip .
in wireshark I can see that happening fine , after that the 6 queries get shown , and after that propnet is avaiable .
then Nothing happens ,
I cant open anything by pointing the brouwser to the netbios name , nor wil nmap see the host up .
PUB Main | i,ptr, bytesToRead,dnsServer
  wiz.HardReset(nRESET_WIZ)
    i := 0
  buffPtr := @buff

  pst.Start(115_200)
  pause(500)
  
  FirstLevelEncode(@encName, @nbName, $00)
  pst.str(@encName)
  pst.char(CR)

  'Fill the encoded name our 3 packets types
  bytemove(@nbNameReg[13], @encName, 32)
  bytemove(@nbPosQueryResp[13], @encName, 32)
  bytemove(@nbStatQueryResp[13], @encName, 32)
     
  pst.str(string("Initialize W5200", CR))
  wiz.start(6, 5, 4, 7) 
  wiz.SetMac($00, $08, $DC, $16, $F8, $01)

  pst.str(string("Getting network paramters", CR))
  dhcp.Init(@buff, 7)  
    
    pst.str(string("Requesting IP....."))

    i := 0 
    repeat until dhcp.DoDhcp
      if(++i > DHCP_ATTEMPTS)
        quit

    if(dhcp.GetErrorCode > 0 OR i > DHCP_ATTEMPTS)
      pst.char(CR) 
      pst.str(string(CR, "DHCP Attempts: "))
      pst.dec(i)
      pst.str(string(CR, "Error Code: "))
      pst.dec(dhcp.GetErrorCode)
      pst.char(CR)
      pst.str(dhcp.GetErrorMessage)
      pst.char(CR)

      return
    else
      PrintIp(dhcp.GetIp)

    pst.str(string("DNS..............."))
    dnsServer := wiz.GetDns
    PrintIp(wiz.GetDns)

    pst.str(string("DHCP Server......."))
    printIp(wiz.GetDhcpServerIp)

    pst.str(string("Router IP........."))
    printIp(wiz.GetRouter)
    
    pst.str(string("Gateway IP........"))                                        
    printIp(wiz.GetGatewayIp)
    
     pst.str(string("Lease Time........"))
    pst.dec(dhcp.GetLeaseTime)
      
    pst.char(CR)
 
 
     pause(2000)
 
 
 
  bytemove(@nbMac, wiz.GetMac, 6)


  bytemove(@ipReg, wiz.GetIp, 4)
  bytemove(@ipResp, wiz.GetIp, 4)

  'Broadcast NetBIOS on port 137
  sock.Init(0, UDP, 137)
  sock.RemoteIp(192, 168, 2, 255)
  sock.RemotePort(137)
  pause(500)

  'Send the name registration request 6 times
  'If we do not get a response then the name "PROPNET" is available
  {   } 
  repeat 6
    ptr := Register
    pause(500)
    ifnot(ptr == @null)
      pst.str(string(CR, "Not NULL", CR))
      if(IsError(ptr))
        pst.str(string("Error ID: "))
        pst.dec(IsError(ptr))
        return  

  pst.str(@nbName)
  pst.str(string(" is available on the network!"))

  word[@nbPosQueryResp] := transId
  repeat
    sock.Open
    
    'Data in the buffer?
    repeat until null <  bytesToRead := sock.Available
  
    'Get the Rx buffer  
    sock.Receive(@buff, bytesToRead)
    PrintDebug(@buff, bytesToRead)

    'Is this broadcast for PROPNET?
    if(IsMine(@buff + 8))
      'Set the target IP address to requester
      sock.RemoteIp(byte[@buff], byte[@buff+1], byte[@buff+2], byte[@buff+3])

      if(IsNbType(@buff + 8))
        bytemove(@nbPosQueryResp, @buff+8, 2)
        sock.Send(@nbPosQueryResp, @enbPosQueryResp - @nbPosQueryResp)

      if(IsNbStatType(@buff + 8))
        bytemove(@nbStatQueryResp, @buff+8, 2)
        sock.Send(@nbStatQueryResp, @enbStatQueryResp - @nbStatQueryResp)
    else
      pst.str(string("*** Not For Me ***")) 

    pause(100)
    sock.Disconnect
    
    bytesToRead~
hope to get some help here making it work .
I got a feeling somehow the code below has to fit somewhere in the multisocket PUB to make it work , but then it will use the same socket different settings so thats not going to work ,
it wil need to use its own socket , because im not having true concurrency anyway , meaning the sockets that im already using are never used parallel to each other ,
maybe we can just remove 1 of the 8 to let to resolve the netbios ,
just an idea , probably a long shot to accomplish this .
if(IsMine(@buff + 8))
      'Set the target IP address to requester
      sock.RemoteIp(byte[@buff], byte[@buff+1], byte[@buff+2], byte[@buff+3])

      if(IsNbType(@buff + 8))
        bytemove(@nbPosQueryResp, @buff+8, 2)
        sock.Send(@nbPosQueryResp, @enbPosQueryResp - @nbPosQueryResp)

      if(IsNbStatType(@buff + 8))
        bytemove(@nbStatQueryResp, @buff+8, 2)
        sock.Send(@nbStatQueryResp, @enbStatQueryResp - @nbStatQueryResp)
    else
      pst.str(string("*** Not For Me ***"))

mmmmmmm.jpg

fffffffffffffffffffffffffffff.jpg

sharklognetbios1.zip

ok , the pst started responding abit later, but its stil not responding to the netbios name , only the rest of things going on on the network
working verry randomly then stopping again

[HTML]FAFCEPFAEOEFFECACACACACACACACAAA
Initialize W5200
Getting network paramters
Requesting IP.....192.168.2.4DNS...............192.168.2.254DH
CP Server.......192.168.2.254Router IP.........192.168.2.254Ga
teway IP........192.168.2.254Lease Time........86400
Send Bytes.......70
Bytes to Read....-1

Send Bytes.......70
Bytes to Read....-1

Send Bytes.......70
Bytes to Read....-1

Send Bytes.......70
Bytes to Read....-1

Send Bytes.......70
Bytes to Read....-1

Send Bytes.......70
Bytes to Read....-1

PROPNET is available on the network!

Request from: 192.168.2.1:137 (68)


00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
0000 80 02 29 10 00 01 00 00 00 00 00 01 20 45 45 46
0010 43 45 46 45 42 45 4E 46 44 43 41 43 41 43 41 43
0020 41 43 41 43 41 43 41 43 41 43 41 41 41 00 00 20
0030 00 01 C0 0C 00 20 00 01 00 04 93 E0 00 06 00 00
0040 C0 A8 02 01 00

Start: 132 Len: 68

FAFCEPFAEOEFFECACACACACACACACAAA
EEFCEFEBENFDCACACACACACACACACAAA
*** Not For Me ***

Request from: 192.168.2.1:137 (68)


00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
0000 80 02 29 10 00 01 00 00 00 00 00 01 20 45 45 46
0010 43 45 46 45 42 45 4E 46 44 43 41 43 41 43 41 43
0020 41 43 41 43 41 43 41 43 41 43 41 41 41 00 00 20
0030 00 01 C0 0C 00 20 00 01 00 04 93 E0 00 06 00 00
0040 C0 A8 02 01 00

Start: 132 Len: 68

FAFCEPFAEOEFFECACACACACACACACAAA
EEFCEFEBENFDCACACACACACACACACAAA
*** Not For Me ***

Request from: 192.168.2.1:137 (68)


00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
0000 80 02 29 10 00 01 00 00 00 00 00 01 20 45 45 46
0010 43 45 46 45 42 45 4E 46 44 43 41 43 41 43 41 43
0020 41 43 41 43 41 43 41 43 41 43 41 41 41 00 00 20
0030 00 01 C0 0C 00 20 00 01 00 04 93 E0 00 06 00 00
0040 C0 A8 02 01 00



[/HTML]
always repeating with not for me
635 x 543 - 64K
Sign In or Register to comment.