Changeset 169

Show
Ignore:
Timestamp:
05/01/07 18:16:39 (2 years ago)
Author:
zedsh..@zedshaw.com
Message:

Change up to use uint64_t for the Stackish number default rather than unsigned long.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • utu-core/build_logs/qualstats.log

    r167 r169  
    3183185879 0 0 0 0 0 0 0 0 
    3193195879 0 0 0 0 0 0 0 0 
     3205879 0 0 0 0 0 0 0 0 
     3215879 0 0 0 0 0 0 0 0 
     3225879 21 0 0 0 0 0 0 0 
     3235879 177 2 0 1 1 28716 61 0 
     3245879 177 2 0 1 1 28716 61 0 
     3255879 177 2 0 1 1 28716 61 0 
     3265880 190 2 0 1 1 28692 59 0 
     3275880 199 2 0 1 1 28692 59 0 
     3285880 202 2 0 1 1 28692 59 0 
     3295880 320 0 0 0 0 0 0 0 
     3305880 335 0 0 0 0 0 0 0 
     3315880 365 0 0 0 0 0 0 0 
     3325880 378 0 0 0 0 0 0 0 
     3335880 390 0 0 0 0 0 0 0 
     3345881 413 0 0 0 0 0 0 0 
  • utu-core/doc/site/src/default.template

    r167 r169  
    2626          the internet is dying 
    2727          <br/><br/> 
    28           <a href="{relocatable: /download.html}">download</a><br/> 
    29           if you're <a href="mailto:zedshaw-FU-SPAMMERS@zedshaw.com">invited</a> 
    30           <br/><br/> 
    3128          <a href="{relocatable: /theory.html}">theory</a><br/> 
    3229          what makes utu work 
     
    3431          <a href="{relocatable: /design.html}">design</a><br/> 
    3532          all that's good for geeks 
     33          <br/><br/> 
     34          <a href="{relocatable: /download.html}">download</a><br/> 
     35          if you're <a href="mailto:zedshaw-FU-SPAMMERS@zedshaw.com">invited</a> 
    3636          <br/><br/> 
    3737          <a href="{relocatable: /status.html}">status</a><br/> 
  • utu-core/src/client/client.c

    r146 r169  
    6969void error(Proxy *conn, UtuMendicantErrorCode code, bstring message) 
    7070{ 
    71   Node *err = Node_cons("[nbw", code, message, "err"); 
     71  Node *err = Node_cons("[nbw", (uint64_t)code, message, "err"); 
     72  Node_dump(err, ' ', 1); 
    7273  Proxy_listener_send(conn, err, NULL); 
    7374} 
  • utu-core/src/hub/connection.c

    r151 r169  
    291291      } 
    292292    } else { 
    293       log(ERROR, "%ld is not a valid circuit", state->recv.msg->circuit); 
     293      log(ERROR, "%llu is not a valid circuit", state->recv.msg->circuit); 
    294294      { state->cs = 11; goto _again;} 
    295295    } 
     
    347347    if(state->recv.msg->msgid != state->recv_count) { 
    348348      Message_ref_inc(state->recv.msg);  // we own it now 
    349       log(ERROR, "msg id is wrong, should be %ld but got %ld", state->recv_count, state->recv.msg->msgid); 
     349      log(ERROR, "msg id is wrong, should be %llu but got %llu", state->recv_count, state->recv.msg->msgid); 
    350350      { state->cs = 11; goto _again;} 
    351351    } 
  • utu-core/src/hub/connection_actions.rl

    r151 r169  
    7474      } 
    7575    } else { 
    76       log(ERROR, "%ld is not a valid circuit", state->recv.msg->circuit); 
     76      log(ERROR, "%llu is not a valid circuit", state->recv.msg->circuit); 
    7777      fgoto Aborting; 
    7878    } 
     
    120120    if(state->recv.msg->msgid != state->recv_count) { 
    121121      Message_ref_inc(state->recv.msg);  // we own it now 
    122       log(ERROR, "msg id is wrong, should be %ld but got %ld", state->recv_count, state->recv.msg->msgid); 
     122      log(ERROR, "msg id is wrong, should be %llu but got %llu", state->recv_count, state->recv.msg->msgid); 
    123123      fgoto Aborting; 
    124124    } 
  • utu-core/src/hub/hub.h

    r103 r169  
    8181typedef struct ConnectionState { 
    8282  int cs; 
    83   unsigned long recv_count; 
    84   unsigned long send_count; 
     83  uint64_t recv_count; 
     84  uint64_t send_count; 
    8585  MyriadClient *client; 
    8686  struct Hub *hub; 
  • utu-core/src/protocol/crypto.c

    r162 r169  
    718718} 
    719719 
    720 Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, unsigned long long *expecting) 
     720Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, uint64_t *expecting) 
    721721{ 
    722722  bstring hash = NULL; 
     
    726726  Node *msg = NULL; 
    727727  int rc = 0; 
    728   unsigned long long level_max = 1; 
     728  uint64_t level_max = 1; 
    729729  level_max <<= (level + 1); 
    730730 
     
    754754 
    755755  // construct the challenge 
    756   msg = Node_cons("[nbbbw", (unsigned long)level, blk2bstr(val.raw, NONCE_LENGTH), hash, signature, CRYPT_CHALLENGE_MSG);  
     756  msg = Node_cons("[nbbbw", (uint64_t)level, blk2bstr(val.raw, NONCE_LENGTH), hash, signature, CRYPT_CHALLENGE_MSG);  
    757757  check(msg, "failed constructing challenge message"); 
    758758 
     
    766766  bstring nonce = NULL; 
    767767  bstring ans_hash = NULL; 
    768   unsigned long level; 
     768  uint64_t level; 
    769769  unsigned long signature_len = MAXBLOCKSIZE; 
    770770  CryptNonce val; 
     
    773773  unsigned char test_hash[MAXBLOCKSIZE]; 
    774774  unsigned long hash_len; 
    775   unsigned long long level_max = 1; 
     775  uint64_t level_max = 1; 
    776776 
    777777  assert_not(state, NULL);  
     
    813813 
    814814  // swap the results 
    815   unsigned long long temp = val.num.left; 
     815  uint64_t temp = val.num.left; 
    816816  val.num.left = val.num.right; val.num.right = temp; 
    817817  ans_hash = CryptState_hash_nonce(&val); 
     
    838838} 
    839839 
    840 int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, unsigned long long expecting) 
     840int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, uint64_t expecting) 
    841841{ 
    842842  bstring ans_hash = NULL, ans_sig = NULL, ans_nonce = NULL; 
    843843  bstring ch_hash = NULL, ch_nonce = NULL; 
    844   unsigned long level; 
     844  uint64_t level; 
    845845  int rc = 0; 
    846846  CryptNonce ch_val, ans_val; 
  • utu-core/src/protocol/crypto.h

    r146 r169  
    6666 * after that. 
    6767 * 
    68  * Additionally, the nonces are 16 bytes but represented as two unsigned long long 
     68 * Additionally, the nonces are 16 bytes but represented as two uint64_t 
    6969 * integers (which is 16 bytes on 32 bit machines, so really not portable).  The 
    7070 * two nonces that are exchanged encrypted are simply incremented for each message 
     
    9797 
    9898/** Length of the nonce in bytes. */ 
    99 #define NONCE_LENGTH (sizeof(unsigned long long) * 2) 
     99#define NONCE_LENGTH (sizeof(uint64_t) * 2) 
    100100/** Default key size for ECC and AES in bytes. */ 
    101101#define KEY_LENGTH  32 
     
    108108 
    109109/** A union that allows simply conversion from two 
    110  * unsigned long long integers and an array of unsigned 
     110 * uint64_t integers and an array of unsigned 
    111111 * bytes.  This makes processing and then incrementing the 
    112112 * nonce much easier. 
     
    115115  unsigned char raw[NONCE_LENGTH]; 
    116116  struct { 
    117     unsigned long long left; 
    118     unsigned long long right; 
     117    uint64_t left; 
     118    uint64_t right; 
    119119  } num; 
    120120} CryptNonce; 
     
    366366/** 
    367367 * Constructs a signed hate challenge that the receiver must process. 
    368  * The algorithm is to construct two unsigned long long integers and  
     368 * The algorithm is to construct two uint64_t integers and  
    369369 * hash them.  The receiver is then only given one of the numbers and 
    370370 * has to calculate: 
     
    383383 * for the right side.  Larger values mean more work for the receiver. 
    384384 */ 
    385 Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, unsigned long long *expecting); 
     385Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, uint64_t *expecting); 
    386386 
    387387Node *CryptState_answer_hate_challenge(CryptState *state, Node *challenge, int *sig_stat, unsigned int max_allowed_level); 
    388388 
    389 int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, unsigned long long expecting); 
     389int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, uint64_t expecting); 
    390390 
    391391#endif 
  • utu-core/src/protocol/message.c

    r154 r169  
    5757} 
    5858 
    59 inline Node *Message_cons_header(unsigned long circuit, unsigned long more, unsigned long msgid) 
     59inline Node *Message_cons_header(uint64_t circuit, uint64_t more, uint64_t msgid) 
    6060{ 
    6161  return Node_cons("[nnnw", circuit, msgid, more,  "header"); 
    6262} 
    6363 
    64 Node *Message_cons(Node **hdr, unsigned long circuit, unsigned long more, unsigned long msgid, Node *data, const char *type) 
     64Node *Message_cons(Node **hdr, uint64_t circuit, uint64_t more, uint64_t msgid, Node *data, const char *type) 
    6565{ 
    6666  assert_not(hdr, NULL); 
     
    9191void Message_dump(Message *msg) 
    9292{ 
    93   fprintf(stderr, "Message: { circuit: %lu, msgid: %lu, more: %lu, type: %s received_at: %u, data: ",  
     93  fprintf(stderr, "Message: { circuit: %llu, msgid: %llu, more: %llu, type: %s received_at: %u, data: ",  
    9494      msg->circuit, msg->msgid, msg->more,  
    9595      bdata(msg->type), (unsigned int)msg->received_at); 
  • utu-core/src/protocol/message.h

    r148 r169  
    3333 */ 
    3434typedef struct Message { 
    35   unsigned long circuit; 
    36   unsigned long msgid; 
    37   unsigned long more; 
     35  uint64_t circuit; 
     36  uint64_t msgid; 
     37  uint64_t more; 
    3838  bstring type; 
    3939  time_t received_at; 
     
    9898 * @return The frame body you can send. 
    9999 */ 
    100 Node *Message_cons(Node **hdr, unsigned long circuit, unsigned long more, unsigned long msgid, Node *data, const char *type); 
     100Node *Message_cons(Node **hdr, uint64_t circuit, uint64_t more, uint64_t msgid, Node *data, const char *type); 
    101101 
    102102/** 
     
    124124 * @see Peer_send 
    125125 */ 
    126 Node *Message_cons_header(unsigned long circuit, unsigned long more, unsigned long msgid); 
     126Node *Message_cons_header(uint64_t circuit, uint64_t more, uint64_t msgid); 
    127127 
    128128#define Message_ref_inc(M) ((M)->ref_count++) 
  • utu-core/src/stackish/node.c

    r154 r169  
    9393      break; 
    9494    case TYPE_NUMBER: 
    95       bformata(str, "%lu%c", d->value.number, sep); 
     95      bformata(str, "%llu%c", d->value.number, sep); 
    9696      break; 
    9797    case TYPE_FLOAT: 
     
    176176 
    177177 
    178 Node *Node_new_number(Node *parent, unsigned long data) 
     178Node *Node_new_number(Node *parent, uint64_t data) 
    179179{ 
    180180  Node *node = calloc(1,sizeof(Node)); 
     
    266266        break; 
    267267      case 'n': { 
    268                   unsigned long number = va_arg(args, unsigned long); 
     268                  uint64_t number = va_arg(args, uint64_t); 
    269269                  Node *n = Node_new_number(cur_node, number); 
    270270                  assert_not(n,NULL); 
     
    365365        break; 
    366366      case 'n': { 
    367                   unsigned long *number = va_arg(args, unsigned long *); 
     367                  uint64_t *number = va_arg(args, uint64_t *); 
    368368                  check_type(number, NUMBER, cur_node); 
    369369                  *number = cur_node->value.number; 
  • utu-core/src/stackish/node.h

    r124 r169  
    1616 
    1717#include <myriad/bstring/bstrlib.h> 
     18#include <stdint.h> 
    1819 
    1920/** Determines what is contained in the Node.value union. */ 
     
    4546   * holds both TYPE_STRING and TYPE_BLOB.*/ 
    4647  union { 
    47     unsigned long number; 
     48    uint64_t number; 
    4849    bstring string; 
    4950    double floating; 
     
    120121 
    121122/** Constructs a new node that represents a number, attaching to parent if not NULL. */ 
    122 Node *Node_new_number(Node *parent, unsigned long data); 
     123Node *Node_new_number(Node *parent, uint64_t data); 
    123124 
    124125/** Constructs a new node that represents a float, attaching to parent if not NULL. */ 
     
    142143 * 
    143144 * '[' -- Start a new group, just like Stackish. 
    144  * 'n' -- A number.  Argument is an unsigned long
     145 * 'n' -- A number.  Argument is an uint64_t
    145146 * 'f' -- A float. Argument is a double. 
    146147 * 'b' -- A blob. Argument is a bstring. 
  • utu-core/src/stackish/stackish.c

    r149 r169  
    4141    case TYPE_NUMBER: 
    4242      end = NULL; 
    43       unsigned long number = strtoul(start, &end, 10); 
     43      uint64_t number = strtoul(start, &end, 10); 
    4444      check(end == start + length, "malformed number on input"); 
    4545      node = Node_new_number(current, number); 
  • utu-core/src/stackish/stackish.rl

    r106 r169  
    4040    case TYPE_NUMBER: 
    4141      end = NULL; 
    42       unsigned long number = strtoul(start, &end, 10); 
     42      uint64_t number = strtoul(start, &end, 10); 
    4343      check(end == start + length, "malformed number on input"); 
    4444      node = Node_new_number(current, number); 
  • utu-core/tests/test_crypto.c

    r124 r169  
    171171  peer1 = CryptState_create(p1name, NULL); 
    172172  peer2 = CryptState_create(p2name, NULL); 
    173   int sig_stat
     173  int sig_stat = 0
    174174  Node *challenge, *answer; 
    175   unsigned long long expecting = 0; 
     175  uint64_t expecting = 0; 
    176176  time_t start, end; 
    177177  int level = 0; 
     
    194194    ASSERT(answer != NULL, "failed to make answer"); 
    195195 
     196    if(!answer) return; 
     197 
    196198    start = time(NULL); 
    197199    ASSERT(CryptState_validate_hate_challenge(peer1, challenge, answer, expecting), "challenge/response failed");