Lines Matching refs:tp
53 static int tftp_session_allocate(struct tftp_t *tp)
73 memcpy(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip));
74 spt->client_port = tp->udp.uh_sport;
81 static int tftp_session_find(struct tftp_t *tp)
90 if (!memcmp(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip))) {
91 if (spt->client_port == tp->udp.uh_sport) {
137 struct tftp_t *tp;
148 tp = (void *)m->m_data;
151 tp->tp_op = htons(TFTP_OACK);
152 n += snprintf((char *)tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
154 n += snprintf((char *)tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",
178 struct tftp_t *tp;
190 tp = (void *)m->m_data;
193 tp->tp_op = htons(TFTP_ERROR);
194 tp->x.tp_error.tp_error_code = htons(errorcode);
195 pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg);
221 struct tftp_t *tp;
237 tp = (void *)m->m_data;
240 tp->tp_op = htons(TFTP_DATA);
241 tp->x.tp_data.tp_block_nr = htons(block_nr);
249 nobytes = tftp_read_data(spt, block_nr - 1, tp->x.tp_data.tp_buf, 512);
256 tftp_send_error(spt, 1, "File not found", tp);
276 static void tftp_handle_rrq(struct tftp_t *tp, int pktlen)
282 s = tftp_session_allocate(tp);
290 src = tp->x.tp_buf;
292 n = pktlen - ((uint8_t *)&tp->x.tp_buf[0] - (uint8_t *)tp);
321 tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
332 tftp_send_error(spt, 2, "Access violation", tp);
339 tftp_send_error(spt, 2, "Access violation", tp);
346 tftp_send_error(spt, 1, "File not found", tp);
351 tftp_send_error(spt, 2, "Access violation", tp);
362 tftp_send_error(spt, 2, "Access violation", tp);
383 tftp_send_error(spt, 1, "File not found", tp);
388 tftp_send_oack(spt, "tsize", tsize, tp);
392 tftp_send_data(spt, 1, tp);
395 static void tftp_handle_ack(struct tftp_t *tp, int pktlen)
399 s = tftp_session_find(tp);
406 ntohs(tp->x.tp_data.tp_block_nr) + 1,
407 tp) < 0) {
414 struct tftp_t *tp = (struct tftp_t *)m->m_data;
416 switch(ntohs(tp->tp_op)) {
418 tftp_handle_rrq(tp, m->m_len);
422 tftp_handle_ack(tp, m->m_len);