static int tftp_session_allocate(Slirp *slirp, struct sockaddr_storage *srcsas,

                                 struct tftp_t *tp)

{

  struct tftp_session *spt;

  int k;



  for (k = 0; k < TFTP_SESSIONS_MAX; k++) {

    spt = &slirp->tftp_sessions[k];



    if (!tftp_session_in_use(spt))

        goto found;



    /* sessions time out after 5 inactive seconds */

    if ((int)(curtime - spt->timestamp) > 5000) {

        tftp_session_terminate(spt);

        goto found;

    }

  }



  return -1;



 found:

  memset(spt, 0, sizeof(*spt));

  spt->client_addr = *srcsas;

  spt->fd = -1;

  spt->block_size = 512;

  spt->client_port = tp->udp.uh_sport;

  spt->slirp = slirp;



  tftp_session_update(spt);



  return k;

}

static int tftp_session_allocate(Slirp *slirp, struct sockaddr_storage *srcsas,

                                 struct tftp_t *tp)

{

  struct tftp_session *spt;

  int k;



  for (k = 0; k < TFTP_SESSIONS_MAX; k++) {

    spt = &slirp->tftp_sessions[k];



    if (!tftp_session_in_use(spt))

        goto found;



    

    if ((int)(curtime - spt->timestamp) > 5000) {

        tftp_session_terminate(spt);

        goto found;

    }

  }



  return -1;



 found:

  memset(spt, 0, sizeof(*spt));

  spt->client_addr = *srcsas;

  spt->fd = -1;

  spt->block_size = 512;

  spt->client_port = tp->udp.uh_sport;

  spt->slirp = slirp;



  tftp_session_update(spt);



  return k;

}

  spt->client_addr = *srcsas;
static int FUNC_0(Slirp *VAR_0, struct sockaddr_storage *VAR_1,

                                 struct tftp_t *VAR_2)

{

  struct tftp_session *VAR_3;

  int VAR_4;



  for (VAR_4 = 0; VAR_4 < TFTP_SESSIONS_MAX; VAR_4++) {

    VAR_3 = &VAR_0->tftp_sessions[VAR_4];



    if (!tftp_session_in_use(VAR_3))

        goto found;



    

    if ((int)(curtime - VAR_3->timestamp) > 5000) {

        tftp_session_terminate(VAR_3);

        goto found;

    }

  }



  return -1;



 found:

  memset(VAR_3, 0, sizeof(*VAR_3));

  VAR_3->client_addr = *VAR_1;

  VAR_3->fd = -1;

  VAR_3->block_size = 512;

  VAR_3->client_port = VAR_2->udp.uh_sport;

  VAR_3->VAR_0 = VAR_0;



  tftp_session_update(VAR_3);



  return VAR_4;

}

static int FUNC_0(Slirp *VAR_0, struct sockaddr_storage *VAR_1,
struct tftp_t *VAR_2)
{ struct tftp_session *VAR_3; int VAR_4; for (VAR_4 = 0; VAR_4 < TFTP_SESSIONS_MAX; VAR_4++) { VAR_3 = &VAR_0->tftp_sessions[VAR_4]; if (!tftp_session_in_use(VAR_3))
goto found; if ((int)(curtime - VAR_3->timestamp) > 5000) { tftp_session_terminate(VAR_3); goto found; } } return -1; found:
memset(VAR_3, 0, sizeof(*VAR_3)); VAR_3->client_addr = *VAR_1; VAR_3->fd = -1; VAR_3->block_size = 512; VAR_3->client_port = VAR_2->udp.uh_sport; VAR_3->VAR_0 = VAR_0; tftp_session_update(VAR_3); return VAR_4; }