diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-19 11:12:46 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-19 11:12:46 +0000 |
commit | 6d9ea24611090f06b74e0e5b038b6c5b4bbe1063 (patch) | |
tree | 7fbefb532c3412b0264a9faf7d0ad3f42254b86e /networking/traceroute.c | |
parent | 1b16bdaebf7d0e543e048dfec9f34f06e983336c (diff) | |
download | busybox-w32-6d9ea24611090f06b74e0e5b038b6c5b4bbe1063.tar.gz busybox-w32-6d9ea24611090f06b74e0e5b038b6c5b4bbe1063.tar.bz2 busybox-w32-6d9ea24611090f06b74e0e5b038b6c5b4bbe1063.zip |
networking/interface.c: huke remaining big statics; use malloc for INET[6]_rresolve
return value. Went thru callers and adjusted them - code got smaller too.
function old new delta
ip_port_str - 126 +126
INET6_rresolve 165 182 +17
static.cache 20 24 +4
route_main 2092 2091 -1
INET_sprint 61 59 -2
INET_nn 4 - -4
INET6_sprint 59 53 -6
udp_do_one 518 508 -10
tcp_do_one 433 423 -10
raw_do_one 494 484 -10
traceroute_main 4117 4105 -12
INET_rresolve 334 321 -13
bb_displayroutes 494 456 -38
snprint_ip_port 244 - -244
static.buff 264 16 -248
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/10 up/down: 147/-598) Total: -451 bytes
size busybox_old busybox_unstripped
text data bss dec hex filename
751073 3048 14688 768809 bbb29 busybox_old
750873 3048 14440 768361 bb969 busybox_unstripped
Diffstat (limited to 'networking/traceroute.c')
-rw-r--r-- | networking/traceroute.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index 9fc15d390..577738a97 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -802,22 +802,20 @@ packet_ok(unsigned char *buf, int cc, struct sockaddr_in *from, int seq) | |||
802 | * numeric value, otherwise try for symbolic name. | 802 | * numeric value, otherwise try for symbolic name. |
803 | */ | 803 | */ |
804 | static inline void | 804 | static inline void |
805 | inetname(struct sockaddr_in *from) | 805 | print_inetname(struct sockaddr_in *from) |
806 | { | 806 | { |
807 | const char *n = NULL; | ||
808 | const char *ina; | 807 | const char *ina; |
809 | char name[257]; | ||
810 | 808 | ||
811 | if (!nflag && from->sin_addr.s_addr != INADDR_ANY) { | ||
812 | if (INET_rresolve(name, sizeof(name), from, 0x4000, | ||
813 | 0xffffffff) >= 0) | ||
814 | n = name; | ||
815 | } | ||
816 | ina = inet_ntoa(from->sin_addr); | 809 | ina = inet_ntoa(from->sin_addr); |
817 | if (nflag) | 810 | if (nflag) |
818 | printf(" %s", ina); | 811 | printf(" %s", ina); |
819 | else | 812 | else { |
813 | char *n = NULL; | ||
814 | if (from->sin_addr.s_addr != INADDR_ANY) | ||
815 | n = xmalloc_sockaddr2host_noport((struct sockaddr*)from, sizeof(*from)); | ||
820 | printf(" %s (%s)", (n ? n : ina), ina); | 816 | printf(" %s (%s)", (n ? n : ina), ina); |
817 | free(n); | ||
818 | } | ||
821 | } | 819 | } |
822 | 820 | ||
823 | static inline void | 821 | static inline void |
@@ -830,7 +828,7 @@ print(unsigned char *buf, int cc, struct sockaddr_in *from) | |||
830 | hlen = ip->ip_hl << 2; | 828 | hlen = ip->ip_hl << 2; |
831 | cc -= hlen; | 829 | cc -= hlen; |
832 | 830 | ||
833 | inetname(from); | 831 | print_inetname(from); |
834 | #if ENABLE_FEATURE_TRACEROUTE_VERBOSE | 832 | #if ENABLE_FEATURE_TRACEROUTE_VERBOSE |
835 | if (verbose) | 833 | if (verbose) |
836 | printf(" %d bytes to %s", cc, inet_ntoa(ip->ip_dst)); | 834 | printf(" %d bytes to %s", cc, inet_ntoa(ip->ip_dst)); |