Skip to content

Commit

Permalink
Fix some typos, typecasts, int widths, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
denisvm committed Mar 31, 2022
1 parent 069a813 commit 010d3f0
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 102 deletions.
4 changes: 2 additions & 2 deletions Ethernet/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t
//}
//
//if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
if((taddr == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_IPINVALID;
if((port == 0) && (getSn_MR(sn)&Sn_MR_MACRAW != Sn_MR_MACRAW)) return SOCKERR_PORTZERO;
if((taddr == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_IPINVALID;
if((port == 0) && ((getSn_MR(sn)&Sn_MR_MACRAW) != Sn_MR_MACRAW)) return SOCKERR_PORTZERO;
tmp = getSn_SR(sn);
#if ( _WIZCHIP_ < 5200 )
if(tmp != SOCK_MACRAW && tmp != SOCK_UDP && tmp != SOCK_IPRAW) return SOCKERR_SOCKSTATUS;
Expand Down
18 changes: 12 additions & 6 deletions Ethernet/wizchip_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,21 @@ _WIZCHIP WIZCHIP =
{
_WIZCHIP_IO_MODE_,
_WIZCHIP_ID_ ,
wizchip_cris_enter,
wizchip_cris_exit,
wizchip_cs_select,
wizchip_cs_deselect,
.CRIS = {
wizchip_cris_enter,
wizchip_cris_exit,
},
.CS = {
wizchip_cs_select,
wizchip_cs_deselect,
},
//M20150601 : Rename the function
//wizchip_bus_readbyte,
//wizchip_bus_writebyte
wizchip_bus_readdata,
wizchip_bus_writedata,
.IF.BUS = {
wizchip_bus_readdata,
wizchip_bus_writedata,
},
// wizchip_spi_readbyte,
// wizchip_spi_writebyte
};
Expand Down
18 changes: 9 additions & 9 deletions Internet/DHCP/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,15 @@ int8_t parseDHCPMSG(void)
uint8_t type;
uint8_t opt_len;

if((len = getSn_RX_RSR(DHCP_SOCKET)) > 0)
{
len = recvfrom(DHCP_SOCKET, (uint8_t *)pDHCPMSG, len, svr_addr, &svr_port);
#ifdef _DHCP_DEBUG_
printf("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len);
#endif
}
else return 0;
if (svr_port == DHCP_SERVER_PORT) {
if((len = getSn_RX_RSR(DHCP_SOCKET)) == 0)
return 0;

len = recvfrom(DHCP_SOCKET, (uint8_t *)pDHCPMSG, len, svr_addr, &svr_port);
#ifdef _DHCP_DEBUG_
printf("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len);
#endif

if (svr_port == DHCP_SERVER_PORT) {
// compare mac address
if ( (pDHCPMSG->chaddr[0] != DHCP_CHADDR[0]) || (pDHCPMSG->chaddr[1] != DHCP_CHADDR[1]) ||
(pDHCPMSG->chaddr[2] != DHCP_CHADDR[2]) || (pDHCPMSG->chaddr[3] != DHCP_CHADDR[3]) ||
Expand Down
2 changes: 1 addition & 1 deletion Internet/DNS/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns)
uint8_t * cp;

msg = pbuf;
memset(pdhdr, 0, sizeof(pdhdr));
memset(pdhdr, 0, sizeof(*pdhdr));

pdhdr->id = get16(&msg[0]);
tmp = get16(&msg[2]);
Expand Down
58 changes: 29 additions & 29 deletions Internet/FTPClient/ftpc.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "ftpc.h"

un_l2cval remote_ip;
uint16_t remote_port;
un_l2cval local_ip;
uint16_t local_port;
un_l2cval FTP_remote_ip;
uint16_t FTP_remote_port;
un_l2cval FTP_local_ip;
uint16_t FTP_local_port;
uint8_t connect_state_control_ftpc = 0;
uint8_t connect_state_data_ftpc = 0;
uint8_t gModeActivePassiveflag = 0;
Expand All @@ -21,11 +21,11 @@ void ftpc_init(uint8_t * src_ip)
{
ftpc.dsock_mode = ACTIVE_MODE;

local_ip.cVal[0] = src_ip[0];
local_ip.cVal[1] = src_ip[1];
local_ip.cVal[2] = src_ip[2];
local_ip.cVal[3] = src_ip[3];
local_port = 35000;
FTP_local_ip.cVal[0] = src_ip[0];
FTP_local_ip.cVal[1] = src_ip[1];
FTP_local_ip.cVal[2] = src_ip[2];
FTP_local_ip.cVal[3] = src_ip[3];
FTP_local_port = 35000;
strcpy(ftpc.workingdir, "/");
socket(CTRL_SOCK, Sn_MR_TCP, FTP_destport, 0x0);
}
Expand Down Expand Up @@ -77,7 +77,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
else{
wiz_NetInfo gWIZNETINFO;
ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO);
sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff));
sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(FTP_local_port>>8), (uint8_t)(FTP_local_port&0x00ff));
send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
Command.First = f_dir;

Expand All @@ -96,7 +96,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
else{
wiz_NetInfo gWIZNETINFO;
ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO);
sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff));
sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(FTP_local_port>>8), (uint8_t)(FTP_local_port&0x00ff));
send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
Command.First = f_put;

Expand All @@ -114,7 +114,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
else{
wiz_NetInfo gWIZNETINFO;
ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO);
sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(local_port>>8), (uint8_t)(local_port&0x00ff));
sprintf(dat,"PORT %d,%d,%d,%d,%d,%d\r\n", gWIZNETINFO.ip[0], gWIZNETINFO.ip[1], gWIZNETINFO.ip[2], gWIZNETINFO.ip[3], (uint8_t)(FTP_local_port>>8), (uint8_t)(FTP_local_port&0x00ff));
send(CTRL_SOCK, (uint8_t *)dat, strlen(dat));
Command.First = f_get;

Expand Down Expand Up @@ -416,25 +416,25 @@ uint8_t ftpc_run(uint8_t * dbuf)
case SOCK_CLOSED :
if(ftpc.dsock_state == DATASOCK_READY){
if(ftpc.dsock_mode == PASSIVE_MODE){
printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, local_port);
if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK){
printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, FTP_local_port);
if((ret=socket(DATA_SOCK, Sn_MR_TCP, FTP_local_port, 0x0)) != DATA_SOCK){
printf("%d:socket() error:%ld\r\n", DATA_SOCK, ret);
close(DATA_SOCK);
return ret;
}
local_port++;
if(local_port > 50000)
local_port = 35000;
FTP_local_port++;
if(FTP_local_port > 50000)
FTP_local_port = 35000;
}else{
printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, local_port);
if((ret=socket(DATA_SOCK, Sn_MR_TCP, local_port, 0x0)) != DATA_SOCK){
printf("%d:FTPDataStart, port : %d\r\n",DATA_SOCK, FTP_local_port);
if((ret=socket(DATA_SOCK, Sn_MR_TCP, FTP_local_port, 0x0)) != DATA_SOCK){
printf("%d:socket() error:%ld\r\n", DATA_SOCK, ret);
close(DATA_SOCK);
return ret;
}
local_port++;
if(local_port > 50000)
local_port = 35000;
FTP_local_port++;
if(FTP_local_port > 50000)
FTP_local_port = 35000;
}
ftpc.dsock_state = DATASOCK_START;
}
Expand All @@ -450,7 +450,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
gDataSockReady = 1;
printf("%d:Listen ok\r\n",DATA_SOCK);
}else{
if((ret = connect(DATA_SOCK, remote_ip.cVal, remote_port)) != SOCK_OK){
if((ret = connect(DATA_SOCK, FTP_remote_ip.cVal, FTP_remote_port)) != SOCK_OK){
printf("%d:Connect error\r\n", DATA_SOCK);
return ret;
}
Expand All @@ -468,7 +468,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
char proc_ftpc(char * buf)
{
uint16_t Responses;
uint8_t dat[30]={0,};
char dat[30]={0,};

Responses =(buf[0]-'0')*100+(buf[1]-'0')*10+(buf[2]-'0');

Expand Down Expand Up @@ -553,23 +553,23 @@ int pportc(char * arg)
{
if(i==0) tok = strtok(NULL,",\r\n");
else tok = strtok(NULL,",");
remote_ip.cVal[i] = (uint8_t)atoi(tok, 10);
FTP_remote_ip.cVal[i] = (uint8_t)atoi(tok, 10);
if (!tok){
printf("bad pport : %s\r\n", arg);
return -1;
}
}
remote_port = 0;
FTP_remote_port = 0;
for (i = 0; i < 2; i++){
tok = strtok(NULL,",\r\n");
remote_port <<= 8;
remote_port += atoi(tok, 10);
FTP_remote_port <<= 8;
FTP_remote_port += atoi(tok, 10);
if (!tok){
printf("bad pport : %s\r\n", arg);
return -1;
}
}
printf("ip : %d.%d.%d.%d, port : %d\r\n", remote_ip.cVal[0], remote_ip.cVal[1], remote_ip.cVal[2], remote_ip.cVal[3], remote_port);
printf("ip : %d.%d.%d.%d, port : %d\r\n", FTP_remote_ip.cVal[0], FTP_remote_ip.cVal[1], FTP_remote_ip.cVal[2], FTP_remote_ip.cVal[3], FTP_remote_port);
return 0;
}
uint8_t* User_Keyboard_MSG()
Expand Down
Loading

0 comments on commit 010d3f0

Please sign in to comment.