These code from googlecode tinyos-main, r5538
In tos/lib/net/blip/UdpP.nc   line 27 - 52 .

the alloc_lport function is used to allocate a port number for a udp client
by the sendtov() command of the UDP Interface.
but the statment " *last_localport = (last_localport < LOCAL_PORT_START) ?
last_localport + 1 : LOCAL_PORT_START;  *" will always return the value
LOCAL_PORT_START since the condition *(last_localport <
LOCAL_PORT_START)  *will
always be false;

it seem that this statement should be modified to *last_localport =
(last_localport < LOCAL_PORT_STOP) ? last_localport + 1 : LOCAL_PORT_START;*

*uint16_t local_ports[N_CLIENTS];

  enum {
    LOCAL_PORT_START = 51024U, // 0xc750
    LOCAL_PORT_STOP  = 54999U, // 0xd6d7
  };
  uint16_t last_localport = LOCAL_PORT_START;

  uint16_t alloc_lport(uint8_t clnt) {
    int i, done = 0;
    uint16_t compare = htons(last_localport);
    last_localport = (last_localport < LOCAL_PORT_START) ? last_localport +
1 : LOCAL_PORT_START;
    while (!done) {
      done = 1;
      for (i = 0; i < N_CLIENTS; i++) {
        if (local_ports[i] == compare) {
          last_localport = (last_localport < LOCAL_PORT_START) ?
last_localport + 1 : LOCAL_PORT_START;
          compare = htons(last_localport);
          done = 0;
          break;
        }
      }
    }
    return last_localport;
}*
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to