[patch] ctrl^c support
"ctrl^c" support for ping & tftp
signed-off-by: Rouchel Yan <rouchel.yan@gmail.com>
-------------------------------------------------------------------------------------------------------
commit 83209f31ee6676e85ddfa317e13c7386458d21c4
Author: rouchel.yan <rouchel.yan@gmail.com>
Date: Tue Aug 25 14:41:02 2009 -0400
ctrl+c
diff --git a/app/net/ping.c b/app/net/ping.c
index ac7fab3..dd57af8 100644
--- a/app/net/ping.c
+++ b/app/net/ping.c
@@ -36,6 +36,8 @@ static int PingMain(int argc, char *argv[])
sockAddr = getaddr(nip);
+ if(EINVAL == sockAddr)
+ return 0;
if (NULL == sockAddr)
{
sockAddr = gethostaddr(szDestIp);
diff --git a/device/net/cs8900.c b/device/net/cs8900.c
index 73fd803..7471264 100644
--- a/device/net/cs8900.c
+++ b/device/net/cs8900.c
@@ -184,7 +184,7 @@ static int __INIT__ CS8900Init(void)
CS8900Reset();
- pNetDev = GkNetDevNew();
+ pNetDev = GkNetDevNew(0);
ret = GkRegisterIsr(IRQ_EINT9, CS8900Isr, NULL);
diff --git a/device/net/dm9000.c b/device/net/dm9000.c
index 73a6ec4..a8efd11 100644
--- a/device/net/dm9000.c
+++ b/device/net/dm9000.c
@@ -333,7 +333,7 @@ static int __INIT__ DM9000Init(void)
}
}
- pNetDev = GkNetDevNew();
+ pNetDev = GkNetDevNew(0);
BUG_IF (NULL == pNetDev);
GkRegisterIsr(CONF_DM9000_IRQ, DM9000Isr, NULL);
diff --git a/device/net/net_core.c b/device/net/net_core.c
index d332511..7ce9b67 100644
--- a/device/net/net_core.c
+++ b/device/net/net_core.c
@@ -123,6 +123,14 @@ struct SocketBuffer *GUdpRecvPacket(struct Socket *pSock)
break;
}
UnlockIrqPsr(psr);
+ if(GkUartGetStatus())
+ {
+ UINT32 uartdata;
+
+ uartdata = GkUartReadByte();
+ if(3 == uartdata)
+ return NULL;
+ }
udelay(5);
}
diff --git a/device/net/socket.c b/device/net/socket.c
index 1bcaeed..e495190 100644
--- a/device/net/socket.c
+++ b/device/net/socket.c
@@ -62,6 +62,8 @@ int close(int fd)
struct sockaddr *gethostaddr(const char *sip)
{
UINT32 nip;
+ UINT32 count = 0;
+
struct sockaddr *sockAddr;
if(GuStrToIp((BYTE *)&nip, sip))
@@ -72,16 +74,24 @@ struct sockaddr *gethostaddr(const char *sip)
ArpSendPacket((BYTE *)&nip, NULL, ARP_OP_REQ);
- while (1)
+ while (count < 100000)
{
UINT32 psr;
+ BYTE uartdata;
sockAddr = getaddr(nip);
+ if(GkUartGetStatus())
+ {
+ uartdata = GkUartReadByte();
+ if(3 == uartdata)
+ return EINVAL;
+ }
if (sockAddr)
break;
// TODO: add re-send code here
udelay(3);
+ count++;
}
return sockAddr;
@@ -145,6 +155,9 @@ long recv(int fd, void *buf, ULONG n)
pSockBuff = GUdpRecvPacket(pSock);
+ if(NULL == pSockBuff)
+ return 0;
+
// fixme !
nPktLen = pSockBuff->wSkbSize <= n ? pSockBuff->wSkbSize : n;
diff --git a/device/net/tftp.c b/device/net/tftp.c
index 1f30c67..2c01cd4 100644
--- a/device/net/tftp.c
+++ b/device/net/tftp.c
@@ -123,6 +123,8 @@ int GuNetTftpGetFile(struct TftpOpt *opt)
{
nPktLen = recv(sockfd, pTftpPkt, TFTP_BUF_LEN);
+ if(0 == nPktLen)
+ goto L1;
nPktLen -= TFTP_HDR_LEN;
if (nPktLen > TFTP_PKT_LEN)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论