Lines Matching refs:spt
42 static void tftp_session_update(struct tftp_session *spt)
44 spt->timestamp = curtime;
45 spt->in_use = 1;
48 static void tftp_session_terminate(struct tftp_session *spt)
50 spt->in_use = 0;
55 struct tftp_session *spt;
59 spt = &tftp_sessions[k];
61 if (!spt->in_use)
65 if ((int)(curtime - spt->timestamp) > 5000)
72 memset(spt, 0, sizeof(*spt));
73 spt->client_ip = ip_geth(tp->ip.ip_src);
74 spt->client_port = port_geth(tp->udp.uh_sport);
76 tftp_session_update(spt);
83 struct tftp_session *spt;
87 spt = &tftp_sessions[k];
89 if (spt->in_use) {
90 if (spt->client_ip == ip_geth(tp->ip.ip_src)) {
91 if (spt->client_port == port_geth(tp->udp.uh_sport)) {
101 static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr,
110 tftp_prefix, spt->filename);
131 static int tftp_send_oack(struct tftp_session *spt,
162 spt->client_ip,
163 spt->client_port );
174 static int tftp_send_error(struct tftp_session *spt,
204 spt->client_ip,
205 spt->client_port );
214 tftp_session_terminate(spt);
219 static int tftp_send_data(struct tftp_session *spt,
252 spt->client_ip,
253 spt->client_port );
255 nobytes = tftp_read_data(spt, block_nr - 1, tp->x.tp_data.tp_buf, 512);
262 tftp_send_error(spt, 1, "File not found", tp);
273 tftp_session_update(spt);
276 tftp_session_terminate(spt);
284 struct tftp_session *spt;
294 spt = &tftp_sessions[s];
297 dst = spt->filename;
327 tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
335 if ((spt->filename[0] != '/')
336 || (spt->filename[strlen((char *)spt->filename) - 1] == '/')
337 || strstr((char *)spt->filename, "/../")) {
338 tftp_send_error(spt, 2, "Access violation", tp);
345 tftp_send_error(spt, 2, "Access violation", tp);
351 if (tftp_read_data(spt, 0, spt->filename, 0) < 0) {
352 tftp_send_error(spt, 1, "File not found", tp);
357 tftp_send_error(spt, 2, "Access violation", tp);
368 tftp_send_error(spt, 2, "Access violation", tp);
384 tftp_prefix, spt->filename);
389 tftp_send_error(spt, 1, "File not found", tp);
394 tftp_send_oack(spt, "tsize", tsize, tp);
398 tftp_send_data(spt, 1, tp);