Problem with [binary scan] and sign in Tcl 8.4
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Problem with [binary scan] and sign in Tcl 8.4

From: Christopher Nelson <cnelson@nycap.rr.com>
Date: Wed May 25 2005 - 18:37:44 CEST

I'm trying to parse MAC addresses out of binary buffers with [binary
scan] but negative signs keep creeping in:

  proc test { } {
    set msg [binary format "c c c c c c" 1 0x80 0xc2 0 0 0]
    binary scan $msg "c6" dst
    puts "dst:$dst"
    puts -nonewline "msg from"
    set sep " "
    foreach e $dst {
        puts -nonewline "$sep[format %02x $e]"
        set sep ":"
    }
    puts ""
  }

produces:

  dst:1 -128 -62 0 0 0
  msg from 01:ffffff80:ffffffc2:00:00:00

I can't find an option to tell [binary scan] to treat the bytes as
unsigned. Am I missing something?
Received on Thu Sep 29 14:19:00 2005