Lines Matching refs:buf

109 static int tftp_fileop_read(void *ref,hsaddr_t buf,int len);
110 static int tftp_fileop_write(void *ref,hsaddr_t buf,int len);
158 ebuf_t *buf = NULL;
186 buf = udp_alloc();
187 if (!buf) break;
190 ebuf_append_u16_be(buf,TFTP_OP_RRQ); /* read file */
193 ebuf_append_u16_be(buf,TFTP_OP_WRQ); /* write file */
195 ebuf_append_bytes(buf,filename,strlen(filename)+1);
196 ebuf_append_bytes(buf,datamode,strlen(datamode)+1);
198 udp_send(info->tftp_socket,buf,info->tftp_ipaddr);
200 buf = udp_recv_with_timeout(info->tftp_socket,tftp_rrq_timeout);
201 if (buf) break;
208 if (!buf) {
218 ebuf_get_u16_be(buf,type);
227 udp_connect(info->tftp_socket,(uint16_t) buf->eb_usrdata);
230 udp_free(buf);
241 udp_free(buf);
250 ebuf_get_u16_be(buf,error);
251 xprintf("TFTP error %d: %s\n",error,ebuf_ptr(buf));
252 udp_free(buf);
261 ebuf_get_u16_be(buf,block);
262 udp_connect(info->tftp_socket,(uint16_t) buf->eb_usrdata);
264 info->tftp_blklen = ebuf_length(buf);
265 ebuf_get_bytes(buf,info->tftp_data,ebuf_length(buf));
266 udp_free(buf);
294 ebuf_t *buf;
311 buf = udp_alloc();
312 if (!buf) return -1;
318 ebuf_append_u16_be(buf,TFTP_OP_ACK);
319 ebuf_append_u16_be(buf,info->tftp_blknum);
320 udp_send(info->tftp_socket,buf,info->tftp_ipaddr);
326 buf = udp_recv_with_timeout(info->tftp_socket,tftp_recv_timeout);
327 if (buf == NULL) continue;
333 ebuf_get_u16_be(buf,cmd);
335 udp_free(buf);
339 ebuf_get_u16_be(buf,block);
341 udp_free(buf);
350 info->tftp_blklen = ebuf_length(buf);
351 ebuf_get_bytes(buf,info->tftp_data,ebuf_length(buf));
352 udp_free(buf);
389 ebuf_t *buf;
406 buf = udp_alloc();
407 if (!buf) return -1;
413 ebuf_append_u16_be(buf,TFTP_OP_DATA);
414 ebuf_append_u16_be(buf,info->tftp_blknum);
415 ebuf_append_bytes(buf,info->tftp_data,info->tftp_blklen);
416 udp_send(info->tftp_socket,buf,info->tftp_ipaddr);
422 buf = udp_recv_with_timeout(info->tftp_socket,tftp_recv_timeout);
423 if (buf == NULL) continue;
429 ebuf_get_u16_be(buf,cmd);
435 ebuf_get_u16_be(buf,error);
436 xprintf("TFTP write error %d: %s\n",error,ebuf_ptr(buf));
439 udp_free(buf);
444 udp_free(buf);
448 ebuf_get_u16_be(buf,block);
450 udp_free(buf);
460 udp_free(buf);
495 ebuf_t *buf;
501 buf = udp_alloc();
502 if (buf) {
505 ebuf_append_u16_be(buf,TFTP_OP_ACK);
506 ebuf_append_u16_be(buf,info->tftp_blknum);
509 ebuf_append_u16_be(buf,TFTP_OP_ERROR);
510 ebuf_append_u16_be(buf,TFTP_ERR_DISKFULL);
511 ebuf_append_bytes(buf,emsg,strlen(emsg)+1);
513 udp_send(info->tftp_socket,buf,info->tftp_ipaddr);
617 * tftp_fileop_read(ref,buf,len)
625 * buf - destination buffer address (NULL to read data and
633 static int tftp_fileop_read(void *ref,hsaddr_t buf,int len)
652 if (buf) {
653 hs_memcpy_to_hs(buf,&(info->tftp_data[info->tftp_blkoffset]),amtcopy);
654 buf += amtcopy;
673 * tftp_fileop_write(ref,buf,len)
681 * buf - source buffer address
688 static int tftp_fileop_write(void *ref,hsaddr_t buf,int len)
705 hs_memcpy_from_hs(&(info->tftp_data[info->tftp_blklen]),buf,amtcopy);
706 buf += amtcopy;