aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-10-26 14:18:38 +0000
committerWolfgang Denk <wd@denx.de>2011-10-27 23:53:57 +0200
commit39bccd21d0c838242fb86bceda759e5640d4d683 (patch)
treed3ca88c491ec71a1b3df6fc7f383d4f2321b4a1a /net
parent206d68fdd41e4942825cfc4a91a096297b654a24 (diff)
downloadu-boot-39bccd21d0c838242fb86bceda759e5640d4d683.zip
u-boot-39bccd21d0c838242fb86bceda759e5640d4d683.tar.gz
u-boot-39bccd21d0c838242fb86bceda759e5640d4d683.tar.bz2
net: Hide more code behind CONFIG_CMD_TFTPPUT
This commit reduces code size a little by making the ICMP handler only available to tftpput. This is reasonable since it is the only user at present (ping just uses the normal handler). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'net')
-rw-r--r--net/net.c8
-rw-r--r--net/tftp.c6
2 files changed, 12 insertions, 2 deletions
diff --git a/net/net.c b/net/net.c
index 84f28bf..11f41ed 100644
--- a/net/net.c
+++ b/net/net.c
@@ -215,7 +215,9 @@ volatile uchar *NetRxPackets[PKTBUFSRX];
/* Current RX packet handler */
static rxhand_f *packetHandler;
+#ifdef CONFIG_CMD_TFTPPUT
static rxhand_icmp_f *packet_icmp_handler; /* Current ICMP rx handler */
+#endif
/* Current timeout handler */
static thand_f *timeHandler;
/* Time base value */
@@ -576,9 +578,11 @@ restart:
}
done:
+#ifdef CONFIG_CMD_TFTPPUT
/* Clear out the handlers */
NetSetHandler(NULL);
net_set_icmp_handler(NULL);
+#endif
return ret;
}
@@ -653,10 +657,12 @@ NetSetHandler(rxhand_f *f)
packetHandler = f;
}
+#ifdef CONFIG_CMD_TFTPPUT
void net_set_icmp_handler(rxhand_icmp_f *f)
{
packet_icmp_handler = f;
}
+#endif
void
NetSetTimeout(ulong iv, thand_f *f)
@@ -1397,10 +1403,12 @@ static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et)
break;
#endif
default:
+#ifdef CONFIG_CMD_TFTPPUT
if (packet_icmp_handler)
packet_icmp_handler(icmph->type, icmph->code,
ntohs(ip->udp_dst), src_ip, ntohs(ip->udp_src),
icmph->un.data, ntohs(ip->udp_len));
+#endif
break;
}
}
diff --git a/net/tftp.c b/net/tftp.c
index 961fdd1..e34f202 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -421,7 +421,7 @@ TftpSend(void)
TftpOurPort, len);
}
-
+#ifdef CONFIG_CMD_TFTPPUT
static void icmp_handler(unsigned type, unsigned code, unsigned dest,
IPaddr_t sip, unsigned src, uchar *pkt, unsigned len)
{
@@ -430,6 +430,7 @@ static void icmp_handler(unsigned type, unsigned code, unsigned dest,
restart("TFTP server died");
}
}
+#endif
static void
TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
@@ -771,8 +772,9 @@ void TftpStart(enum proto_t protocol)
NetSetTimeout(TftpTimeoutMSecs, TftpTimeout);
NetSetHandler(TftpHandler);
+#ifdef CONFIG_CMD_TFTPPUT
net_set_icmp_handler(icmp_handler);
-
+#endif
TftpRemotePort = WELL_KNOWN_PORT;
TftpTimeoutCount = 0;
/* Use a pseudo-random port unless a specific port is set */