Commit b8b8ab2f authored by Roger Dingledine's avatar Roger Dingledine
Browse files

port is now kept in host order except in sin_port


svn:r82
parent c040bbe0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ int circuit_init(circuit_t *circ, int aci_type) {
  log(LOG_DEBUG,"circuit_init(): starting");
  circ->n_addr = ol->addr;
  circ->n_port = ol->port;
  log(LOG_DEBUG,"circuit_init(): Set port to %u.",ntohs(ol->port));
  log(LOG_DEBUG,"circuit_init(): Set port to %u.",ol->port);
  circ->p_f = ol->backf;
  log(LOG_DEBUG,"circuit_init(): Set BACKF to %u.",ol->backf);
  circ->n_f = ol->forwf;
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ void command_process_create_cell(cell_t *cell, connection_t *conn) {
    circ->n_port = n_conn->port;

    circ->n_conn = n_conn;
    log(LOG_DEBUG,"command_process_create_cell(): n_conn is %s:%u",n_conn->address,ntohs(n_conn->port));
    log(LOG_DEBUG,"command_process_create_cell(): n_conn is %s:%u",n_conn->address,n_conn->port);

    /* send the CREATE cells on to the next hop  */
    pad_onion(circ->onion,circ->onionlen, sizeof(onion_layer_t));
+2 −2
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ int retry_all_connections(int role, routerinfo_t **router_array, int rarray_len,
    for (i=0;i<rarray_len;i++) {
      router = router_array[i];
      if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */
        log(LOG_DEBUG,"retry_all_connections(): connecting to OR %s:%u.",router->address,ntohs(router->or_port));
        log(LOG_DEBUG,"retry_all_connections(): connecting to OR %s:%u.",router->address,router->or_port);
        connection_or_connect_as_or(router, prkey, &local);
      }
    }
@@ -517,7 +517,7 @@ int connection_encrypt_cell_header(cell_t *cellp, connection_t *conn) {
#endif

  if(crypto_cipher_encrypt(conn->f_crypto, (char *)cellp, 8, newheader)) {
    log(LOG_ERR,"Could not encrypt data for connection %s:%u.",conn->address,ntohs(conn->port));
    log(LOG_ERR,"Could not encrypt data for connection %s:%u.",conn->address,conn->port);
    return -1;
  }
#if 0
+4 −6
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ int ap_handshake_process_ss(connection_t *conn) {

    if(connection_fetch_from_buf(conn->dest_port,conn->dest_port_len,conn) < 0)
      return -1;
    log(LOG_DEBUG,"ap_handshake_process_ss(): Read dest_port (network order) '%s'.",conn->dest_port);
    log(LOG_DEBUG,"ap_handshake_process_ss(): Read dest_port '%s'.",conn->dest_port);

    conn->dest_port_received = conn->dest_port_len;
  }
@@ -202,7 +202,7 @@ int ap_handshake_establish_circuit(connection_t *conn, unsigned int *route, int
  circ->cpathlen = routelen;

  log(LOG_DEBUG,"ap_handshake_establish_circuit(): Looking for firsthop '%s:%u'",
      firsthop->address,ntohs(firsthop->or_port));
      firsthop->address,firsthop->or_port);
  n_conn = connection_twin_get_by_addr_port(firsthop->addr,firsthop->or_port);
  if(!n_conn) { /* not currently connected */
    circ->n_addr = firsthop->addr;
@@ -257,7 +257,7 @@ int ap_handshake_send_onion(connection_t *ap_conn, connection_t *n_conn, circuit

  circ->n_aci = get_unique_aci_by_addr_port(circ->n_addr, circ->n_port, ACI_TYPE_BOTH);
  circ->n_conn = n_conn;
  log(LOG_DEBUG,"ap_handshake_send_onion(): n_conn is %s:%u",n_conn->address,ntohs(n_conn->port));
  log(LOG_DEBUG,"ap_handshake_send_onion(): n_conn is %s:%u",n_conn->address,n_conn->port);

  /* deliver the onion as one or more create cells */
  cell.command = CELL_CREATE;
@@ -267,9 +267,7 @@ int ap_handshake_send_onion(connection_t *ap_conn, connection_t *n_conn, circuit
  tmpbuf = malloc(tmpbuflen);
  if(!tmpbuf)
    return -1;
  circ->onionlen = htonl(circ->onionlen);
  memcpy(tmpbuf,&circ->onionlen,4);
  circ->onionlen = ntohl(circ->onionlen);
  *(uint32_t*)tmpbuf = htonl(circ->onionlen);
  memcpy(tmpbuf+4, circ->onion, circ->onionlen);

  dataleft = tmpbuflen;
+4 −4
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ int connection_exit_finished_flushing(connection_t *conn) {
      /* the connect has finished. */

      log(LOG_DEBUG,"connection_exit_finished_flushing() : Connection to %s:%u established.",
          conn->address,ntohs(conn->port));
          conn->address,conn->port);
      
      conn->state = EXIT_CONN_STATE_OPEN;
      if(connection_wants_to_flush(conn)) /* in case there are any queued data cells */
@@ -125,10 +125,10 @@ int connection_exit_process_data_cell(cell_t *cell, connection_t *conn) {
      
        memset((void *)&dest_addr,0,sizeof(dest_addr));
        dest_addr.sin_family = AF_INET;
        dest_addr.sin_port = conn->port;
        dest_addr.sin_port = htons(conn->port);
        memcpy((void *)&dest_addr.sin_addr, &conn->addr, sizeof(uint32_t));
      
        log(LOG_DEBUG,"connection_exit_process_data_cell(): Connecting to %s:%u.",conn->address,ntohs(conn->port)); 
        log(LOG_DEBUG,"connection_exit_process_data_cell(): Connecting to %s:%u.",conn->address,conn->port); 

        if(connect(s,(struct sockaddr *)&dest_addr,sizeof(dest_addr)) < 0){
          if(errno != EINPROGRESS){
@@ -148,7 +148,7 @@ int connection_exit_process_data_cell(cell_t *cell, connection_t *conn) {
        }

        /* it succeeded. we're connected. */
        log(LOG_DEBUG,"connection_exit_process_data_cell(): Connection to %s:%u established.",conn->address,ntohs(conn->port));
        log(LOG_DEBUG,"connection_exit_process_data_cell(): Connection to %s:%u established.",conn->address,conn->port);

        conn->s = s;
        connection_set_poll_socket(conn);
Loading