static void tftp_send_error(struct tftp_session *spt,

                            uint16_t errorcode, const char *msg,

                            struct tftp_t *recv_tp)

{

  struct sockaddr_in saddr, daddr;

  struct mbuf *m;

  struct tftp_t *tp;



  m = m_get(spt->slirp);



  if (!m) {

    goto out;

  }



  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_ERROR);

  tp->x.tp_error.tp_error_code = htons(errorcode);

  pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg);



  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 + 3 + strlen(msg) -

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



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



out:

  tftp_session_terminate(spt);

}

static void tftp_send_error(struct tftp_session *spt,

                            uint16_t errorcode, const char *msg,

                            struct tftp_t *recv_tp)

{

  struct sockaddr_in saddr, daddr;

  struct mbuf *m;

  struct tftp_t *tp;



  m = m_get(spt->slirp);



  if (!m) {

    goto out;

  }



  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_ERROR);

  tp->x.tp_error.tp_error_code = htons(errorcode);

  pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg);



  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 + 3 + strlen(msg) -

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



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



out:

  tftp_session_terminate(spt);

}

static void FUNC_0(struct tftp_session *VAR_0,

                            uint16_t VAR_1, const char *VAR_2,

                            struct tftp_t *VAR_3)

{

  struct sockaddr_in VAR_4, VAR_5;

  struct mbuf *VAR_6;

  struct tftp_t *VAR_7;



  VAR_6 = m_get(VAR_0->slirp);



  if (!VAR_6) {

    goto out;

  }



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



  VAR_6->m_data += IF_MAXLINKHDR;

  VAR_7 = (void *)VAR_6->m_data;

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



  VAR_7->tp_op = htons(TFTP_ERROR);

  VAR_7->x.tp_error.tp_error_code = htons(VAR_1);

  pstrcpy((char *)VAR_7->x.tp_error.tp_msg, sizeof(VAR_7->x.tp_error.tp_msg), VAR_2);



  VAR_4.sin_addr = VAR_3->ip.ip_dst;

  VAR_4.sin_port = VAR_3->udp.uh_dport;



  VAR_5.sin_addr = VAR_0->client_ip;

  VAR_5.sin_port = VAR_0->client_port;



  VAR_6->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(VAR_2) -

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



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



out:

  tftp_session_terminate(VAR_0);

}

static void FUNC_0(struct tftp_session *VAR_0,
uint16_t VAR_1, const char *VAR_2,
struct tftp_t *VAR_3)
{ struct sockaddr_in VAR_4, VAR_5; struct mbuf *VAR_6; struct tftp_t *VAR_7; VAR_6 = m_get(VAR_0->slirp); if (!VAR_6) { goto out; } memset(VAR_6->m_data, 0, VAR_6->m_size); VAR_6->m_data += IF_MAXLINKHDR; VAR_7 = (void *)VAR_6->m_data; VAR_6->m_data += sizeof(struct udpiphdr); VAR_7->tp_op = htons(TFTP_ERROR); VAR_7->x.tp_error.tp_error_code = htons(VAR_1); pstrcpy((char *)VAR_7->x.tp_error.tp_msg, sizeof(VAR_7->x.tp_error.tp_msg), VAR_2); VAR_4.sin_addr = VAR_3->ip.ip_dst; VAR_4.sin_port = VAR_3->udp.uh_dport; VAR_5.sin_addr = VAR_0->client_ip; VAR_5.sin_port = VAR_0->client_port; VAR_6->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(VAR_2) -
sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, VAR_6, &VAR_4, &VAR_5, IPTOS_LOWDELAY); out:
tftp_session_terminate(VAR_0); }