Below you will find pages that utilize the taxonomy term “TFTP”
简单TFTP协议实现
简单实现了传输的功能,基本没有错误和异常处理……
服务器端
<br></br>#include <stdio.h><br></br>#include <stdlib.h><br></br>#include <string.h><br></br>#include <strings.h><br></br>#include <sys><br></br>#include <sys><br></br>#include <netdb.h><br></br>#include <fcntl.h></fcntl.h></netdb.h></sys></sys></strings.h></string.h></stdlib.h></stdio.h>
#define DEBUG 1
#define OPCODE_RRQ (1)
#define OPCODE_WRQ (2)
#define OPCODE_DATA (3)
#define OPCODE_ACK (4)
#define OPCODE_ERR (5)
#define BLOCKSIZE (512)
struct TFTPHeader{
short opcode;
}__attribute__((packed));
struct TFTPWRRQ{
struct TFTPHeader header;
char *filename; // Terminal as \0x00
char *mode; // Terminal as \0x00
}__attribute__((packed));
struct TFTPData{
struct TFTPHeader header;
short block;
void* data;
}__attribute__((packed));
struct TFTPACK{
struct TFTPHeader header;
short block;
}__attribute__((packed));