我找不到一个,但很惊讶它不存在。是否有一个已经定义的枚举,其值(例如 TCP、UDP、ICMP)对应于 IP 标头的协议字段?
问问题
361 次
2 回答
2
没有枚举,但有getprotoent()
, getprotobyname()
,getprotobynumber()
如果你想从/etc/protocols
.
于 2013-10-08T15:10:28.433 回答
1
检查linux/include/uapi/linux/in.h
:
/* Standard well-defined IP protocols. */
enum {
IPPROTO_IP = 0, /* Dummy protocol for TCP */
#define IPPROTO_IP IPPROTO_IP
IPPROTO_ICMP = 1, /* Internet Control Message Protocol */
#define IPPROTO_ICMP IPPROTO_ICMP
IPPROTO_IGMP = 2, /* Internet Group Management Protocol */
#define IPPROTO_IGMP IPPROTO_IGMP
IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */
#define IPPROTO_IPIP IPPROTO_IPIP
IPPROTO_TCP = 6, /* Transmission Control Protocol */
#define IPPROTO_TCP IPPROTO_TCP
...
于 2021-05-16T11:18:09.923 回答