Jump to content











Photo
- - - - -

DHCP additional option non ascii value problem (eg ntp)

ntp dhcp tftpd32

  • Please log in to reply
7 replies to this topic

#1 beamer145

beamer145
  • Members
  • 6 posts
  •  
    Belgium

Posted 22 October 2012 - 02:29 PM

I have enabled the sntp server feature of tftpd32, but unfortunately tftpd32 does not add this server to the bootp options automatically.
It seemed I could easily fix this myself by adding this as an extra option in the dhcp settings menu. (ntp server is option number 42, value is the ip address of the server)

Unfortunalely, what you fill in in the value field of the additional option is directly put in ascii into the outgoing packet.
This means there is no way to eg enter 10.1.3.1 as an address, because those numbers do not translate to ascii chars.
I tried editing the ini file directly by entering the hex values with a hex editor, but he stops parsing the line as soon as he sees the 0x0A.

Any workarounds ?
( Feauture request : change the value field of the additional options so that it must be entered as hex numbers)

#2 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 22 October 2012 - 08:31 PM

...
Any workarounds ?
( Feauture request : change the value field of the additional options so that it must be entered as hex numbers)

Please try running the program, then clicking the Help button/menu, then read the documentation section called Getting Started -> DHCP Setup

#3 beamer145

beamer145
  • Members
  • 6 posts
  •  
    Belgium

Posted 23 October 2012 - 08:55 AM

Thanks
I checked the 'Tftpd32 advanced setup' section, but that one does not seem updated to the latest version and did not contain any info about the optional parameters.

#4 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 23 October 2012 - 09:58 AM

Thanks
I checked the 'Tftpd32 advanced setup' section, but that one does not seem updated to the latest version and did not contain any info about the optional parameters.

That is not the section that I mentioned. Did you find the section that I mentioned?

#5 beamer145

beamer145
  • Members
  • 6 posts
  •  
    Belgium

Posted 23 October 2012 - 12:55 PM

Yes , your explanation was clear.
(I just mentioned the advanced setup section to indicate that I did in fact tried to RTFM before asking for help :) )

However, I just tried playing with the 'a' and '0x' prefix (0x is not explicitly mentioned, but it is shown in the screenshot in the help), but it does not seem to work. The a or 0x is just considered to be part of the string, and appears as ascii in the message.
Do I have to use an escape character to 'qualify' the prefix ?
Anything else I am missing?

FYI currenly my settings resulted in the following entry in the ini file:
AddOptionNumber1=42
AddOptionValue1=a10.1.3.98
or
AddOptionNumber1=42
AddOptionValue1=0x0a010362

#6 beamer145

beamer145
  • Members
  • 6 posts
  •  
    Belgium

Posted 23 October 2012 - 03:54 PM

Ok, I checked the sources, and I was missing a space separator between the prefix and the value (format: "prefix[space]value").
So the screenshot in the help is misleading :(

In case anyone else runs into this topic, for completeness all possible prefixes (version 4.00) are:
case 'a' : // IP address
* (unsigned long *) buffer = inet_addr (opt_val+2);
return sizeof (unsigned long);
case 's' : // string
lstrcpyn (sz, opt_val+2, len);
TranslateExp (sz, buffer, ip, tMac);
((char *) buffer) [len-1] = 0;
return lstrlen (buffer);
case 'i' : // integer
* (unsigned long *) buffer = atoi (opt_val+2);
return sizeof (unsigned long);
case '0' :
case 'x' : // hex digit
sscanf(opt_val+2, "%x", buffer);
return sizeof (unsigned long);
case 'u' : // hex digit
sscanf(opt_val+2, "%u", buffer);
return sizeof (unsigned long);

It seems the ip address can be postfixed by a "[space]@'"but I don't know what that triggers.

#7 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 23 October 2012 - 05:13 PM

...
However, I just tried playing with the 'a' and '0x' prefix (0x is not explicitly mentioned, but it is shown in the screenshot in the help), but it does not seem to work.
...

What version of the program are you using? My old 3.23's Help explicitly talks about using 0x as a prefix. In fact, it doesn't mention any other possible prefices, probably because of how old it is. Did a newer version's Help really remove the mention of the 0x prefix for option value data? If so, that's too bad.

Glad you figured it out.

#8 beamer145

beamer145
  • Members
  • 6 posts
  •  
    Belgium

Posted 24 October 2012 - 09:09 AM

Mine has:

"Additional Option The first field is the number of the option to be handled The second filed is the value of the field. The value is prefixed with its type (a for IP address, s for ASCII, i for integer) Default type is string, except if the value begins with 0 or x... "

So it is a bit confusing/incorrect:
- in the part between brackets it is mentioned that only a,s and i are type prefixes.
- the next sentence seems to state that if you don't use a prefix but your 'text' starts with 0 or x then it is not treated as string but as something else (unspecified what exactly, one can assume x means hex, but using C like reasoning 0 would be octal :) ). But this is not the behavior that is implemented, if the string starts with 0 or x it is still a string, and 0 and x are just regular prefixes that need to be followed by a space.

BTW I also think '0x' is not a valid prefix anymore, it can only be 0 or x

Edited by beamer145, 24 October 2012 - 09:10 AM.






Also tagged with one or more of these keywords: ntp, dhcp, tftpd32

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users