Advertisement
Guest User

Bro 128 bit uids

a guest
Jun 5th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.68 KB | None | 0 0
  1. diff --git a/src/Conn.cc b/src/Conn.cc
  2. index bc2e7fb..dfa2eb8 100644
  3. --- a/src/Conn.cc
  4. +++ b/src/Conn.cc
  5. @@ -160,6 +160,7 @@ Connection::Connection(NetSessions* s, HashKey* k, double t, const ConnID* id,
  6.     conn_timer_mgr = tag ? new TimerMgr::Tag(*tag) : 0;
  7.  
  8.     uid = 0; // Will set later.
  9. +   uid2 = 0;
  10.  
  11.     if ( arg_encap )
  12.         encapsulation = new EncapsulationStack(*arg_encap);
  13. @@ -378,11 +379,15 @@ RecordVal* Connection::BuildConnVal()
  14.         conn_val->Assign(7, new Val(0, TYPE_COUNT));    // hot
  15.         conn_val->Assign(8, new StringVal("")); // history
  16.  
  17. -       if ( ! uid )
  18. +       if ( ! uid ) {
  19.             uid = calculate_unique_id();
  20. +           uid2 = calculate_unique_id();
  21. +       }
  22.  
  23. -       char tmp[20];
  24. -       conn_val->Assign(9, new StringVal(uitoa_n(uid, tmp, sizeof(tmp), 62)));
  25. +       char tmp[40];
  26. +       char tmp2[40];
  27. +       uitoa_n(uid2, tmp2, sizeof(tmp2), 62);
  28. +       conn_val->Assign(9, new StringVal(uitoa_n(uid, tmp, sizeof(tmp), 62, tmp2)));
  29.  
  30.         if ( encapsulation && encapsulation->Depth() > 0 )
  31.             conn_val->Assign(10, encapsulation->GetVectorVal());
  32. diff --git a/src/Conn.h b/src/Conn.h
  33. index 782d41a..8f2345b 100644
  34. --- a/src/Conn.h
  35. +++ b/src/Conn.h
  36. @@ -318,6 +318,7 @@ protected:
  37.     PIA* primary_PIA;
  38.  
  39.     uint64 uid; // Globally unique connection ID.
  40. +   uint64 uid2;    // Globally unique connection ID 2.
  41.  };
  42.  
  43.  class ConnectionTimer : public Timer {
  44. diff --git a/src/bro.bif b/src/bro.bif
  45. index 26fe16d..2e9d5ac 100644
  46. --- a/src/bro.bif
  47. +++ b/src/bro.bif
  48. @@ -974,9 +974,12 @@ function entropy_test_finish%(handle: opaque of entropy%): entropy_test_result
  49.  ## .. bro:see:: unique_id_from
  50.  function unique_id%(prefix: string%) : string
  51.     %{
  52. -   char tmp[20];
  53. +   char tmp[40];
  54. +   char tmp2[40];
  55.     uint64 uid = calculate_unique_id(UID_POOL_DEFAULT_SCRIPT);
  56. -   return new StringVal(uitoa_n(uid, tmp, sizeof(tmp), 62, prefix->CheckString()));
  57. +   uint64 uid2 = calculate_unique_id(UID_POOL_DEFAULT_SCRIPT);
  58. +   uitoa_n(uid2, tmp2, sizeof(tmp2), 62, prefix->CheckString());
  59. +   return new StringVal(uitoa_n(uid, tmp, sizeof(tmp), 62, tmp2));
  60.     %}
  61.  
  62.  ## Creates an identifier that is unique with high probability.
  63. @@ -990,9 +993,12 @@ function unique_id_from%(pool: int, prefix: string%) : string
  64.     %{
  65.     pool += UID_POOL_CUSTOM_SCRIPT; // Make sure we don't conflict with internal pool.
  66.  
  67. -   char tmp[20];
  68. +   char tmp[40];
  69. +   char tmp2[40];
  70.     uint64 uid = calculate_unique_id(pool);
  71. -   return new StringVal(uitoa_n(uid, tmp, sizeof(tmp), 62, prefix->CheckString()));
  72. +   uint64 uid2 = calculate_unique_id(pool);
  73. +   uitoa_n(uid2, tmp2, sizeof(tmp2), 62, prefix->CheckString());
  74. +   return new StringVal(uitoa_n(uid, tmp, sizeof(tmp), 62, tmp2));
  75.     %}
  76.  
  77.  # ===========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement