[Bro-Dev] #968: Add bytestring_to_uint16, uint32, uint64 functions

Bro Tracker bro at tracker.bro.org
Tue Mar 19 08:08:30 PDT 2013


#968: Add bytestring_to_uint16, uint32, uint64 functions
--------------------+------------------------
  Reporter:  yun    |      Owner:
      Type:  Patch  |     Status:  new
  Priority:  Low    |  Milestone:  Bro2.2
 Component:  Bro    |    Version:  git/master
Resolution:         |   Keywords:  bytestring
--------------------+------------------------

Comment (by yun):

 Replying to [comment:10 seth]:

 >
 > Ah, seems reasonable.  I still think that for now we'd like to stick to
 only one function named bytestring_to_count.  Adding something akin to
 unpack doesn't fit the longer term model we're putting in place and I'd
 like to avoid the various bit length uint functions since in Bro all
 integers are 64bit.


 Fair enough, i'm not very happy with the amount different methods either
 but was at least something to accomodate my needs. I thought it might be
 useful to have it upstream.

 How about I change the function to bytestream_to_count(), and based on the
 length convert it to 8bit, 16bit, 32bit or 64 bit integers? So basically:

 {{{
 print bytestream_to_count("\x11") #17
 print bytestream_to_count("\x11\x22") #4386
 print bytestream_to_count("\x11\x22\x33\x44") #287454020
 print bytestream_to_count("\x11\x22\x33\x44\x55\x66\x77\x88")
 #1234605616436508552
 }}}

 I'm open for suggestions to implement this differently.

-- 
Ticket URL: <http://tracker.bro.org/bro/ticket/968#comment:11>
Bro Tracker <http://tracker.bro.org/bro>
Bro Issue Tracker



More information about the bro-dev mailing list