static int tftp_send_oack(struct tftp_session *spt,

                          const char *keys[], uint32_t values[], int nb,

                          struct tftp_t *recv_tp)

{

    struct sockaddr_in saddr, daddr;

    struct mbuf *m;

    struct tftp_t *tp;

    int i, n = 0;



    m = m_get(spt->slirp);



    if (!m)

	return -1;



    memset(m->m_data, 0, m->m_size);



    m->m_data += IF_MAXLINKHDR;

    tp = (void *)m->m_data;

    m->m_data += sizeof(struct udpiphdr);



    tp->tp_op = htons(TFTP_OACK);

    for (i = 0; i < nb; i++) {

        n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",

                      keys[i]) + 1;

        n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",

                      values[i]) + 1;

    }



    saddr.sin_addr = recv_tp->ip.ip_dst;

    saddr.sin_port = recv_tp->udp.uh_dport;



    daddr.sin_addr = spt->client_ip;

    daddr.sin_port = spt->client_port;



    m->m_len = sizeof(struct tftp_t) - 514 + n -

        sizeof(struct ip) - sizeof(struct udphdr);

    udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);



    return 0;

}

static int tftp_send_oack(struct tftp_session *spt,

                          const char *keys[], uint32_t values[], int nb,

                          struct tftp_t *recv_tp)

{

    struct sockaddr_in saddr, daddr;

    struct mbuf *m;

    struct tftp_t *tp;

    int i, n = 0;



    m = m_get(spt->slirp);



    if (!m)

	return -1;



    memset(m->m_data, 0, m->m_size);



    m->m_data += IF_MAXLINKHDR;

    tp = (void *)m->m_data;

    m->m_data += sizeof(struct udpiphdr);



    tp->tp_op = htons(TFTP_OACK);

    for (i = 0; i < nb; i++) {

        n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",

                      keys[i]) + 1;

        n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",

                      values[i]) + 1;

    }



    saddr.sin_addr = recv_tp->ip.ip_dst;

    saddr.sin_port = recv_tp->udp.uh_dport;



    daddr.sin_addr = spt->client_ip;

    daddr.sin_port = spt->client_port;



    m->m_len = sizeof(struct tftp_t) - 514 + n -

        sizeof(struct ip) - sizeof(struct udphdr);

    udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);



    return 0;

}

static int FUNC_0(struct tftp_session *VAR_0,

                          const char *VAR_1[], uint32_t VAR_2[], int VAR_3,

                          struct tftp_t *VAR_4)

{

    struct sockaddr_in VAR_5, VAR_6;

    struct mbuf *VAR_7;

    struct tftp_t *VAR_8;

    int VAR_9, VAR_10 = 0;



    VAR_7 = m_get(VAR_0->slirp);



    if (!VAR_7)

	return -1;



    memset(VAR_7->m_data, 0, VAR_7->m_size);



    VAR_7->m_data += IF_MAXLINKHDR;

    VAR_8 = (void *)VAR_7->m_data;

    VAR_7->m_data += sizeof(struct udpiphdr);



    VAR_8->tp_op = htons(TFTP_OACK);

    for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9++) {

        VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, "%s",

                      VAR_1[VAR_9]) + 1;

        VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, "%u",

                      VAR_2[VAR_9]) + 1;

    }



    VAR_5.sin_addr = VAR_4->ip.ip_dst;

    VAR_5.sin_port = VAR_4->udp.uh_dport;



    VAR_6.sin_addr = VAR_0->client_ip;

    VAR_6.sin_port = VAR_0->client_port;



    VAR_7->m_len = sizeof(struct tftp_t) - 514 + VAR_10 -

        sizeof(struct ip) - sizeof(struct udphdr);

    udp_output2(NULL, VAR_7, &VAR_5, &VAR_6, IPTOS_LOWDELAY);



    return 0;

}

static int FUNC_0(struct tftp_session *VAR_0,
const char *VAR_1[], uint32_t VAR_2[], int VAR_3,
struct tftp_t *VAR_4)
{ struct sockaddr_in VAR_5, VAR_6; struct mbuf *VAR_7; struct tftp_t *VAR_8; int VAR_9, VAR_10 = 0; VAR_7 = m_get(VAR_0->slirp); if (!VAR_7)
return -1; memset(VAR_7->m_data, 0, VAR_7->m_size); VAR_7->m_data += IF_MAXLINKHDR; VAR_8 = (void *)VAR_7->m_data; VAR_7->m_data += sizeof(struct udpiphdr); VAR_8->tp_op = htons(TFTP_OACK); for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9++) { VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, "%s",
VAR_1[VAR_9]) + 1; VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, "%u",
VAR_2[VAR_9]) + 1; } VAR_5.sin_addr = VAR_4->ip.ip_dst; VAR_5.sin_port = VAR_4->udp.uh_dport; VAR_6.sin_addr = VAR_0->client_ip; VAR_6.sin_port = VAR_0->client_port; VAR_7->m_len = sizeof(struct tftp_t) - 514 + VAR_10 -
sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, VAR_7, &VAR_5, &VAR_6, IPTOS_LOWDELAY); return 0; }