|
|
| version 1.2, 2014/02/17 14:28:29 | version 1.2.2.1, 2014/02/20 00:44:49 |
|---|---|
| Line 116 txAck(sched_task_t *task) | Line 116 txAck(sched_task_t *task) |
| taskExit(task, NULL); | taskExit(task, NULL); |
| } | } |
| static int | |
| getOpts(rpack_t * __restrict pkt) | |
| { | |
| return 0; | |
| } | |
| static void * | static void * |
| txOack(sched_task_t *task) | |
| { | |
| rpack_t *pkt = TASK_DATA(task); | |
| u_short n = htons(TFTP_OPC_OACK); | |
| struct stat sb; | |
| char szStr[STRSIZ]; | |
| ETRACE(); | |
| RPACK_REWIND(pkt); | |
| rpack_uint16(pkt, &n, 0); | |
| /* if opcode is RRQ and tsize is 0 then we must return file size to client */ | |
| if (cli.opc == TFTP_OPC_RRQ && !cli.tsiz && stat(cli.file, &sb) != -1) | |
| cli.tsiz = sb.st_size; | |
| if (cli.siz > TFTP_LOAD_MAX) { | |
| memset(szStr, 0, sizeof szStr); | |
| snprintf(szStr, sizeof szStr, "%u", cli.siz); | |
| rpack_rdata(pkt, TFTP_OPT_BLKSIZE, strlen(TFTP_OPT_BLKSIZE) + 1); | |
| rpack_rdata(pkt, szStr, strlen(szStr) + 1); | |
| } | |
| if (cli.tsiz) { | |
| memset(szStr, 0, sizeof szStr); | |
| snprintf(szStr, sizeof szStr, "%llu", cli.tsiz); | |
| rpack_rdata(pkt, TFTP_OPT_TSIZE, strlen(TFTP_OPT_TSIZE) + 1); | |
| rpack_rdata(pkt, szStr, strlen(szStr) + 1); | |
| } | |
| if (cli.tout) { | |
| memset(szStr, 0, sizeof szStr); | |
| snprintf(szStr, sizeof szStr, "%u", cli.tout); | |
| rpack_rdata(pkt, TFTP_OPT_TIMEOUT, strlen(TFTP_OPT_TIMEOUT) + 1); | |
| rpack_rdata(pkt, szStr, strlen(szStr) + 1); | |
| } | |
| schedEvent(TASK_ROOT(task), txPkt, NULL, TASK_FD(task), | |
| TASK_DATA(task), RPACK_OFF(pkt)); | |
| taskExit(task, NULL); | |
| } | |
| static void * | |
| RQ(sched_task_t *task) | RQ(sched_task_t *task) |
| { | { |
| rpack_t *pkt = TASK_DATA(task); | rpack_t *pkt = TASK_DATA(task); |
| Line 168 RQ(sched_task_t *task) | Line 215 RQ(sched_task_t *task) |
| EVERBOSE(2, "WRQ:: file=%s mode=%s\n", cli.file, cli.mode); | EVERBOSE(2, "WRQ:: file=%s mode=%s\n", cli.file, cli.mode); |
| break; | break; |
| } | } |
| if (!RPACK_ISEND(pkt) && !getOpts(pkt)) | |
| schedEvent(TASK_ROOT(task), txOack, NULL, TASK_FD(task), | |
| TASK_DATA(task), 0); | |
| cli.fd = open(cli.file, code, 0644); | cli.fd = open(cli.file, code, 0644); |
| if (cli.fd == -1) { | if (cli.fd == -1) { |
| if (errno == EACCES) | if (errno == EACCES) |