Compare commits
1 Commits
FIxedwiz_c
...
modifyFTPS
Author | SHA1 | Date | |
---|---|---|---|
7286d4aa36 |
@ -1,113 +0,0 @@
|
|||||||
#include "multicast.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "socket.h"
|
|
||||||
#include "wizchip_conf.h"
|
|
||||||
|
|
||||||
|
|
||||||
int32_t multicast_loopback(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
uint16_t size, sentsize;
|
|
||||||
uint8_t destip[4];
|
|
||||||
uint16_t destport, port=3000;
|
|
||||||
|
|
||||||
switch(getSn_SR(sn))
|
|
||||||
{
|
|
||||||
case SOCK_UDP :
|
|
||||||
if((size = getSn_RX_RSR(sn)) > 0)
|
|
||||||
{
|
|
||||||
if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
|
|
||||||
ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport);
|
|
||||||
if(ret <= 0)
|
|
||||||
{
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d: recvfrom error. %ld\r\n",sn,ret);
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
size = (uint16_t) ret;
|
|
||||||
sentsize = 0;
|
|
||||||
while(sentsize != size)
|
|
||||||
{
|
|
||||||
ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport);
|
|
||||||
if(ret < 0)
|
|
||||||
{
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d: sendto error. %ld\r\n",sn,ret);
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case SOCK_CLOSED:
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d:Multicast Loopback start\r\n",sn);
|
|
||||||
#endif
|
|
||||||
setSn_DIPR(0, multicast_ip);
|
|
||||||
setSn_DPORT(0, multicast_port);
|
|
||||||
if((ret = socket(sn, Sn_MR_UDP, port, Sn_MR_MULTI)) != sn)
|
|
||||||
return ret;
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d:Opened, UDP Multicast Socket\r\n", sn);
|
|
||||||
printf("%d:Multicast Group IP - %d.%d.%d.%d\r\n", sn, multicast_ip[0], multicast_ip[1], multicast_ip[2], multicast_ip[3]);
|
|
||||||
printf("%d:Multicast Group Port - %d\r\n", sn, multicast_port);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t multicast_recv(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
uint16_t size, port=3000;
|
|
||||||
uint8_t destip[4];
|
|
||||||
uint16_t destport;
|
|
||||||
|
|
||||||
switch(getSn_SR(sn))
|
|
||||||
{
|
|
||||||
case SOCK_UDP :
|
|
||||||
if((size = getSn_RX_RSR(sn)) > 0)
|
|
||||||
{
|
|
||||||
if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
|
|
||||||
ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport);
|
|
||||||
if(ret <= 0)
|
|
||||||
{
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d: recvfrom error. %ld\r\n",sn,ret);
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
size = (uint16_t) ret;
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("\r\nrecv size : %d\r\n", size);
|
|
||||||
for(int i=0; i<size; i++)
|
|
||||||
printf("%c", buf[i]);
|
|
||||||
printf("\r\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SOCK_CLOSED:
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d:Multicast Recv start\r\n",sn);
|
|
||||||
#endif
|
|
||||||
setSn_DIPR(sn, multicast_ip);
|
|
||||||
setSn_DPORT(sn, multicast_port);
|
|
||||||
if((ret = socket(sn, Sn_MR_UDP, port, Sn_MR_MULTI)) != sn)
|
|
||||||
return ret;
|
|
||||||
#ifdef _MULTICAST_DEBUG_
|
|
||||||
printf("%d:Opened, UDP Multicast Socket\r\n", sn);
|
|
||||||
printf("%d:Multicast Group IP - %d.%d.%d.%d\r\n", sn, multicast_ip[0], multicast_ip[1], multicast_ip[2], multicast_ip[3]);
|
|
||||||
printf("%d:Multicast Group Port - %d\r\n", sn, multicast_port);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
#ifndef _MULTICAST_H_
|
|
||||||
#define _MULTICAST_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/* Multicast test debug message printout enable */
|
|
||||||
#define _MULTICAST_DEBUG_
|
|
||||||
|
|
||||||
#ifndef DATA_BUF_SIZE
|
|
||||||
#define DATA_BUF_SIZE 2048
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* UDP Multicast Loopback test example */
|
|
||||||
int32_t multicast_loopback(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port);
|
|
||||||
|
|
||||||
/* UDP Multicast Recv test example */
|
|
||||||
int32_t multicast_recv(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -117,7 +117,6 @@ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
|
|||||||
uint32_t taddr;
|
uint32_t taddr;
|
||||||
getSIPR((uint8_t*)&taddr);
|
getSIPR((uint8_t*)&taddr);
|
||||||
if(taddr == 0) return SOCKERR_SOCKINIT;
|
if(taddr == 0) return SOCKERR_SOCKINIT;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case Sn_MR_UDP :
|
case Sn_MR_UDP :
|
||||||
case Sn_MR_MACRAW :
|
case Sn_MR_MACRAW :
|
||||||
|
@ -521,12 +521,7 @@ void wizchip_clrinterrupt(intr_kind intr)
|
|||||||
setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) );
|
setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) );
|
||||||
#else
|
#else
|
||||||
setIR(ir);
|
setIR(ir);
|
||||||
//M20200227 : For clear
|
setSIR(sir);
|
||||||
//setSIR(sir);
|
|
||||||
for(ir=0; ir<8; ir++){
|
|
||||||
if(sir & (0x01 <<ir) ) setSn_IR(ir, 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,21 +21,19 @@ extern "C" {
|
|||||||
//#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement.
|
//#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement.
|
||||||
|
|
||||||
#if defined(F_FILESYSTEM)
|
#if defined(F_FILESYSTEM)
|
||||||
#include "ff.h"
|
//#include "ff.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define F_APP_FTP
|
#define F_APP_FTP
|
||||||
#define _FTP_DEBUG_
|
#define _FTP_DEBUG_
|
||||||
|
|
||||||
|
|
||||||
#define LINELEN 100
|
#define _FTP_FILENAME_LEN_ 100
|
||||||
//#define DATA_BUF_SIZE 100
|
//#define DATA_BUF_SIZE 100
|
||||||
#if !defined(F_FILESYSTEM)
|
#if !defined(F_FILESYSTEM)
|
||||||
#define _MAX_SS 512
|
#define _MAX_SS 512
|
||||||
#endif
|
#endif
|
||||||
|
#define SOCK_MAX_NUM 4
|
||||||
#define CTRL_SOCK 2
|
|
||||||
#define DATA_SOCK 3
|
|
||||||
|
|
||||||
#define IPPORT_FTPD 20 /* FTP Data port */
|
#define IPPORT_FTPD 20 /* FTP Data port */
|
||||||
#define IPPORT_FTP 21 /* FTP Control port */
|
#define IPPORT_FTP 21 /* FTP Control port */
|
||||||
@ -79,43 +77,18 @@ enum ftp_cmd {
|
|||||||
NO_CMD,
|
NO_CMD,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ftp_type {
|
|
||||||
ASCII_TYPE,
|
|
||||||
IMAGE_TYPE,
|
|
||||||
LOGICAL_TYPE
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ftp_state {
|
|
||||||
FTPS_NOT_LOGIN,
|
|
||||||
FTPS_LOGIN
|
|
||||||
};
|
|
||||||
|
|
||||||
enum datasock_state{
|
|
||||||
DATASOCK_IDLE,
|
|
||||||
DATASOCK_READY,
|
|
||||||
DATASOCK_START
|
|
||||||
};
|
|
||||||
|
|
||||||
enum datasock_mode{
|
|
||||||
PASSIVE_MODE,
|
|
||||||
ACTIVE_MODE
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ftpd {
|
struct ftpd {
|
||||||
uint8_t control; /* Control stream */
|
uint8_t ctrl_sock; /* Control Socket */
|
||||||
uint8_t data; /* Data stream */
|
uint8_t data_sock; /* Data Socket */
|
||||||
|
char user[20]; /* FTP Server user */
|
||||||
enum ftp_type type; /* Transfer type */
|
char pass[20]; /* FTP Server password */
|
||||||
enum ftp_state state;
|
char username[_FTP_FILENAME_LEN_]; /* Arg to USER command */
|
||||||
|
char workingdir[_FTP_FILENAME_LEN_];
|
||||||
enum ftp_cmd current_cmd;
|
char filename[_FTP_FILENAME_LEN_];
|
||||||
|
uint8_t is_login; /* Login 1: login, 0: Not login */
|
||||||
enum datasock_state dsock_state;
|
uint8_t is_ascii; /* Transfer Type 1 : ASCII, 0 : Binary */
|
||||||
enum datasock_mode dsock_mode;
|
uint8_t is_active; /* FTP Mode 1 : Active, 0: Passive */
|
||||||
|
|
||||||
char username[LINELEN]; /* Arg to USER command */
|
|
||||||
char workingdir[LINELEN];
|
|
||||||
char filename[LINELEN];
|
|
||||||
|
|
||||||
#if defined(F_FILESYSTEM)
|
#if defined(F_FILESYSTEM)
|
||||||
FIL fil; // FatFs File objects
|
FIL fil; // FatFs File objects
|
||||||
@ -124,18 +97,8 @@ struct ftpd {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef un_I2cval
|
void ftpd_init(char* user, char*pass);
|
||||||
typedef union _un_l2cval {
|
|
||||||
uint32_t lVal;
|
|
||||||
uint8_t cVal[4];
|
|
||||||
}un_l2cval;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ftpd_init(uint8_t * src_ip);
|
|
||||||
uint8_t ftpd_run(uint8_t * dbuf);
|
uint8_t ftpd_run(uint8_t * dbuf);
|
||||||
char proc_ftpd(char * buf);
|
|
||||||
char ftplogin(char * pass);
|
|
||||||
int pport(char * arg);
|
|
||||||
|
|
||||||
int sendit(char * command);
|
int sendit(char * command);
|
||||||
int recvit(char * command);
|
int recvit(char * command);
|
||||||
|
@ -169,7 +169,7 @@ void httpServer_run(uint8_t seqnum)
|
|||||||
|
|
||||||
gettime = get_httpServer_timecount();
|
gettime = get_httpServer_timecount();
|
||||||
// Check the TX socket buffer for End of HTTP response sends
|
// Check the TX socket buffer for End of HTTP response sends
|
||||||
while(getSn_TX_FSR(s) != (getSn_TxMAX(s)))
|
while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024))
|
||||||
{
|
{
|
||||||
if((get_httpServer_timecount() - gettime) > 3)
|
if((get_httpServer_timecount() - gettime) > 3)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user