45 ret =
udp_sendto(sock, remip, *remport, (
char *) msg, mlen);
64 kprintf(
"\n[tftp_send1] UDP Receive Timeout\n");
75 kprintf(
"\n[tftp_send1] TFTP Error %d, %s\n",
76 ntohs(inmsg->tf_ercode),
84 (
ntohs(inmsg->tf_dblk) == expected)) {
102 const char* filename,
108 return tftpget_mb(serverip, filename, &rcv_buf, &rcv_buf_size, 1,
120 const char* filename,
146 if(filename ==
NULL || serverip == 0 || rcv_bufs ==
NULL ||
147 rcv_buf_sizes ==
NULL || rcv_buf_count == 0) {
148 kprintf(
"[TFTP GET] ERROR: Invalid argument\n");
151 for(i = 0; i < rcv_buf_count; i++) {
152 if(rcv_bufs[i] ==
NULL || rcv_buf_sizes[i] == 0) {
153 kprintf(
"[TFTP GET] ERROR: Invalid argument\n");
164 kprintf(
"[TFTP Get] Server: %08X File: %s\n",
172 if (verbose & TFTP_VERBOSE) {
173 kprintf(
"[TFTP Get] Using local port %u\n",
181 kprintf(
"[TFTP Get] ERROR: udp_register failed\n");
193 curr_buf = (
char*)rcv_bufs[curr_buf_ind];
199 strncpy(outmsg.tf_filemode, filename, nlen+1);
201 strncpy(outmsg.tf_filemode+nlen+1,
"octet",
sizeof(
"octet")+1);
206 mlen = nlen +
strnlen(
"octet", 6) + 4;
213 n =
tftp_send1(sock, serverip, &remport, &outmsg, mlen,
218 kprintf(
"\n[TFTP Get] ERROR: TFTP Send fails\n");
226 if (i >= TFTP_MAXRETRIES) {
227 kprintf(
"\n[TFTP Get] ERROR: Max retries %d exceeded\n",
233 if(verbose & TFTP_VERBOSE) {
243 for (i=0; i<dlen; i++) {
244 if (curr_used >= rcv_buf_sizes[curr_buf_ind]) {
246 if(curr_buf_ind >= rcv_buf_count) {
248 if(verbose & TFTP_VERBOSE) {
253 curr_buf = (
char*)rcv_bufs[curr_buf_ind];
256 *curr_buf++ = inmsg.
tf_data[i];
264 outmsg.tf_ablk =
htons(expected);
265 mlen =
sizeof(outmsg.tf_opcode) +
sizeof(outmsg.tf_ablk);
271 (
char *) &outmsg, mlen);
274 if(verbose & TFTP_VERBOSE) {
279 kprintf(
"\n[TFTP GET] Error on final ack\n");
syscall kprintf(char *fmt,...)
ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。
#define NULL
連結リスト用のNULLポインタ
unsigned char byte
符号なし8ビット値(unsigned char)
char * strncpy(char *, const char *, int32)
文字列s1に文字列s2をN文字(Byte)分コピーする。
status tftpget_mb(uint32 serverip, const char *filename, char **rcv_bufs, uint32 *rcv_buf_sizes, uint32 rcv_buf_count, byte verbose)
int32 udp_recvaddr(uid32, uint32 *, uint16 *, char *, int32, uint32)
status tftp_send1(int32 sock, uint32 remip, uint16 *remport, struct tftp_msg *msg, int32 mlen, struct tftp_msg *inmsg, uint16 expected)
#define TIMEOUT
システムコールがタイムアウトした場合
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
status tftpget(uint32 serverip, const char *filename, char *rcv_buf, uint32 rcv_buf_size, byte verbose)
char tf_data[TFTP_MAXDATA]
int int32
符号あり32ビット整数(int)
uid32 udp_register(uint32, uint16, uint16)
unsigned short uint16
符号なし16ビット整数(unsigned short)
void * memset(void *, const int, int32)
指定のByteブロックに対して、同じ値をNバイト分書き込む。
status udp_release(uid32)
status udp_sendto(uid32, uint32, uint16, char *, int32)
unsigned int uint32
符号なし32ビット整数(unsigned int)
int32 strnlen(const char *, uint32)
NULL終端された文字列の長さを返す。NULL終端は長さに含まない。
#define NULLCH
NULL文字(NULL終端)