onsdag den 2 maj 2012 klockan 14:47 skrev Alfred M. Szmidt detta: > Well, OpenSolaris, NetBSD, OpenBSD, FreeBSD, and DragonFly BSD are > in agreement of using "struct icmp" and all macro names, save that > the BSDs might add a few beyond ICMP_MAXTYPE. Some small > disagreement on n_short/uint16_t and n_time/uint32_t exists, > though. > > Then comes Glibc along, keeps all of the above, adds a complete and > disjoint set of macros, and duplicates the old structure as 'struct > icmphdr'. Chicken race, if I ever saw one! > > I not convinced by such an argument (foo vs. bar); the simple case is > that GNU is our main target, and the GNU C library is the C library of > that system.
My observation was not meant as an argument really, but only expresses my surprise that the Glibc authors did not dare to exclude the heritage from BSD. Could the new set have originated with SysV? > We should name it after glibc, since that is the main C library on > GNU. The problem with the RFCs is that they are non-free > documentation; so we should not really refer to them even though they > are the standard. Same with POSIX. > > For reference I append the changes needed for 'libicmp/icmp.h'. > > Could you post a diff? Forgot it at first attempt. I am now convinced to let macros and typedefs stay as they are, only to mend and amend the code and descriptions to achieve corrections and improvements, so the present difference text will only serve as informal documen- tation of potential portability quirks for ICMP related macros. Regards, Mats E A
diff --git a/libicmp/icmp.h b/libicmp/icmp.h index 574b8d5..99db5b7 100644 --- a/libicmp/icmp.h +++ b/libicmp/icmp.h @@ -45,7 +45,7 @@ struct icmp_header unsigned short ipm_nextmtu; } ih_pmtu; - /* ICMP_ROUTERADV -- RFC 1256 */ + /* ICMP_ROUTERADVERT -- RFC 1256 */ struct ih_rtradv { unsigned char irt_num_addrs; /* Number of addresses following the msg */ @@ -67,7 +67,7 @@ struct icmp_header union { - struct id_ts /* ICMP_TIMESTAMP, ICMP_TIMESTAMP_REPLY */ + struct id_ts /* ICMP_TSTAMP, ICMP_TSTAMPREPLY */ { n_time its_otime; /* Originate timestamp */ n_time its_rtime; /* Recieve timestamp */ @@ -78,7 +78,7 @@ struct icmp_header struct ip idi_ip; /* options and then 64 bits of data */ } id_ip; - unsigned long id_mask; /* ICMP_ADDRESS, ICMP_ADDRESSREPLY */ + unsigned long id_mask; /* ICMP_MASKREQ, ICMP_MASKREPLY */ char id_data[1]; } icmp_dun; #define icmp_otime icmp_dun.id_ts.its_otime @@ -90,50 +90,51 @@ struct icmp_header }; #define ICMP_ECHOREPLY 0 /* Echo Reply */ -#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ -/* Codes for ICMP_DEST_UNREACH. */ -#define ICMP_NET_UNREACH 0 /* Network Unreachable */ -#define ICMP_HOST_UNREACH 1 /* Host Unreachable */ -#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ -#define ICMP_PORT_UNREACH 3 /* Port Unreachable */ -#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ -#define ICMP_SR_FAILED 5 /* Source Route failed */ -#define ICMP_NET_UNKNOWN 6 -#define ICMP_HOST_UNKNOWN 7 -#define ICMP_HOST_ISOLATED 8 -#define ICMP_NET_ANO 9 -#define ICMP_HOST_ANO 10 -#define ICMP_NET_UNR_TOS 11 -#define ICMP_HOST_UNR_TOS 12 -#define ICMP_PKT_FILTERED 13 /* Packet filtered */ -#define ICMP_PREC_VIOLATION 14 /* Precedence violation */ -#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ +#define ICMP_UNREACH 3 /* Destination Unreachable */ +/* Codes for ICMP_UNREACH. */ +#define ICMP_UNREACH_NET 0 /* Network Unreachable */ +#define ICMP_UNREACH_HOST 1 /* Host Unreachable */ +#define ICMP_UNREACH_PROTOCOL 2 /* Protocol Unreachable */ +#define ICMP_UNREACH_PORT 3 /* Port Unreachable */ +#define ICMP_UNREACH_NEEDFRAG 4 /* Fragmentation Needed/DF set */ +#define ICMP_UNREACH_SRCFAIL 5 /* Source Route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 +#define ICMP_UNREACH_HOST_UNKNOWN 7 +#define ICMP_UNREACH_ISOLATED 8 +#define ICMP_UNREACH_NET_PROHIB 9 +#define ICMP_UNREACH_HOST_PROHIB 10 +#define ICMP_UNREACH_TOSNET 11 +#define ICMP_UNREACH_TOSHOST 12 +#define ICMP_UNREACH_FILTER_PROHIB 13 /* Packet filtered */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* Precedence violation */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* Precedence cut off */ #define NR_ICMP_UNREACH 15 /* total subcodes */ -#define ICMP_SOURCE_QUENCH 4 /* Source Quench */ +#define ICMP_SOURCEQUENCH 4 /* Source Quench */ #define ICMP_REDIRECT 5 /* Redirect (change route) */ /* Codes for ICMP_REDIRECT. */ -#define ICMP_REDIR_NET 0 /* Redirect Net */ -#define ICMP_REDIR_HOST 1 /* Redirect Host */ -#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ -#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ +#define ICMP_REDIRECT_NET 0 /* Redirect Net */ +#define ICMP_REDIRECT_HOST 1 /* Redirect Host */ +#define ICMP_REDIRECT_TOSNET 2 /* Redirect Net for TOS */ +#define ICMP_REDIRECT_TOSHOST 3 /* Redirect Host for TOS */ #define ICMP_ECHO 8 /* Echo Request */ -#define ICMP_ROUTERADV 9 /* Router Advertisement -- RFC 1256 */ -#define ICMP_ROUTERDISCOVERY 10 /* Router Discovery -- RFC 1256 */ -#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ -/* Codes for TIME_EXCEEDED. */ -#define ICMP_EXC_TTL 0 /* TTL count exceeded */ -#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ - -#define ICMP_PARAMETERPROB 12 /* Parameter Problem */ -#define ICMP_TIMESTAMP 13 /* Timestamp Request */ -#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ -#define ICMP_INFO_REQUEST 15 /* Information Request */ -#define ICMP_INFO_REPLY 16 /* Information Reply */ -#define ICMP_ADDRESS 17 /* Address Mask Request */ -#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ -#define NR_ICMP_TYPES 18 +#define ICMP_ROUTERADVERT 9 /* Router Advertisement -- RFC 1256 */ +#define ICMP_ROUTERSOLICIT 10 /* Router Discovery -- RFC 1256 */ +#define ICMP_TIMXCEED 11 /* Time Exceeded */ +/* Codes for TIMXCEED. */ +#define ICMP_TIMXCEED_INTRANS 0 /* TTL count exceeded */ +#define ICMP_TIMXCEED_REASS 1 /* Fragment Reass time exceeded */ + +#define ICMP_PARAMPROB 12 /* Parameter Problem */ +#define ICMP_TSTAMP 13 /* Timestamp Request */ +#define ICMP_TSTAMPREPLY 14 /* Timestamp Reply */ +#define ICMP_IREQ 15 /* Information Request */ +#define ICMP_IREQREPLY 16 /* Information Reply */ +#define ICMP_MASKREQ 17 /* Address Mask Request */ +#define ICMP_MASKREPLY 18 /* Address Mask Reply */ + +#define ICMP_MAXTYPE 18