示例#1
0
void TftpdStart(void)
{
	 ptr=0x80201000;  //only for RT6855/RT6856/RT63365   
#if defined(CONFIG_NET_MULTI)
	printf("Using %s device\n", eth_get_name());
#endif
	//puts(" \nTFTP from server ");	print_IPaddr(NetServerIP);
	puts("\nOur IP address is:(");	
	print_IPaddr(NetOurIP);
	puts(")\nWait for TFTP request...\n");
	/* Check if we need to send across this subnet */
	if (NetOurGatewayIP && NetOurSubnetMask) 
	{
		IPaddr_t OurNet 	= NetOurIP    & NetOurSubnetMask;
		IPaddr_t ServerNet 	= NetServerIP & NetOurSubnetMask;
		
		if (OurNet != ServerNet)
		{
			puts("; sending through gateway ");
			print_IPaddr(NetOurGatewayIP) ;
		}
	}

	memset(ptr,0,sizeof(ptr));
	_tftpd_open();
}
示例#2
0
static int tftp_fileop_open(void **ref,void *fsctx,char *filename,int mode)
{
    tftp_info_t *info;
    char *host;
    char *file;
    int res;

    if ((mode != FILE_MODE_READ) && (mode != FILE_MODE_WRITE)) {
	/* must be either read or write, not both */
	return CFE_ERR_UNSUPPORTED;
	}

    /* Allocate the tftp info structure */

    info = KMALLOC(sizeof(tftp_info_t),0);
    if (!info) {
	return CFE_ERR_NOMEM;
	}


    info->tftp_filename = lib_strdup(filename);
    if (!info->tftp_filename) {
	KFREE(info);
	return CFE_ERR_NOMEM;
	}

    lib_chop_filename(info->tftp_filename,&host,&file);

    /* Open the file */

    if (!*host && !*file) {
	/* TFTP server if hostname and filename are not specified */
#ifdef RESCUE_MODE
        xprintf("TFTP Server.\n");
#endif
	res = _tftpd_open(info,host,file,mode);
    } else {
	/* TFTP client otherwise */
#ifdef RESCUE_MODE
        xprintf("TFTP Client.\n");
#endif
	res = _tftp_open(info,host,file,mode);
    }

    if (res == 0) {
	info->tftp_blkoffset = 0;
	info->tftp_fileoffset = 0;
	*ref = info;
	}
    else {
	KFREE(info->tftp_filename);
	KFREE(info);
	*ref = NULL;
	}
    return res;
}