1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00

Enclose IPv6 addresses in brackets when they are displayed printable with a

TCP/UDP port seperated by a colon.  This is for the log_in_vain facility.

Pointed out by:	Edward J. M. Brocklesby
Reviewed by:	ume
MFC after:	2 weeks
This commit is contained in:
Juli Mallett 2002-08-19 19:47:13 +00:00
parent 51e2390d61
commit ded7008a07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102131
3 changed files with 15 additions and 7 deletions

View File

@ -576,14 +576,18 @@ tcp_input(m, off0)
if (inp == NULL) {
if (log_in_vain) {
#ifdef INET6
char dbuf[INET6_ADDRSTRLEN], sbuf[INET6_ADDRSTRLEN];
char dbuf[INET6_ADDRSTRLEN+2], sbuf[INET6_ADDRSTRLEN+2];
#else
char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"];
#endif
if (isipv6) {
strcpy(dbuf, ip6_sprintf(&ip6->ip6_dst));
strcpy(sbuf, ip6_sprintf(&ip6->ip6_src));
strcpy(dbuf, "[");
strcpy(sbuf, "[");
strcat(dbuf, ip6_sprintf(&ip6->ip6_dst));
strcat(sbuf, ip6_sprintf(&ip6->ip6_src));
strcat(dbuf, "]");
strcat(sbuf, "]");
} else {
strcpy(dbuf, inet_ntoa(ip->ip_dst));
strcpy(sbuf, inet_ntoa(ip->ip_src));

View File

@ -576,14 +576,18 @@ tcp_input(m, off0)
if (inp == NULL) {
if (log_in_vain) {
#ifdef INET6
char dbuf[INET6_ADDRSTRLEN], sbuf[INET6_ADDRSTRLEN];
char dbuf[INET6_ADDRSTRLEN+2], sbuf[INET6_ADDRSTRLEN+2];
#else
char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"];
#endif
if (isipv6) {
strcpy(dbuf, ip6_sprintf(&ip6->ip6_dst));
strcpy(sbuf, ip6_sprintf(&ip6->ip6_src));
strcpy(dbuf, "[");
strcpy(sbuf, "[");
strcat(dbuf, ip6_sprintf(&ip6->ip6_dst));
strcat(sbuf, ip6_sprintf(&ip6->ip6_src));
strcat(dbuf, "]");
strcat(sbuf, "]");
} else {
strcpy(dbuf, inet_ntoa(ip->ip_dst));
strcpy(sbuf, inet_ntoa(ip->ip_src));

View File

@ -346,7 +346,7 @@ udp6_input(mp, offp, proto)
strcpy(buf, ip6_sprintf(&ip6->ip6_dst));
log(LOG_INFO,
"Connection attempt to UDP %s:%d from %s:%d\n",
"Connection attempt to UDP [%s]:%d from [%s]:%d\n",
buf, ntohs(uh->uh_dport),
ip6_sprintf(&ip6->ip6_src), ntohs(uh->uh_sport));
}