diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/uts/common/netinet | |
download | illumos-joyent-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/uts/common/netinet')
29 files changed, 5366 insertions, 0 deletions
diff --git a/usr/src/uts/common/netinet/Makefile b/usr/src/uts/common/netinet/Makefile new file mode 100644 index 0000000000..3e3b86cf50 --- /dev/null +++ b/usr/src/uts/common/netinet/Makefile @@ -0,0 +1,56 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +#ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# uts/common/netinet/Makefile +# +# include global definitions +include ../../../Makefile.master + +HDRS= arp.h dhcp.h icmp6.h icmp_var.h if_ether.h igmp.h igmp_var.h \ + in.h inetutil.h in_pcb.h in_systm.h in_var.h ip.h ip6.h ip_icmp.h \ + ip_mroute.h ip_var.h pim.h sctp.h tcp.h tcp_debug.h tcp_fsm.h \ + tcp_seq.h tcp_timer.h tcp_var.h tcpip.h udp.h udp_var.h + +ROOTDIRS= $(ROOT)/usr/include/netinet + +ROOTHDRS= $(HDRS:%=$(ROOT)/usr/include/netinet/%) + +CHECKHDRS= $(HDRS:%.h=%.check) + +$(ROOTDIRS)/%: % + $(INS.file) + +.KEEP_STATE: + +.PARALLEL: $(CHECKHDRS) + +install_h: $(ROOTDIRS) $(ROOTHDRS) + +$(ROOTDIRS): + $(INS.dir) + +check: $(CHECKHDRS) diff --git a/usr/src/uts/common/netinet/arp.h b/usr/src/uts/common/netinet/arp.h new file mode 100644 index 0000000000..523f111c00 --- /dev/null +++ b/usr/src/uts/common/netinet/arp.h @@ -0,0 +1,96 @@ +/* + * Copyright 1986-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_ARP_H +#define _NETINET_ARP_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Address Resolution Protocol. + * + * See RFC 826 for protocol description. ARP packets are variable + * in size; the arphdr structure defines the fixed-length portion. + * Protocol type values are the same as those for 10 Mb/s Ethernet. + * It is followed by the variable-sized fields ar_sha, arp_spa, + * arp_tha and arp_tpa in that order, according to the lengths + * specified. Field names used correspond to RFC 826. + */ +struct arphdr { + ushort_t ar_hrd; /* format of hardware address */ +#define ARPHRD_ETHER 1 /* ethernet hardware address */ +#define ARPHRD_IB 32 /* IPoIB hardware address */ + ushort_t ar_pro; /* format of protocol address */ + uchar_t ar_hln; /* length of hardware address */ + uchar_t ar_pln; /* length of protocol address */ + ushort_t ar_op; /* one of: */ +#define ARPOP_REQUEST 1 /* request to resolve address */ +#define ARPOP_REPLY 2 /* response to previous request */ +#define REVARP_REQUEST 3 /* Reverse ARP request */ +#define REVARP_REPLY 4 /* Reverse ARP reply */ + /* + * The remaining fields are variable in size, + * according to the sizes above, and are defined + * as appropriate for specific hardware/protocol + * combinations. (E.g., see <netinet/if_ether.h>.) + */ +#ifdef notdef + uchar_t ar_sha[]; /* sender hardware address */ + uchar_t ar_spa[]; /* sender protocol address */ + uchar_t ar_tha[]; /* target hardware address */ + uchar_t ar_tpa[]; /* target protocol address */ +#endif /* notdef */ +}; + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + struct ether_addr arp_sha; /* sender hardware address */ + uchar_t arp_spa[4]; /* sender protocol address */ + struct ether_addr arp_tha; /* target hardware address */ + uchar_t arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +/* + * ARP ioctl request + */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ +}; +/* arp_flags and at_flags field values */ +#define ATF_INUSE 0x01 /* entry in use */ +#define ATF_COM 0x02 /* completed entry (enaddr valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry (respond for other host) */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_ARP_H */ diff --git a/usr/src/uts/common/netinet/dhcp.h b/usr/src/uts/common/netinet/dhcp.h new file mode 100644 index 0000000000..0cf5660af3 --- /dev/null +++ b/usr/src/uts/common/netinet/dhcp.h @@ -0,0 +1,228 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * dhcp.h - Generic DHCP definitions, as per RFC's 2131 and 2132. + */ + +#ifndef _DHCP_H +#define _DHCP_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _REENTRANT +#include <thread.h> +#endif /* _REENTRANT */ + +/* + * DHCP option codes. + */ + +#define CD_PAD 0 +#define CD_END 255 +#define CD_SUBNETMASK 1 +#define CD_TIMEOFFSET 2 +#define CD_ROUTER 3 +#define CD_TIMESERV 4 +#define CD_IEN116_NAME_SERV 5 +#define CD_DNSSERV 6 +#define CD_LOG_SERV 7 +#define CD_COOKIE_SERV 8 +#define CD_LPR_SERV 9 +#define CD_IMPRESS_SERV 10 +#define CD_RESOURCE_SERV 11 +#define CD_HOSTNAME 12 +#define CD_BOOT_SIZE 13 +#define CD_DUMP_FILE 14 +#define CD_DNSDOMAIN 15 +#define CD_SWAP_SERV 16 +#define CD_ROOT_PATH 17 +#define CD_EXTEND_PATH 18 + +/* IP layer parameters */ +#define CD_IP_FORWARDING_ON 19 +#define CD_NON_LCL_ROUTE_ON 20 +#define CD_POLICY_FILTER 21 +#define CD_MAXIPSIZE 22 +#define CD_IPTTL 23 +#define CD_PATH_MTU_TIMEOUT 24 +#define CD_PATH_MTU_TABLE_SZ 25 + +/* IP layer parameters per interface */ +#define CD_MTU 26 +#define CD_ALL_SUBNETS_LCL_ON 27 +#define CD_BROADCASTADDR 28 +#define CD_MASK_DISCVRY_ON 29 +#define CD_MASK_SUPPLIER_ON 30 +#define CD_ROUTER_DISCVRY_ON 31 +#define CD_ROUTER_SOLICIT_SERV 32 +#define CD_STATIC_ROUTE 33 + +/* Link Layer Parameters per Interface */ +#define CD_TRAILER_ENCAPS_ON 34 +#define CD_ARP_TIMEOUT 35 +#define CD_ETHERNET_ENCAPS_ON 36 + +/* TCP Parameters */ +#define CD_TCP_TTL 37 +#define CD_TCP_KALIVE_INTVL 38 +#define CD_TCP_KALIVE_GRBG_ON 39 + +/* Application layer parameters */ +#define CD_NIS_DOMAIN 40 +#define CD_NIS_SERV 41 +#define CD_NTP_SERV 42 +#define CD_VENDOR_SPEC 43 + +/* NetBIOS parameters */ +#define CD_NETBIOS_NAME_SERV 44 +#define CD_NETBIOS_DIST_SERV 45 +#define CD_NETBIOS_NODE_TYPE 46 +#define CD_NETBIOS_SCOPE 47 + +/* X Window parameters */ +#define CD_XWIN_FONT_SERV 48 +#define CD_XWIN_DISP_SERV 49 + +/* DHCP protocol extension options */ +#define CD_REQUESTED_IP_ADDR 50 +#define CD_LEASE_TIME 51 +#define CD_OPTION_OVERLOAD 52 +#define CD_DHCP_TYPE 53 +#define CD_SERVER_ID 54 +#define CD_REQUEST_LIST 55 +#define CD_MESSAGE 56 +#define CD_MAX_DHCP_SIZE 57 +#define CD_T1_TIME 58 +#define CD_T2_TIME 59 +#define CD_CLASS_ID 60 +#define CD_CLIENT_ID 61 + +/* Netware options */ +#define CD_NW_IP_DOMAIN 62 +#define CD_NW_IP_OPTIONS 63 + +/* Nisplus options */ +#define CD_NISPLUS_DMAIN 64 +#define CD_NISPLUS_SERVS 65 + +/* Optional sname/bootfile options */ +#define CD_TFTP_SERV_NAME 66 +#define CD_OPT_BOOTFILE_NAME 67 + +/* Additional server options */ +#define CD_MOBILE_IP_AGENT 68 +#define CD_SMTP_SERVS 69 +#define CD_POP3_SERVS 70 +#define CD_NNTP_SERVS 71 +#define CD_WWW_SERVS 72 +#define CD_FINGER_SERVS 73 +#define CD_IRC_SERVS 74 + +/* Streettalk options */ +#define CD_STREETTALK_SERVS 75 +#define CD_STREETTALK_DA_SERVS 76 + +/* User class identifier */ +#define CD_USER_CLASS_ID 77 + +/* Newer options */ + +#define CD_SLPDA 78 +#define CD_SLPSS 79 +#define CD_AGENTOPT 82 +#define CD_FQDN 89 +#define CD_PXEARCHi 93 +#define CD_PXENIIi 94 +#define CD_PXECID 95 +#define CD_MULTICST 107 + +#define DHCP_FIRST_OPT CD_SUBNETMASK +#define DHCP_LAST_STD CD_MULTICST +#define DHCP_SITE_OPT 128 /* inclusive */ +#define DHCP_END_SITE 254 +#define DHCP_LAST_OPT DHCP_END_SITE /* last op code */ + +#define DHCP_MAX_OPT_SIZE 255 /* maximum option size in octets */ + +/* + * DHCP Packet. What will fit in a ethernet frame. We may use a smaller + * size, based on what our transport can handle. + */ +#define DHCP_DEF_MAX_SIZE 576 /* as spec'ed in RFC 2131 */ +#define PKT_BUFFER 1486 /* max possible size of pkt buffer */ +#define BASE_PKT_SIZE 240 /* everything but the options */ +typedef struct dhcp { + uint8_t op; /* message opcode */ + uint8_t htype; /* Hardware address type */ + uint8_t hlen; /* Hardware address length */ + uint8_t hops; /* Used by relay agents */ + uint32_t xid; /* transaction id */ + uint16_t secs; /* Secs elapsed since client boot */ + uint16_t flags; /* DHCP Flags field */ + struct in_addr ciaddr; /* client IP addr */ + struct in_addr yiaddr; /* 'Your' IP addr. (from server) */ + struct in_addr siaddr; /* Boot server IP addr */ + struct in_addr giaddr; /* Relay agent IP addr */ + uint8_t chaddr[16]; /* Client hardware addr */ + uint8_t sname[64]; /* Optl. boot server hostname */ + uint8_t file[128]; /* boot file name (ascii path) */ + uint8_t cookie[4]; /* Magic cookie */ + uint8_t options[60]; /* Options */ +} PKT; + +typedef uint32_t lease_t; /* DHCP lease time (32 bit quantity) */ + +/* + * DHCP packet types. As per protocol. + */ +#define DISCOVER ((uint8_t)1) +#define OFFER ((uint8_t)2) +#define REQUEST ((uint8_t)3) +#define DECLINE ((uint8_t)4) +#define ACK ((uint8_t)5) +#define NAK ((uint8_t)6) +#define RELEASE ((uint8_t)7) +#define INFORM ((uint8_t)8) + +/* + * Generic DHCP protocol defines + */ +#define DHCP_PERM ((lease_t)0xffffffff) /* "permanent" lease time */ +#define BOOTREQUEST (1) /* BOOTP REQUEST opcode */ +#define BOOTREPLY (2) /* BOOTP REPLY opcode */ +#define BOOTMAGIC { 99, 130, 83, 99 } /* rfc1048 magic cookie */ +#define BCAST_MASK 0x8000 /* BROADCAST flag */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DHCP_H */ diff --git a/usr/src/uts/common/netinet/icmp6.h b/usr/src/uts/common/netinet/icmp6.h new file mode 100644 index 0000000000..2d8903d6f1 --- /dev/null +++ b/usr/src/uts/common/netinet/icmp6.h @@ -0,0 +1,489 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NETINET_ICMP6_H +#define _NETINET_ICMP6_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> + +/* + * Type and code definitions for ICMPv6. + * Based on RFC2292. + */ + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +/* Minimum ICMPv6 header length. */ +#define ICMP6_MINLEN 8 + +typedef struct icmp6_hdr { + uint8_t icmp6_type; /* type field */ + uint8_t icmp6_code; /* code field */ + uint16_t icmp6_cksum; /* checksum field */ + union { + uint32_t icmp6_un_data32[1]; /* type-specific field */ + uint16_t icmp6_un_data16[2]; /* type-specific field */ + uint8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; +} icmp6_t; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +/* Multicast Listener Discovery messages (RFC 3542 (v1), RFC 3810 (v2)). */ + +#define MLD_MINLEN 24 +#define MLD_V2_QUERY_MINLEN 28 + +/* Query Header, common to v1 and v2 */ +typedef struct mld_hdr { + struct icmp6_hdr mld_icmp6_hdr; + struct in6_addr mld_addr; /* multicast address */ +} mld_hdr_t; + +#define mld_type mld_icmp6_hdr.icmp6_type +#define mld_code mld_icmp6_hdr.icmp6_code +#define mld_cksum mld_icmp6_hdr.icmp6_cksum +#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] +#define mld_reserved mld_icmp6_hdr.icmp6_data16[1] + +/* MLDv2 query */ +typedef struct mld2q { + mld_hdr_t mld2q_hdr; + uint8_t mld2q_sqrv; /* S Flag, Q's Robustness Variable */ + uint8_t mld2q_qqic; /* Querier's Query Interval Code */ + uint16_t mld2q_numsrc; /* number of sources */ +} mld2q_t; + +#define mld2q_type mld2q_hdr.mld_icmp6_hdr.icmp6_type +#define mld2q_code mld2q_hdr.mld_icmp6_hdr.icmp6_code +#define mld2q_cksum mld2q_hdr.mld_icmp6_hdr.icmp6_cksum +#define mld2q_mxrc mld2q_hdr.mld_icmp6_hdr.icmp6_data16[0] +#define mld2q_addr mld2q_hdr.mld_addr + +#define MLD_V2_SFLAG_MASK 0x8 /* mask off s part of sqrv */ +#define MLD_V2_RV_MASK 0x7 /* mask off qrv part of sqrv */ + +/* definitions used to extract max response delay from mrc field */ +#define MLD_V2_MAXRT_FPMIN 0x8000 +#define MLD_V2_MAXRT_MANT_MASK 0x0fff +#define MLD_V2_MAXRT_EXP_MASK 0x7000 + +/* definitions used to extract querier's query interval from qqic field */ +#define MLD_V2_QQI_FPMIN 0x80 +#define MLD_V2_QQI_MANT_MASK 0x0f +#define MLD_V2_QQI_EXP_MASK 0x70 + +/* MLDv2 response */ +typedef icmp6_t mld2r_t; + +#define mld2r_type icmp6_type +#define mld2r_res icmp6_code +#define mld2r_cksum icmp6_cksum +#define mld2r_res1 icmp6_data16[0] +#define mld2r_nummar icmp6_data16[1] + +/* MLDv2 multicast address record */ +typedef struct mld2mar { + uint8_t mld2mar_type; /* type of record */ + uint8_t mld2mar_auxlen; /* auxiliary data length */ + uint16_t mld2mar_numsrc; /* number of sources */ + struct in6_addr mld2mar_group; /* group address being reported */ +} mld2mar_t; + + +/* For router renumbering. */ +struct icmp6_router_renum { /* router renumbering header */ + struct icmp6_hdr rr_hdr; + uint8_t rr_segnum; + uint8_t rr_flags; + uint16_t rr_maxdelay; + uint32_t rr_reserved; +}; + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +/* Router renumbering flags */ +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +struct rr_pco_match { /* match prefix part */ + uint8_t rpm_code; + uint8_t rpm_len; + uint8_t rpm_ordinal; + uint8_t rpm_matchlen; + uint8_t rpm_minlen; + uint8_t rpm_maxlen; + uint16_t rpm_reserved; + struct in6_addr rpm_prefix; +}; + +/* PCO code values */ +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 + +struct rr_pco_use { /* use prefix part */ + uint8_t rpu_uselen; + uint8_t rpu_keeplen; + uint8_t rpu_ramask; + uint8_t rpu_raflags; + uint32_t rpu_vltime; + uint32_t rpu_pltime; + uint32_t rpu_flags; + struct in6_addr rpu_prefix; +}; + +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 + +#ifdef _BIG_ENDIAN +#define ICMP_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 +#define ICMP_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 +#else /* _BIG_ENDIAN */ +#define ICMP_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 +#define ICMP_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 +#endif /* _BIG_ENDIAN */ + +struct rr_result { /* router renumbering result message */ + uint16_t rrr_flags; + uint8_t rrr_ordinal; + uint8_t rrr_matchedlen; + uint32_t rrr_ifid; + struct in6_addr rrr_prefix; +}; + +#ifdef _BIG_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 +#else /* _BIG_ENDIAN */ +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 +#endif /* _BIG_ENDIAN */ + +/* ICMPv6 error types */ +#define ICMP6_DST_UNREACH 1 +#define ICMP6_PACKET_TOO_BIG 2 +#define ICMP6_TIME_EXCEEDED 3 +#define ICMP6_PARAM_PROB 4 + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +/* ICMPv6 query types */ +#define ICMP6_ECHO_REQUEST 128 +#define ICMP6_ECHO_REPLY 129 + +/* + * ICMPv6 group membership types + * ICMP6_MEMBERSHIP* types are the older names for these constants and should + * not be used in new code. + */ +#define MLD_LISTENER_QUERY 130 +#define ICMP6_MEMBERSHIP_QUERY 130 +#define MLD_LISTENER_REPORT 131 +#define ICMP6_MEMBERSHIP_REPORT 131 +#define MLD_LISTENER_REDUCTION 132 +#define ICMP6_MEMBERSHIP_REDUCTION 132 +#define MLD_V2_LISTENER_REPORT 143 + +/* types for neighbor discovery */ +#define ND_ROUTER_SOLICIT 133 +#define ND_ROUTER_ADVERT 134 +#define ND_NEIGHBOR_SOLICIT 135 +#define ND_NEIGHBOR_ADVERT 136 +#define ND_REDIRECT 137 + +/* router renumbering */ +#define ICMP6_ROUTER_RENUMBERING 138 + +#define ICMP6_MAX_INFO_TYPE 138 + +#define ICMP6_IS_ERROR(x) ((x) < 128) + +/* codes for ICMP6_DST_UNREACH */ +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ + /* administratively prohibited */ +#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ + +/* codes for ICMP6_TIME_EXCEEDED */ +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ + +/* codes for ICMP6_PARAM_PROB */ +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ + +/* Default MLD max report delay value */ +#define ICMP6_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) */ + +typedef struct nd_router_solicit { /* router solicitation */ + icmp6_t nd_rs_hdr; + /* could be followed by options */ +} nd_router_solicit_t; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +typedef struct nd_router_advert { /* router advertisement */ + icmp6_t nd_ra_hdr; + uint32_t nd_ra_reachable; /* reachable time */ + uint32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ +} nd_router_advert_t; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] + +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_MANAGED 0x80 + +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +typedef struct nd_neighbor_solicit { /* neighbor solicitation */ + icmp6_t nd_ns_hdr; + struct in6_addr nd_ns_target; /* target address */ + /* could be followed by options */ +} nd_neighbor_solicit_t; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +typedef struct nd_neighbor_advert { /* neighbor advertisement */ + icmp6_t nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ +} nd_neighbor_advert_t; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum + +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] + +/* + * The first three bits of the flgs_reserved field of the ND structure are + * defined in this order: + * Router flag + * Solicited flag + * Override flag + */ + +/* Save valuable htonl() cycles on little-endian boxen. */ + +#ifdef _BIG_ENDIAN + +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 + +#else /* _BIG_ENDIAN */ + +#define ND_NA_FLAG_ROUTER 0x80 +#define ND_NA_FLAG_SOLICITED 0x40 +#define ND_NA_FLAG_OVERRIDE 0x20 + +#endif /* _BIG_ENDIAN */ + +typedef struct nd_redirect { /* redirect */ + icmp6_t nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ +} nd_redirect_t; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +typedef struct nd_opt_hdr { /* Neighbor discovery option header */ + uint8_t nd_opt_type; + uint8_t nd_opt_len; /* in units of 8 octets */ + /* followed by option specific data */ +} nd_opt_hdr_t; + +/* Neighbor discovery option types */ +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 + +typedef struct nd_opt_prefix_info { /* prefix information */ + uint8_t nd_opt_pi_type; + uint8_t nd_opt_pi_len; + uint8_t nd_opt_pi_prefix_len; + uint8_t nd_opt_pi_flags_reserved; + uint32_t nd_opt_pi_valid_time; + uint32_t nd_opt_pi_preferred_time; + uint32_t nd_opt_pi_reserved2; + struct in6_addr nd_opt_pi_prefix; +} nd_opt_prefix_info_t; + +#define ND_OPT_PI_FLAG_AUTO 0x40 +#define ND_OPT_PI_FLAG_ONLINK 0x80 + +typedef struct nd_opt_rd_hdr { /* redirected header */ + uint8_t nd_opt_rh_type; + uint8_t nd_opt_rh_len; + uint16_t nd_opt_rh_reserved1; + uint32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ +} nd_opt_rd_hdr_t; + +typedef struct nd_opt_mtu { /* MTU option */ + uint8_t nd_opt_mtu_type; + uint8_t nd_opt_mtu_len; + uint16_t nd_opt_mtu_reserved; + uint32_t nd_opt_mtu_mtu; +} nd_opt_mtu_t; + +/* Note: the option is variable length (at least 8 bytes long) */ +#ifndef ND_MAX_HDW_LEN +#define ND_MAX_HDW_LEN 64 +#endif +struct nd_opt_lla { + uint8_t nd_opt_lla_type; + uint8_t nd_opt_lla_len; /* in units of 8 octets */ + uint8_t nd_opt_lla_hdw_addr[ND_MAX_HDW_LEN]; +}; + + +/* Neighbor discovery protocol constants */ + +/* Router constants */ +#define ND_MAX_INITIAL_RTR_ADVERT_INTERVAL 16000 /* milliseconds */ +#define ND_MAX_INITIAL_RTR_ADVERTISEMENTS 3 /* transmissions */ +#define ND_MAX_FINAL_RTR_ADVERTISEMENTS 3 /* transmissions */ +#define ND_MIN_DELAY_BETWEEN_RAS 3000 /* milliseconds */ +#define ND_MAX_RA_DELAY_TIME 500 /* milliseconds */ + +/* Host constants */ +#define ND_MAX_RTR_SOLICITATION_DELAY 1000 /* milliseconds */ +#define ND_RTR_SOLICITATION_INTERVAL 4000 /* milliseconds */ +#define ND_MAX_RTR_SOLICITATIONS 3 /* transmissions */ + +/* Node constants */ +#define ND_MAX_MULTICAST_SOLICIT 3 /* transmissions */ +#define ND_MAX_UNICAST_SOLICIT 3 /* transmissions */ +#define ND_MAX_ANYCAST_DELAY_TIME 1000 /* milliseconds */ +#define ND_MAX_NEIGHBOR_ADVERTISEMENT 3 /* transmissions */ +#define ND_REACHABLE_TIME 30000 /* milliseconds */ +#define ND_RETRANS_TIMER 1000 /* milliseconds */ +#define ND_DELAY_FIRST_PROBE_TIME 5000 /* milliseconds */ +#define ND_MIN_RANDOM_FACTOR .5 +#define ND_MAX_RANDOM_FACTOR 1.5 + +#define ND_MAX_REACHTIME 3600000 /* milliseconds */ +#define ND_MAX_REACHRETRANSTIME 100000 /* milliseconds */ + +/* + * ICMPv6 type filtering for IPPROTO_ICMPV6 ICMP6_FILTER socket option + */ +#define ICMP6_FILTER 0x01 /* Set filter */ + +typedef struct icmp6_filter { + uint32_t __icmp6_filt[8]; +} icmp6_filter_t; + +/* Pass all ICMPv6 messages to the application */ +#define ICMP6_FILTER_SETPASSALL(filterp) ( \ + ((filterp)->__icmp6_filt[0] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[1] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[2] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[3] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[4] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[5] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[6] = 0xFFFFFFFFU), \ + ((filterp)->__icmp6_filt[7] = 0xFFFFFFFFU)) + +/* ICMPv6 messages are blocked from being passed to the application */ +#define ICMP6_FILTER_SETBLOCKALL(filterp) ( \ + ((filterp)->__icmp6_filt[0] = 0x0), \ + ((filterp)->__icmp6_filt[1] = 0x0), \ + ((filterp)->__icmp6_filt[2] = 0x0), \ + ((filterp)->__icmp6_filt[3] = 0x0), \ + ((filterp)->__icmp6_filt[4] = 0x0), \ + ((filterp)->__icmp6_filt[5] = 0x0), \ + ((filterp)->__icmp6_filt[6] = 0x0), \ + ((filterp)->__icmp6_filt[7] = 0x0)) + +/* Pass messages of a given type to the application */ +#define ICMP6_FILTER_SETPASS(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))) + +/* Block messages of a given type from being passed to the application */ +#define ICMP6_FILTER_SETBLOCK(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))) + +/* Test if message of a given type will be passed to an application */ +#define ICMP6_FILTER_WILLPASS(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) + +/* + * Test if message of a given type will blocked from + * being passed to an application + */ +#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ + ((((filterp)->__icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) + + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_ICMP6_H */ diff --git a/usr/src/uts/common/netinet/icmp_var.h b/usr/src/uts/common/netinet/icmp_var.h new file mode 100644 index 0000000000..b67429f0f5 --- /dev/null +++ b/usr/src/uts/common/netinet/icmp_var.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Variables related to this implementation + * of the internet control message protocol. + */ + +#ifndef _NETINET_ICMP_VAR_H +#define _NETINET_ICMP_VAR_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* icmp_var.h 1.10 88/08/19 SMI; from UCB 7.2 1/13/87 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct icmpstat { +/* statistics related to icmp packets generated */ + int icps_error; /* # of calls to icmp_error */ + int icps_oldshort; /* no error 'cuz old ip too short */ + int icps_oldicmp; /* no error 'cuz old was icmp */ + int icps_outhist[ICMP_MAXTYPE + 1]; +/* statistics related to input messages processed */ + int icps_badcode; /* icmp_code out of range */ + int icps_tooshort; /* packet < ICMP_MINLEN */ + int icps_checksum; /* bad checksum */ + int icps_badlen; /* calculated bound mismatch */ + int icps_reflect; /* number of responses */ + int icps_inhist[ICMP_MAXTYPE + 1]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_ICMP_VAR_H */ diff --git a/usr/src/uts/common/netinet/if_ether.h b/usr/src/uts/common/netinet/if_ether.h new file mode 100644 index 0000000000..14d456aac4 --- /dev/null +++ b/usr/src/uts/common/netinet/if_ether.h @@ -0,0 +1,121 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#ifndef _NETINET_IF_ETHER_H +#define _NETINET_IF_ETHER_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* if_ether.h 1.28 89/08/04 SMI; from UCB 7.2 12/7/87 */ + +#include <sys/ethernet.h> + +/* + * The following include is for compatibility with SunOS 3.x and + * 4.3bsd. Newly written programs should include it separately. + */ +#include <net/if_arp.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + ether_addr_t arp_sha; /* sender hardware address */ + uchar_t arp_spa[4]; /* sender protocol address */ + ether_addr_t arp_tha; /* target hardware address */ + uchar_t arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +/* + * multicast address structure + * + * Keep a reference count for each multicast address so + * addresses loaded into chip are unique. + */ +struct mcaddr { + struct ether_addr mc_enaddr; /* multicast address */ + ushort_t mc_count; /* reference count */ +}; +#define MCADDRMAX 64 /* multicast addr table length */ +#define MCCOUNTMAX 4096 /* multicast addr max reference count */ + +/* + * Structure shared between the ethernet driver modules and + * the address resolution code. For example, each ec_softc or il_softc + * begins with this structure. + * + * The structure contains a pointer to an array of multicast addresses. + * This pointer is NULL until the first successful SIOCADDMULTI ioctl + * is issued for the interface. + */ +struct arpcom { + struct ifnet ac_if; /* network-visible interface */ + struct ether_addr ac_enaddr; /* ethernet hardware address */ + struct in_addr ac_ipaddr; /* copy of ip address- XXX */ + struct mcaddr *ac_mcaddr; /* table of multicast addrs */ + ushort_t ac_nmcaddr; /* count of M/C addrs in use */ + struct in_addr ac_lastip; /* cache of last ARP lookup */ + struct ether_addr ac_lastarp; /* result of the last ARP */ +}; + +/* + * Internet to ethernet address resolution table. + */ +struct arptab { + struct in_addr at_iaddr; /* internet address */ + union { + struct ether_addr atu_enaddr; /* ethernet address */ + long atu_tvsec; /* timestamp if incomplete */ + } at_union; + uchar_t at_timer; /* minutes since last reference */ + uchar_t at_flags; /* flags */ + struct mbuf *at_hold; /* last packet until resolved/timeout */ +}; + +#define at_enaddr at_union.atu_enaddr +#define at_tvsec at_union.atu_tvsec + +/* + * Copy IP addresses from a to b - assumes that the two given + * pointers can be referenced as shorts. On architectures + * where this is not the case, use bcopy instead. + */ +#if defined(__sparc) || defined(__i386) || defined(__amd64) +#define ip_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \ + ((short *)b)[1] = ((short *)a)[1]; } +#else +#define ip_copy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 4)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IF_ETHER_H */ diff --git a/usr/src/uts/common/netinet/igmp.h b/usr/src/uts/common/netinet/igmp.h new file mode 100644 index 0000000000..9954211b6e --- /dev/null +++ b/usr/src/uts/common/netinet/igmp.h @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _NETINET_IGMP_H +#define _NETINET_IGMP_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Internet Group Management Protocol (IGMP) definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * Modified by Rosen Sharma, Stanford, Aug 1994 + * Modified by Bill Fenner, Xerox PARC, April 1995 + * + * MULTICAST 3.5.1.1 + */ + +/* + * IGMP packet format. + */ +struct igmp { + uchar_t igmp_type; /* version & type of IGMP message */ + uchar_t igmp_code; /* code for routing sub-msgs */ + ushort_t igmp_cksum; /* IP-style checksum */ + struct in_addr igmp_group; /* group address being reported */ +}; /* (zero for queries) */ + +/* IGMPv3 Membership Report common header */ +struct igmp3r { + uchar_t igmp3r_type; /* version & type of IGMP message */ + uchar_t igmp3r_code; /* code for routing sub-msgs */ + ushort_t igmp3r_cksum; /* IP-style checksum */ + ushort_t igmp3r_res; /* Reserved */ + ushort_t igmp3r_numrec; /* Number of group records */ +}; + +/* IGMPv3 Group Record header */ +struct grphdr { + uchar_t grphdr_type; /* type of record */ + uchar_t grphdr_auxlen; /* auxiliary data length */ + ushort_t grphdr_numsrc; /* number of sources */ + struct in_addr grphdr_group; /* group address being reported */ +}; + +/* IGMPv3 Membership Query header */ +struct igmp3q { + uchar_t igmp3q_type; /* type of IGMP message */ + uchar_t igmp3q_mxrt; /* maximum response time */ + ushort_t igmp3q_cksum; /* IP-style checksum */ + struct in_addr igmp3q_group; /* group address being queried */ + ushort_t igmp3q_res; /* reserved */ + ushort_t igmp3q_numsrc; /* number of sources */ +}; + +#ifdef _KERNEL +typedef struct igmp_s { + uint8_t igmp_type; /* version & type of IGMP message */ + uint8_t igmp_code; /* code for routing sub-msgs */ + uint8_t igmp_cksum[2]; /* IP-style checksum */ + uint8_t igmp_group[4]; /* group address being reported */ +} igmp_t; /* (zero for queries) */ + +/* Aligned igmp header */ +typedef struct igmpa_s { + uint8_t igmpa_type; /* version & type of IGMP message */ + uint8_t igmpa_code; /* code for routing sub-msgs */ + uint16_t igmpa_cksum; /* IP-style checksum */ + ipaddr_t igmpa_group; /* group address being reported */ +} igmpa_t; /* (zero for queries) */ + +/* Aligned IGMPv3 Membership Report common header */ +typedef struct igmp3ra_s { + uint8_t igmp3ra_type; /* version & type of IGMP message */ + uint8_t igmp3ra_res; /* Reserved */ + uint16_t igmp3ra_cksum; /* IP-style checksum */ + uint16_t igmp3ra_res1; /* Reserved */ + uint16_t igmp3ra_numrec; /* Number of group records */ +} igmp3ra_t; + +/* Aligned IGMPv3 Group Record header */ +typedef struct grphdra_s { + uint8_t grphdra_type; /* type of record */ + uint8_t grphdra_auxlen; /* auxiliary data length */ + uint16_t grphdra_numsrc; /* number of sources */ + ipaddr_t grphdra_group; /* group addrss being reported */ +} grphdra_t; + +/* Aligned IGMpv3 Membership Query header */ +typedef struct igmp3qa_s { + uint8_t igmp3qa_type; /* type of IGMP message */ + uint8_t igmp3qa_mxrc; /* maximum response code */ + uint16_t igmp3qa_cksum; /* IP-style checksum */ + ipaddr_t igmp3qa_group; /* group address being queried */ + uint8_t igmp3qa_sqrv; /* S Flag, Q's Robustness Variable */ + uint8_t igmp3qa_qqic; /* Querier's Query Interval Code */ + uint16_t igmp3qa_numsrc; /* number of sources */ +} igmp3qa_t; + +#endif /* _KERNEL */ + + +#define IGMP_MINLEN 8 +#define IGMP_V3_QUERY_MINLEN 12 + + +/* + * Message types, including version number. + */ + +#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ +#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Vers.1 membership report */ +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Vers.2 membership report */ +#define IGMP_V3_MEMBERSHIP_REPORT 0x22 /* Vers.3 membership report */ +#define IGMP_V2_LEAVE_GROUP 0x17 /* Leave-group message */ +#define IGMP_DVMRP 0x13 /* DVMRP routing message */ +#define IGMP_PIM 0x14 /* PIM routing message */ + +#define IGMP_MTRACE_RESP 0x1e /* traceroute resp to sender */ +#define IGMP_MTRACE 0x1f /* mcast traceroute messages */ + +#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) */ + /* according to RFC1112 */ + +#define IGMP_V3_MAXRT_FPMIN 0x80 /* max resp code fp format */ +#define IGMP_V3_MAXRT_MANT_MASK 0x0f +#define IGMP_V3_MAXRT_EXP_MASK 0x70 + +#define IGMP_V3_SFLAG_MASK 0x8 /* mask off s part of sqrv */ +#define IGMP_V3_RV_MASK 0x7 /* mask off qrv part of sqrv */ + +#define IGMP_V3_QQI_FPMIN 0x80 /* qqi code fp format */ +#define IGMP_V3_QQI_MANT_MASK 0x0f +#define IGMP_V3_QQI_EXP_MASK 0x70 + +/* + * IGMPv3/MLDv2-specific definitions + */ +/* + * Group Record Types. The values of these enums match the Record Type + * field values defined in RFCs 3376 and 3810 for IGMPv3 and MLDv2 reports. + */ +typedef enum { + MODE_IS_INCLUDE = 1, + MODE_IS_EXCLUDE, + CHANGE_TO_INCLUDE, + CHANGE_TO_EXCLUDE, + ALLOW_NEW_SOURCES, + BLOCK_OLD_SOURCES +} mcast_record_t; + +/* Router Alert Option */ +#define RTRALERT_LEN 4 +#define RTRALERT_LEN_IN_WORDS 1 + +/* + * The following four defininitions are for backwards compatibility. + * They should be removed as soon as all applications are updated to + * use the new constant names. + */ +#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY +#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT +#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT +#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IGMP_H */ diff --git a/usr/src/uts/common/netinet/igmp_var.h b/usr/src/uts/common/netinet/igmp_var.h new file mode 100644 index 0000000000..2cdcaff904 --- /dev/null +++ b/usr/src/uts/common/netinet/igmp_var.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NETINET_IGMP_VAR_H +#define _NETINET_IGMP_VAR_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Internet Group Management Protocol (IGMP), + * implementation-specific definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * + * MULTICAST 3.5.1.1 + */ + +struct igmpstat { + uint_t igps_rcv_total; /* total IGMP messages received */ + uint_t igps_rcv_tooshort; /* received with too few bytes */ + uint_t igps_rcv_badsum; /* received with bad checksum */ + uint_t igps_rcv_queries; /* received membership queries */ + uint_t igps_rcv_badqueries; /* received invalid queries */ + uint_t igps_rcv_reports; /* received membership reports */ + uint_t igps_rcv_badreports; /* received invalid reports */ + uint_t igps_rcv_ourreports; /* received reports for our groups */ + uint_t igps_snd_reports; /* sent membership reports */ +}; + +#ifdef _KERNEL +struct igmpstat igmpstat; + +/* + * slowtimo interval used for both IGMP and MLD + */ +#define MCAST_SLOWTIMO_INTERVAL 10000 /* milliseconds */ + + +/* + * Macro to compute a random timer value between 1 and maxticks. + * Include <sys/random.h> for random_get_pseudo_bytes() declaration. + */ +#include <sys/random.h> +#define MCAST_RANDOM_DELAY(timer, maxticks) \ + /* uint_t timer; int maxticks */ \ + (void) random_get_pseudo_bytes((uint8_t *)&(timer), sizeof (uint_t)); \ + (timer) = ((uint_t)(timer) % (maxticks)) + 1 + +/* + * States for IGMPv2's leave processing + */ +#define IGMP_OTHERMEMBER 0 +#define IGMP_IREPORTEDLAST 1 + +/* + * We must remember what version the subnet's querier is. + */ +#define IGMP_V1_ROUTER 0 +#define IGMP_V2_ROUTER 1 +#define IGMP_V3_ROUTER 2 + +/* + * Map MLD versions to corresponding IGMP versions + */ +#define MLD_V1_ROUTER IGMP_V2_ROUTER +#define MLD_V2_ROUTER IGMP_V3_ROUTER + +/* + * Default values for various IGMPv3/MLDv2 values + */ +#define MCAST_DEF_ROBUSTNESS 2 +#define MCAST_QUERY_RESP_INTERVAL 10 /* in seconds */ +#define MCAST_DEF_QUERY_INTERVAL 125 /* in seconds */ +#define MCAST_DEF_QUERY_RESP_INTERVAL 100 /* in tenths of secs */ +#define MCAST_DEF_UNSOL_RPT_INTERVAL 1 /* in seconds */ + +/* + * IGMP and MLD mandate a TTL/Hop Limit of 1 for protocol messages + */ +#define IGMP_TTL 1 +#define MLD_HOP_LIMIT 1 + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IGMP_VAR_H */ diff --git a/usr/src/uts/common/netinet/in.h b/usr/src/uts/common/netinet/in.h new file mode 100644 index 0000000000..6e7f4066bb --- /dev/null +++ b/usr/src/uts/common/netinet/in.h @@ -0,0 +1,1214 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * Constants and structures defined by the internet system, + * according to following documents + * + * Internet ASSIGNED NUMBERS (RFC1700) and its successors + * and other assignments at ftp://ftp.isi.edu/in-notes/iana/assignments + * Basic Socket Interface Extensions for IPv6 (RFC2133 and its successors) + * + */ + +#ifndef _NETINET_IN_H +#define _NETINET_IN_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/feature_tests.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include <sys/socket_impl.h> +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifndef _SOCKLEN_T +#define _SOCKLEN_T + +/* + * The socklen definitions are reproduced here from sys/socket.h so as to + * not introduce that namespace into existing users of netinet/in.h. + */ +#if defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) +typedef size_t socklen_t; +#else +typedef uint32_t socklen_t; +#endif /* defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) */ + +#if defined(_XPG4_2) || defined(_BOOT) +typedef socklen_t *Psocklen_t; +#else +typedef void *Psocklen_t; +#endif /* defined(_XPG4_2) || defined(_BOOT) */ + +#endif /* _SOCKLEN_T */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#include <sys/stream.h> +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ +/* + * Symbols such as htonl() are required to be exposed through this file, + * per XNS Issue 5. This is achieved by inclusion of <sys/byteorder.h> + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) || defined(_XPG5) +#include <sys/byteorder.h> +#endif + +#ifndef _IN_PORT_T +#define _IN_PORT_T +typedef uint16_t in_port_t; +#endif + +/* + * Note: IPv4 address data structures usage conventions. + * The "in_addr_t" type below (required by Unix standards) + * is NOT a typedef of "struct in_addr" and violates the usual + * conventions where "struct <name>" and <name>_t are corresponding + * typedefs. + * To minimize confusion, kernel data structures/usage prefers use + * of "ipaddr_t" as atomic uint32_t type and avoid using "in_addr_t" + * The user level APIs continue to follow the historic popular + * practice of using "struct in_addr". + */ +#ifndef _IN_ADDR_T +#define _IN_ADDR_T +typedef uint32_t in_addr_t; +#endif + +#ifndef _IPADDR_T +#define _IPADDR_T +typedef uint32_t ipaddr_t; +#endif + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) + +struct in6_addr { + union { + /* + * Note: Static initalizers of "union" type assume + * the constant on the RHS is the type of the first member + * of union. + * To make static initializers (and efficient usage) work, + * the order of members exposed to user and kernel view of + * this data structure is different. + * User environment sees specified uint8_t type as first + * member whereas kernel sees most efficient type as + * first member. + */ +#ifdef _KERNEL + uint32_t _S6_u32[4]; /* IPv6 address */ + uint8_t _S6_u8[16]; /* IPv6 address */ +#else + uint8_t _S6_u8[16]; /* IPv6 address */ + uint32_t _S6_u32[4]; /* IPv6 address */ +#endif + uint32_t __S6_align; /* Align on 32 bit boundary */ + } _S6_un; +}; +#define s6_addr _S6_un._S6_u8 + +#ifdef _KERNEL +#define s6_addr8 _S6_un._S6_u8 +#define s6_addr32 _S6_un._S6_u32 +#endif + +typedef struct in6_addr in6_addr_t; + +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef uint16_t sa_family_t; +#endif + +/* + * Protocols + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_HOPOPTS 0 /* Hop by hop header for IPv6 */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_IGMP 2 /* group control protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_ENCAP 4 /* IP in IP encapsulation */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_IPV6 41 /* IPv6 encapsulated in IP */ +#define IPPROTO_ROUTING 43 /* Routing header for IPv6 */ +#define IPPROTO_FRAGMENT 44 /* Fragment header for IPv6 */ +#define IPPROTO_RSVP 46 /* rsvp */ +#define IPPROTO_ESP 50 /* IPsec Encap. Sec. Payload */ +#define IPPROTO_AH 51 /* IPsec Authentication Hdr. */ +#define IPPROTO_ICMPV6 58 /* ICMP for IPv6 */ +#define IPPROTO_NONE 59 /* No next header for IPv6 */ +#define IPPROTO_DSTOPTS 60 /* Destination options */ +#define IPPROTO_HELLO 63 /* "hello" routing protocol */ +#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ +#define IPPROTO_EON 80 /* ISO clnp */ +#define IPPROTO_OSPF 89 /* OSPF */ +#define IPPROTO_PIM 103 /* PIM routing protocol */ +#define IPPROTO_SCTP 132 /* Stream Control */ + /* Transmission Protocol */ + +#define IPPROTO_RAW 255 /* raw IP packet */ +#define IPPROTO_MAX 256 + +/* + * Port/socket numbers: network standard functions + */ +#define IPPORT_ECHO 7 +#define IPPORT_DISCARD 9 +#define IPPORT_SYSTAT 11 +#define IPPORT_DAYTIME 13 +#define IPPORT_NETSTAT 15 +#define IPPORT_CHARGEN 19 +#define IPPORT_FTP 21 +#define IPPORT_TELNET 23 +#define IPPORT_SMTP 25 +#define IPPORT_TIMESERVER 37 +#define IPPORT_NAMESERVER 42 +#define IPPORT_WHOIS 43 +#define IPPORT_MTP 57 + +/* + * Port/socket numbers: host specific functions + */ +#define IPPORT_BOOTPS 67 +#define IPPORT_BOOTPC 68 +#define IPPORT_TFTP 69 +#define IPPORT_RJE 77 +#define IPPORT_FINGER 79 +#define IPPORT_TTYLINK 87 +#define IPPORT_SUPDUP 95 + +/* + * Internet Key Exchange (IKE) ports + */ +#define IPPORT_IKE 500 +#define IPPORT_IKE_NATT 4500 + +/* + * UNIX TCP sockets + */ +#define IPPORT_EXECSERVER 512 +#define IPPORT_LOGINSERVER 513 +#define IPPORT_CMDSERVER 514 +#define IPPORT_EFSSERVER 520 + +/* + * UNIX UDP sockets + */ +#define IPPORT_BIFFUDP 512 +#define IPPORT_WHOSERVER 513 +#define IPPORT_ROUTESERVER 520 /* 520+1 also used */ + +/* + * Ports < IPPORT_RESERVED are reserved for + * privileged processes (e.g. root). + * Ports > IPPORT_USERRESERVED are reserved + * for servers, not necessarily privileged. + */ +#define IPPORT_RESERVED 1024 +#define IPPORT_USERRESERVED 5000 + +/* + * Link numbers + */ +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 + +/* + * IPv4 Internet address + * This definition contains obsolete fields for compatibility + * with SunOS 3.x and 4.2bsd. The presence of subnets renders + * divisions into fixed fields misleading at best. New code + * should use only the s_addr field. + */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#define _S_un_b S_un_b +#define _S_un_w S_un_w +#define _S_addr S_addr +#define _S_un S_un +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +struct in_addr { + union { + struct { uint8_t s_b1, s_b2, s_b3, s_b4; } _S_un_b; + struct { uint16_t s_w1, s_w2; } _S_un_w; +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + uint32_t _S_addr; +#else + in_addr_t _S_addr; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + } _S_un; +#define s_addr _S_un._S_addr /* should be used for all code */ +#define s_host _S_un._S_un_b.s_b2 /* OBSOLETE: host on imp */ +#define s_net _S_un._S_un_b.s_b1 /* OBSOLETE: network */ +#define s_imp _S_un._S_un_w.s_w2 /* OBSOLETE: imp */ +#define s_impno _S_un._S_un_b.s_b4 /* OBSOLETE: imp # */ +#define s_lh _S_un._S_un_b.s_b3 /* OBSOLETE: logical host */ +}; + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + */ +#define IN_CLASSA(i) (((i) & 0x80000000U) == 0) +#define IN_CLASSA_NET 0xff000000U +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffffU +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((i) & 0xc0000000U) == 0x80000000U) +#define IN_CLASSB_NET 0xffff0000U +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffffU +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((i) & 0xe0000000U) == 0xc0000000U) +#define IN_CLASSC_NET 0xffffff00U +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ffU + +#define IN_CLASSD(i) (((i) & 0xf0000000U) == 0xe0000000U) +#define IN_CLASSD_NET 0xf0000000U /* These aren't really */ +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IN_CLASSD_HOST 0x0fffffffU /* routing needn't know */ +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((i) & 0xe0000000U) == 0xe0000000U) +#define IN_BADCLASS(i) (((i) & 0xf0000000U) == 0xf0000000U) + +#define INADDR_ANY 0x00000000U +#define INADDR_LOOPBACK 0x7F000001U +#define INADDR_BROADCAST 0xffffffffU /* must be masked */ +#define INADDR_NONE 0xffffffffU + +#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ +#define INADDR_ALLRPTS_GROUP 0xe0000016U /* 224.0.0.22, IGMPv3 */ +#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */ + +/* Scoped IPv4 prefixes (in host byte-order) */ +#define IN_AUTOCONF_NET 0xa9fe0000U /* 169.254/16 */ +#define IN_AUTOCONF_MASK 0xffff0000U +#define IN_PRIVATE8_NET 0x0a000000U /* 10/8 */ +#define IN_PRIVATE8_MASK 0xff000000U +#define IN_PRIVATE12_NET 0xac100000U /* 172.16/12 */ +#define IN_PRIVATE12_MASK 0xfff00000U +#define IN_PRIVATE16_NET 0xc0a80000U /* 192.168/16 */ +#define IN_PRIVATE16_MASK 0xffff0000U + +/* Well known 6to4 Relay Router Anycast address defined in RFC 3068 */ +#if !defined(_XPG4_2) || !defined(__EXTENSIONS__) +#define INADDR_6TO4RRANYCAST 0xc0586301U /* 192.88.99.1 */ +#endif /* !defined(_XPG4_2) || !defined(__EXTENSIONS__) */ + +#define IN_LOOPBACKNET 127 /* official! */ + +/* + * Define a macro to stuff the loopback address into an Internet address + */ +#if !defined(_XPG4_2) || !defined(__EXTENSIONS__) +#define IN_SET_LOOPBACK_ADDR(a) \ + { (a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \ + (a)->sin_family = AF_INET; } +#endif /* !defined(_XPG4_2) || !defined(__EXTENSIONS__) */ + +/* + * IPv4 Socket address. + */ +struct sockaddr_in { + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) + char sin_zero[8]; +#else + unsigned char sin_zero[8]; +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ +}; + +#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) +/* + * IPv6 socket address. + */ +struct sockaddr_in6 { + sa_family_t sin6_family; + in_port_t sin6_port; + uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + uint32_t sin6_scope_id; /* Depends on scope of sin6_addr */ + uint32_t __sin6_src_id; /* Impl. specific - UDP replies */ +}; + +/* + * Macros for accessing the traffic class and flow label fields from + * sin6_flowinfo. + * These are designed to be applied to a 32-bit value. + */ +#ifdef _BIG_ENDIAN + +/* masks */ +#define IPV6_FLOWINFO_FLOWLABEL 0x000fffffU +#define IPV6_FLOWINFO_TCLASS 0x0ff00000U + +#else /* _BIG_ENDIAN */ + +/* masks */ +#define IPV6_FLOWINFO_FLOWLABEL 0xffff0f00U +#define IPV6_FLOWINFO_TCLASS 0x0000f00fU + +#endif /* _BIG_ENDIAN */ + +/* + * Note: Macros IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT are for + * use as RHS of Static initializers of "struct in6_addr" (or in6_addr_t) + * only. They need to be different for User/Kernel versions because union + * component data structure is defined differently (it is identical at + * binary representation level). + * + * const struct in6_addr IN6ADDR_ANY_INIT; + * const struct in6_addr IN6ADDR_LOOPBACK_INIT; + */ + + +#ifdef _KERNEL +#define IN6ADDR_ANY_INIT { 0, 0, 0, 0 } + +#ifdef _BIG_ENDIAN +#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0x00000001U } +#else /* _BIG_ENDIAN */ +#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0x01000000U } +#endif /* _BIG_ENDIAN */ + +#else + +#define IN6ADDR_ANY_INIT { 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0 } + +#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0x1U } +#endif /* _KERNEL */ + +/* + * RFC 2553 specifies the following macros. Their type is defined + * as "int" in the RFC but they only have boolean significance + * (zero or non-zero). For the purposes of our comment notation, + * we assume a hypothetical type "bool" defined as follows to + * write the prototypes assumed for macros in our comments better. + * + * typedef int bool; + */ + +/* + * IN6 macros used to test for special IPv6 addresses + * (Mostly from spec) + * + * bool IN6_IS_ADDR_UNSPECIFIED (const struct in6_addr *); + * bool IN6_IS_ADDR_LOOPBACK (const struct in6_addr *); + * bool IN6_IS_ADDR_MULTICAST (const struct in6_addr *); + * bool IN6_IS_ADDR_LINKLOCAL (const struct in6_addr *); + * bool IN6_IS_ADDR_SITELOCAL (const struct in6_addr *); + * bool IN6_IS_ADDR_V4MAPPED (const struct in6_addr *); + * bool IN6_IS_ADDR_V4MAPPED_ANY(const struct in6_addr *); -- Not from RFC2553 + * bool IN6_IS_ADDR_V4COMPAT (const struct in6_addr *); + * bool IN6_IS_ADDR_MC_RESERVED (const struct in6_addr *); -- Not from RFC2553 + * bool IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *); + * bool IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *); + * bool IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *); + * bool IN6_IS_ADDR_MC_ORGLOCAL (const struct in6_addr *); + * bool IN6_IS_ADDR_MC_GLOBAL (const struct in6_addr *); + * bool IN6_IS_ADDR_6TO4 (const struct in6_addr *); -- Not from RFC2553 + * bool IN6_ARE_6TO4_PREFIX_EQUAL(const struct in6_addr *, + * const struct in6_addr *); -- Not from RFC2553 + * bool IN6_IS_ADDR_LINKSCOPE (const struct in6addr *); -- Not from RFC2553 + */ + +#define IN6_IS_ADDR_UNSPECIFIED(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0) && \ + ((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_LOOPBACK(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0x00000001) && \ + ((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_LOOPBACK(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0x01000000) && \ + ((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MULTICAST(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff000000) == 0xff000000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MULTICAST(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x000000ff) == 0x000000ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xffc00000) == 0xfe800000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x0000c0ff) == 0x000080fe) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xffc00000) == 0xfec00000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x0000c0ff) == 0x0000c0fe) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4MAPPED(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4MAPPED(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +/* + * IN6_IS_ADDR_V4MAPPED - A IPv4 mapped INADDR_ANY + * Note: This macro is currently NOT defined in RFC2553 specification + * and not a standard macro that portable applications should use. + */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4MAPPED_ANY(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0) && \ + ((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4MAPPED_ANY(addr) \ + (((addr)->_S6_un._S6_u32[3] == 0) && \ + ((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0)) +#endif /* _BIG_ENDIAN */ + +/* Exclude loopback and unspecified address */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_V4COMPAT(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0x00000001)) + +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_V4COMPAT(addr) \ + (((addr)->_S6_un._S6_u32[2] == 0) && \ + ((addr)->_S6_un._S6_u32[1] == 0) && \ + ((addr)->_S6_un._S6_u32[0] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0) && \ + !((addr)->_S6_un._S6_u32[3] == 0x01000000)) +#endif /* _BIG_ENDIAN */ + +/* + * Note: + * IN6_IS_ADDR_MC_RESERVED macro is currently NOT defined in RFC2553 + * specification and not a standard macro that portable applications + * should use. + */ +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_RESERVED(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff000000) + +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_RESERVED(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000000ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_NODELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff010000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_NODELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000001ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff020000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000002ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff050000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_SITELOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000005ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff080000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000008ff) +#endif /* _BIG_ENDIAN */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_MC_GLOBAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff0e0000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_MC_GLOBAL(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x00000eff) +#endif /* _BIG_ENDIAN */ + +/* + * Macros to a) test for 6to4 IPv6 address, and b) to test if two + * 6to4 addresses have the same /48 prefix, and, hence, are from the + * same 6to4 site. + */ + +#ifdef _BIG_ENDIAN +#define IN6_IS_ADDR_6TO4(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0xffff0000) == 0x20020000) +#else /* _BIG_ENDIAN */ +#define IN6_IS_ADDR_6TO4(addr) \ + (((addr)->_S6_un._S6_u32[0] & 0x0000ffff) == 0x00000220) +#endif /* _BIG_ENDIAN */ + +#define IN6_ARE_6TO4_PREFIX_EQUAL(addr1, addr2) \ + (((addr1)->_S6_un._S6_u32[0] == (addr2)->_S6_un._S6_u32[0]) && \ + ((addr1)->_S6_un._S6_u8[4] == (addr2)->_S6_un._S6_u8[4]) && \ + ((addr1)->_S6_un._S6_u8[5] == (addr2)->_S6_un._S6_u8[5])) + +/* + * IN6_IS_ADDR_LINKSCOPE + * Identifies an address as being either link-local, link-local multicast or + * node-local multicast. All types of addresses are considered to be unique + * within the scope of a given link. + */ +#define IN6_IS_ADDR_LINKSCOPE(addr) \ + (IN6_IS_ADDR_LINKLOCAL(addr) || IN6_IS_ADDR_MC_LINKLOCAL(addr) || \ + IN6_IS_ADDR_MC_NODELOCAL(addr)) + +/* + * Useful utility macros for operations with IPv6 addresses + * Note: These macros are NOT defined in the RFC2553 or any other + * standard specification and are not standard macros that portable + * applications should use. + */ + +/* + * IN6_V4MAPPED_TO_INADDR + * IN6_V4MAPPED_TO_IPADDR + * Assign a IPv4-Mapped IPv6 address to an IPv4 address. + * Note: These macros are NOT defined in RFC2553 or any other standard + * specification and are not macros that portable applications should + * use. + * + * void IN6_V4MAPPED_TO_INADDR(const in6_addr_t *v6, struct in_addr *v4); + * void IN6_V4MAPPED_TO_IPADDR(const in6_addr_t *v6, ipaddr_t v4); + * + */ +#define IN6_V4MAPPED_TO_INADDR(v6, v4) \ + ((v4)->s_addr = (v6)->_S6_un._S6_u32[3]) +#define IN6_V4MAPPED_TO_IPADDR(v6, v4) \ + ((v4) = (v6)->_S6_un._S6_u32[3]) + +/* + * IN6_INADDR_TO_V4MAPPED + * IN6_IPADDR_TO_V4MAPPED + * Assign a IPv4 address address to an IPv6 address as a IPv4-mapped + * address. + * Note: These macros are NOT defined in RFC2553 or any other standard + * specification and are not macros that portable applications should + * use. + * + * void IN6_INADDR_TO_V4MAPPED(const struct in_addr *v4, in6_addr_t *v6); + * void IN6_IPADDR_TO_V4MAPPED(const ipaddr_t v4, in6_addr_t *v6); + * + */ +#ifdef _BIG_ENDIAN +#define IN6_INADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4)->s_addr, \ + (v6)->_S6_un._S6_u32[2] = 0x0000ffff, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#define IN6_IPADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4), \ + (v6)->_S6_un._S6_u32[2] = 0x0000ffff, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#else /* _BIG_ENDIAN */ +#define IN6_INADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4)->s_addr, \ + (v6)->_S6_un._S6_u32[2] = 0xffff0000U, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#define IN6_IPADDR_TO_V4MAPPED(v4, v6) \ + ((v6)->_S6_un._S6_u32[3] = (v4), \ + (v6)->_S6_un._S6_u32[2] = 0xffff0000U, \ + (v6)->_S6_un._S6_u32[1] = 0, \ + (v6)->_S6_un._S6_u32[0] = 0) +#endif /* _BIG_ENDIAN */ + +/* + * IN6_6TO4_TO_V4ADDR + * Extract the embedded IPv4 address from the prefix to a 6to4 IPv6 + * address. + * Note: This macro is NOT defined in RFC2553 or any other standard + * specification and is not a macro that portable applications should + * use. + * Note: we don't use the IPADDR form of the macro because we need + * to do a bytewise copy; the V4ADDR in the 6to4 address is not + * 32-bit aligned. + * + * void IN6_6TO4_TO_V4ADDR(const in6_addr_t *v6, struct in_addr *v4); + * + */ +#define IN6_6TO4_TO_V4ADDR(v6, v4) \ + ((v4)->_S_un._S_un_b.s_b1 = (v6)->_S6_un._S6_u8[2], \ + (v4)->_S_un._S_un_b.s_b2 = (v6)->_S6_un._S6_u8[3], \ + (v4)->_S_un._S_un_b.s_b3 = (v6)->_S6_un._S6_u8[4], \ + (v4)->_S_un._S_un_b.s_b4 = (v6)->_S6_un._S6_u8[5]) + +/* + * IN6_V4ADDR_TO_6TO4 + * Given an IPv4 address and an IPv6 address for output, a 6to4 address + * will be created from the IPv4 Address. + * Note: This method for creating 6to4 addresses is not standardized + * outside of Solaris. The newly created 6to4 address will be of the form + * 2002:<V4ADDR>:<SUBNETID>::<HOSTID>, where SUBNETID will equal 0 and + * HOSTID will equal 1. + * + * void IN6_V4ADDR_TO_6TO4(const struct in_addr *v4, in6_addr_t *v6) + * + */ +#ifdef _BIG_ENDIAN +#define IN6_V4ADDR_TO_6TO4(v4, v6) \ + ((v6)->_S6_un._S6_u8[0] = 0x20, \ + (v6)->_S6_un._S6_u8[1] = 0x02, \ + (v6)->_S6_un._S6_u8[2] = (v4)->_S_un._S_un_b.s_b1, \ + (v6)->_S6_un._S6_u8[3] = (v4)->_S_un._S_un_b.s_b2, \ + (v6)->_S6_un._S6_u8[4] = (v4)->_S_un._S_un_b.s_b3, \ + (v6)->_S6_un._S6_u8[5] = (v4)->_S_un._S_un_b.s_b4, \ + (v6)->_S6_un._S6_u8[6] = 0, \ + (v6)->_S6_un._S6_u8[7] = 0, \ + (v6)->_S6_un._S6_u32[2] = 0, \ + (v6)->_S6_un._S6_u32[3] = 0x00000001U) +#else +#define IN6_V4ADDR_TO_6TO4(v4, v6) \ + ((v6)->_S6_un._S6_u8[0] = 0x20, \ + (v6)->_S6_un._S6_u8[1] = 0x02, \ + (v6)->_S6_un._S6_u8[2] = (v4)->_S_un._S_un_b.s_b1, \ + (v6)->_S6_un._S6_u8[3] = (v4)->_S_un._S_un_b.s_b2, \ + (v6)->_S6_un._S6_u8[4] = (v4)->_S_un._S_un_b.s_b3, \ + (v6)->_S6_un._S6_u8[5] = (v4)->_S_un._S_un_b.s_b4, \ + (v6)->_S6_un._S6_u8[6] = 0, \ + (v6)->_S6_un._S6_u8[7] = 0, \ + (v6)->_S6_un._S6_u32[2] = 0, \ + (v6)->_S6_un._S6_u32[3] = 0x01000000U) +#endif /* _BIG_ENDIAN */ + +/* + * IN6_ARE_ADDR_EQUAL (defined in RFC2292) + * Compares if IPv6 addresses are equal. + * Note: Compares in order of high likelyhood of a miss so we minimize + * compares. (Current heuristic order, compare in reverse order of + * uint32_t units) + * + * bool IN6_ARE_ADDR_EQUAL(const struct in6_addr *, + * const struct in6_addr *); + */ +#define IN6_ARE_ADDR_EQUAL(addr1, addr2) \ + (((addr1)->_S6_un._S6_u32[3] == (addr2)->_S6_un._S6_u32[3]) && \ + ((addr1)->_S6_un._S6_u32[2] == (addr2)->_S6_un._S6_u32[2]) && \ + ((addr1)->_S6_un._S6_u32[1] == (addr2)->_S6_un._S6_u32[1]) && \ + ((addr1)->_S6_un._S6_u32[0] == (addr2)->_S6_un._S6_u32[0])) + +#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ + + +/* + * Options for use with [gs]etsockopt at the IP level. + * + * Note: Some of the IP_ namespace has conflict with and + * and is exposed through <xti.h>. (It also requires exposing + * options not implemented). The options with potential + * for conflicts use #ifndef guards. + */ +#ifndef IP_OPTIONS +#define IP_OPTIONS 1 /* set/get IP per-packet options */ +#endif + +#define IP_HDRINCL 2 /* int; header is included with data (raw) */ + +#ifndef IP_TOS +#define IP_TOS 3 /* int; IP type of service and precedence */ +#endif + +#ifndef IP_TTL +#define IP_TTL 4 /* int; IP time to live */ +#endif + +#define IP_RECVOPTS 0x5 /* int; receive all IP options w/datagram */ +#define IP_RECVRETOPTS 0x6 /* int; receive IP options for response */ +#define IP_RECVDSTADDR 0x7 /* int; receive IP dst addr w/datagram */ +#define IP_RETOPTS 0x8 /* ip_opts; set/get IP per-packet options */ +#define IP_RECVIF 0x9 /* int; receive the inbound interface index */ +#define IP_RECVSLLA 0xa /* sockaddr_dl; get source link layer address */ +#define IP_RECVTTL 0xb /* uint8_t; get TTL for inbound packet */ + +#define IP_MULTICAST_IF 0x10 /* set/get IP multicast interface */ +#define IP_MULTICAST_TTL 0x11 /* set/get IP multicast timetolive */ +#define IP_MULTICAST_LOOP 0x12 /* set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 0x13 /* add an IP group membership */ +#define IP_DROP_MEMBERSHIP 0x14 /* drop an IP group membership */ +#define IP_BLOCK_SOURCE 0x15 /* block mcast pkts from source */ +#define IP_UNBLOCK_SOURCE 0x16 /* unblock mcast pkts from source */ +#define IP_ADD_SOURCE_MEMBERSHIP 0x17 /* add mcast group/source pair */ +#define IP_DROP_SOURCE_MEMBERSHIP 0x18 /* drop mcast gruop/source pair */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Different preferences that can be requested from IPSEC protocols. + */ +#define IP_SEC_OPT 0x22 /* Used to set IPSEC options */ +#define IPSEC_PREF_NEVER 0x01 +#define IPSEC_PREF_REQUIRED 0x02 +#define IPSEC_PREF_UNIQUE 0x04 +/* + * This can be used with the setsockopt() call to set per socket security + * options. When the application uses per-socket API, we will reflect + * the request on both outbound and inbound packets. + */ + +typedef struct ipsec_req { + uint_t ipsr_ah_req; /* AH request */ + uint_t ipsr_esp_req; /* ESP request */ + uint_t ipsr_self_encap_req; /* Self-Encap request */ + uint8_t ipsr_auth_alg; /* Auth algs for AH */ + uint8_t ipsr_esp_alg; /* Encr algs for ESP */ + uint8_t ipsr_esp_auth_alg; /* Auth algs for ESP */ +} ipsec_req_t; + +/* + * MCAST_* options are protocol-independent. The actual definitions + * are with the v6 options below; this comment is here to note the + * namespace usage. + * + * #define MCAST_JOIN_GROUP 0x29 + * #define MCAST_LEAVE_GROUP 0x2a + * #define MCAST_BLOCK_SOURCE 0x2b + * #define MCAST_UNBLOCK_SOURCE 0x2c + * #define MCAST_JOIN_SOURCE_GROUP 0x2d + * #define MCAST_LEAVE_SOURCE_GROUP 0x2e + */ +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * SunOS private (potentially not portable) IP_ option names + */ +#define IP_BOUND_IF 0x41 /* bind socket to an ifindex */ +#define IP_UNSPEC_SRC 0x42 /* use unspecified source address */ +/* + * IP_XMIT_IF is used to send unicast/multicast packets through the specified + * interface without looking at the routing table entries. + * This is a Sun private interface. + */ +#define IP_XMIT_IF 0x43 /* use specified outgoing interface */ +/* + * IP_DONTFAILOVER_IF option is used to indicate that outbound unicast and + * multicast packets go through the specified interface, no load spreading, + * no failover. + * This is a Sun private interface. + */ +#define IP_DONTFAILOVER_IF 0x44 + +/* + * Option values and names (when !_XPG5) shared with <xti_inet.h> + */ +#ifndef IP_REUSEADDR +#define IP_REUSEADDR 0x104 +#endif + +#ifndef IP_DONTROUTE +#define IP_DONTROUTE 0x105 +#endif + +#ifndef IP_BROADCAST +#define IP_BROADCAST 0x106 +#endif + +/* + * The following option values are reserved by <xti_inet.h> + * + * T_IP_OPTIONS 0x107 - IP per-packet options + * T_IP_TOS 0x108 - IP per packet type of service + */ + +/* + * Default value constants for multicast attributes controlled by + * IP*_MULTICAST_LOOP and IP*_MULTICAST_{TTL,HOPS} options. + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument structure for IP_BLOCK_SOURCE, IP_UNBLOCK_SOURCE, + * IP_ADD_SOURCE_MEMBERSHIP, and IP_DROP_SOURCE_MEMBERSHIP. + */ +struct ip_mreq_source { + struct in_addr imr_multiaddr; /* IP address of group */ + struct in_addr imr_sourceaddr; /* IP address of source */ + struct in_addr imr_interface; /* IP address of interface */ +}; + +/* + * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP on + * IPv6 addresses. + */ +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */ + unsigned int ipv6mr_interface; /* interface index */ +}; + +/* + * Use #pragma pack() construct to force 32-bit alignment on amd64. + * This is needed to keep the structure size and offsets consistent + * between a 32-bit app and the 64-bit amd64 kernel in structures + * where 64-bit alignment would create gaps (in this case, structures + * which have a uint32_t followed by a struct sockaddr_storage). + */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* + * Argument structure for MCAST_JOIN_GROUP and MCAST_LEAVE_GROUP. + */ +struct group_req { + uint32_t gr_interface; /* interface index */ + struct sockaddr_storage gr_group; /* group address */ +}; + +/* + * Argument structure for MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE, + * MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP. + */ +struct group_source_req { + uint32_t gsr_interface; /* interface index */ + struct sockaddr_storage gsr_group; /* group address */ + struct sockaddr_storage gsr_source; /* source address */ +}; + +/* + * Argument for SIOC[GS]MSFILTER ioctls + */ +struct group_filter { + uint32_t gf_interface; /* interface index */ + struct sockaddr_storage gf_group; /* multicast address */ + uint32_t gf_fmode; /* filter mode */ + uint32_t gf_numsrc; /* number of sources */ + struct sockaddr_storage gf_slist[1]; /* source address */ +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +#define GROUP_FILTER_SIZE(numsrc) \ + (sizeof (struct group_filter) - sizeof (struct sockaddr_storage) \ + + (numsrc) * sizeof (struct sockaddr_storage)) + +/* + * Argument for SIOC[GS]IPMSFILTER ioctls (IPv4-specific) + */ +struct ip_msfilter { + struct in_addr imsf_multiaddr; /* IP multicast address of group */ + struct in_addr imsf_interface; /* local IP address of interface */ + uint32_t imsf_fmode; /* filter mode */ + uint32_t imsf_numsrc; /* number of sources in src_list */ + struct in_addr imsf_slist[1]; /* start of source list */ +}; + +#define IP_MSFILTER_SIZE(numsrc) \ + (sizeof (struct ip_msfilter) - sizeof (struct in_addr) \ + + (numsrc) * sizeof (struct in_addr)) + +/* + * Multicast source filter manipulation functions in libsocket; + * defined in RFC 3678. + */ +int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, uint32_t, + uint_t, struct sockaddr_storage *); + +int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, uint32_t *, + uint_t *, struct sockaddr_storage *); + +int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, + uint32_t, struct in_addr *); + +int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, + uint32_t *, struct in_addr *); + +/* + * Definitions needed for [gs]etsourcefilter(), [gs]etipv4sourcefilter() + */ +#define MCAST_INCLUDE 1 +#define MCAST_EXCLUDE 2 + +/* + * Argument struct for IPV6_PKTINFO option + */ +struct in6_pktinfo { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ +}; + +/* + * Argument struct for IPV6_MTUINFO option + */ +struct ip6_mtuinfo { + struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */ + uint32_t ip6m_mtu; /* path MTU in host byte order */ +}; + +/* + * IPv6 routing header types + */ +#define IPV6_RTHDR_TYPE_0 0 + +extern socklen_t inet6_rth_space(int type, int segments); +extern void *inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments); +extern int inet6_rth_add(void *bp, const struct in6_addr *addr); +extern int inet6_rth_reverse(const void *in, void *out); +extern int inet6_rth_segments(const void *bp); +extern struct in6_addr *inet6_rth_getaddr(const void *bp, int index); + +extern int inet6_opt_init(void *extbuf, socklen_t extlen); +extern int inet6_opt_append(void *extbuf, socklen_t extlen, int offset, + uint8_t type, socklen_t len, uint_t align, void **databufp); +extern int inet6_opt_finish(void *extbuf, socklen_t extlen, int offset); +extern int inet6_opt_set_val(void *databuf, int offset, void *val, + socklen_t vallen); +extern int inet6_opt_next(void *extbuf, socklen_t extlen, int offset, + uint8_t *typep, socklen_t *lenp, void **databufp); +extern int inet6_opt_find(void *extbufp, socklen_t extlen, int offset, + uint8_t type, socklen_t *lenp, void **databufp); +extern int inet6_opt_get_val(void *databuf, int offset, void *val, + socklen_t vallen); +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Argument structure for IP_ADD_PROXY_ADDR. + * Note that this is an unstable, experimental interface. It may change + * later. Don't use it unless you know what it is. + */ +typedef struct { + struct in_addr in_prefix_addr; + unsigned int in_prefix_len; +} in_prefix_t; + + +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +/* + * IPv6 options + */ +#define IPV6_UNICAST_HOPS 0x5 /* hop limit value for unicast */ + /* packets. */ + /* argument type: uint_t */ +#define IPV6_MULTICAST_IF 0x6 /* outgoing interface for */ + /* multicast packets. */ + /* argument type: struct in6_addr */ +#define IPV6_MULTICAST_HOPS 0x7 /* hop limit value to use for */ + /* multicast packets. */ + /* argument type: uint_t */ +#define IPV6_MULTICAST_LOOP 0x8 /* enable/disable delivery of */ + /* multicast packets on same socket. */ + /* argument type: uint_t */ +#define IPV6_JOIN_GROUP 0x9 /* join an IPv6 multicast group. */ + /* argument type: struct ipv6_mreq */ +#define IPV6_LEAVE_GROUP 0xa /* leave an IPv6 multicast group */ + /* argument type: struct ipv6_mreq */ +/* + * IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP are being kept + * for backward compatibility. They have the same meaning as IPV6_JOIN_GROUP + * and IPV6_LEAVE_GROUP respectively. + */ +#define IPV6_ADD_MEMBERSHIP 0x9 /* join an IPv6 multicast group. */ + /* argument type: struct ipv6_mreq */ +#define IPV6_DROP_MEMBERSHIP 0xa /* leave an IPv6 multicast group */ + /* argument type: struct ipv6_mreq */ + +#define IPV6_PKTINFO 0xb /* addr plus interface index */ + /* arg type: "struct in6_pktingo" - */ +#define IPV6_HOPLIMIT 0xc /* hoplimit for datagram */ +#define IPV6_NEXTHOP 0xd /* next hop address */ +#define IPV6_HOPOPTS 0xe /* hop by hop options */ +#define IPV6_DSTOPTS 0xf /* destination options - after */ + /* the routing header */ +#define IPV6_RTHDR 0x10 /* routing header */ +#define IPV6_RTHDRDSTOPTS 0x11 /* destination options - before */ + /* the routing header */ +#define IPV6_RECVPKTINFO 0x12 /* enable/disable IPV6_PKTINFO */ +#define IPV6_RECVHOPLIMIT 0x13 /* enable/disable IPV6_HOPLIMIT */ +#define IPV6_RECVHOPOPTS 0x14 /* enable/disable IPV6_HOPOPTS */ + +/* + * This options exists for backwards compatability and should no longer be + * used. Use IPV6_RECVDSTOPTS instead. + */ +#define _OLD_IPV6_RECVDSTOPTS 0x15 + +#define IPV6_RECVRTHDR 0x16 /* enable/disable IPV6_RTHDR */ + +/* + * enable/disable IPV6_RTHDRDSTOPTS. Now obsolete. IPV6_RECVDSTOPTS enables + * the receipt of both headers. + */ +#define IPV6_RECVRTHDRDSTOPTS 0x17 + +#define IPV6_CHECKSUM 0x18 /* Control checksum on raw sockets */ +#define IPV6_RECVTCLASS 0x19 /* enable/disable IPV6_CLASS */ +#define IPV6_USE_MIN_MTU 0x20 /* send packets with minimum MTU */ +#define IPV6_DONTFRAG 0x21 /* don't fragment packets */ +#define IPV6_SEC_OPT 0x22 /* Used to set IPSEC options */ +#define IPV6_SRC_PREFERENCES 0x23 /* Control socket's src addr select */ +#define IPV6_RECVPATHMTU 0x24 /* receive PMTU info */ +#define IPV6_PATHMTU 0x25 /* get the PMTU */ +#define IPV6_TCLASS 0x26 /* traffic class */ +#define IPV6_V6ONLY 0x27 /* v6 only socket option */ + +/* + * enable/disable receipt of both both IPV6_DSTOPTS headers. + */ +#define IPV6_RECVDSTOPTS 0x28 + +/* + * protocol-independent multicast membership options. + */ +#define MCAST_JOIN_GROUP 0x29 /* join group for all sources */ +#define MCAST_LEAVE_GROUP 0x2a /* leave group */ +#define MCAST_BLOCK_SOURCE 0x2b /* block specified source */ +#define MCAST_UNBLOCK_SOURCE 0x2c /* unblock specified source */ +#define MCAST_JOIN_SOURCE_GROUP 0x2d /* join group for specified source */ +#define MCAST_LEAVE_SOURCE_GROUP 0x2e /* leave source/group pair */ + +/* 32Bit field for IPV6_SRC_PREFERENCES */ +#define IPV6_PREFER_SRC_HOME 0x00000001 +#define IPV6_PREFER_SRC_COA 0x00000002 +#define IPV6_PREFER_SRC_PUBLIC 0x00000004 +#define IPV6_PREFER_SRC_TMP 0x00000008 +#define IPV6_PREFER_SRC_NONCGA 0x00000010 +#define IPV6_PREFER_SRC_CGA 0x00000020 + +#define IPV6_PREFER_SRC_MIPMASK (IPV6_PREFER_SRC_HOME | IPV6_PREFER_SRC_COA) +#define IPV6_PREFER_SRC_MIPDEFAULT IPV6_PREFER_SRC_HOME +#define IPV6_PREFER_SRC_TMPMASK (IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP) +#define IPV6_PREFER_SRC_TMPDEFAULT IPV6_PREFER_SRC_PUBLIC +#define IPV6_PREFER_SRC_CGAMASK (IPV6_PREFER_SRC_NONCGA | IPV6_PREFER_SRC_CGA) +#define IPV6_PREFER_SRC_CGADEFAULT IPV6_PREFER_SRC_NONCGA + +#define IPV6_PREFER_SRC_MASK (IPV6_PREFER_SRC_MIPMASK |\ + IPV6_PREFER_SRC_TMPMASK | IPV6_PREFER_SRC_CGAMASK) + +#define IPV6_PREFER_SRC_DEFAULT (IPV6_PREFER_SRC_MIPDEFAULT |\ + IPV6_PREFER_SRC_TMPDEFAULT | IPV6_PREFER_SRC_CGADEFAULT) + +/* + * SunOS private (potentially not portable) IPV6_ option names + */ +#define IPV6_BOUND_IF 0x41 /* bind to an ifindex */ +#define IPV6_UNSPEC_SRC 0x42 /* source of packets set to */ + /* unspecified (all zeros) */ +#define IPV6_BOUND_PIF 0x43 /* Bind to Physical interface */ + /* No load balancing or failover */ +/* + * IPV6_DONTFAILOVER_IF option is used to indicate that outbound unicast and + * multicast packets go through the specified interface, no load spreading, + * no failover. + * This is a Sun private interface. + */ +#define IPV6_DONTFAILOVER_IF 0x44 + +/* + * Miscellaneous IPv6 constants. + */ +#define INET_ADDRSTRLEN 16 /* max len IPv4 addr in ascii dotted */ + /* decimal notation. */ +#define INET6_ADDRSTRLEN 46 /* max len of IPv6 addr in ascii */ + /* standard colon-hex notation. */ +#define IPV6_PAD1_OPT 0 /* pad byte in IPv6 extension hdrs */ + +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +/* + * Extern declarations for pre-defined global const variables + */ +#if !defined(_XPG4_2) || defined(__EXTENSIONS__) +#ifndef _KERNEL +#ifdef __STDC__ +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +#else +extern struct in6_addr in6addr_any; +extern struct in6_addr in6addr_loopback; +#endif +#endif +#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_H */ diff --git a/usr/src/uts/common/netinet/in_pcb.h b/usr/src/uts/common/netinet/in_pcb.h new file mode 100644 index 0000000000..0814efc5b3 --- /dev/null +++ b/usr/src/uts/common/netinet/in_pcb.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Common structure pcb for internet protocol implementation. + * Here are stored pointers to local and foreign host table + * entries, local and foreign socket numbers, and pointers + * up (to a socket structure) and down (to a protocol-specific) + * control block. + */ + +#ifndef _NETINET_IN_PCB_H +#define _NETINET_IN_PCB_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* in_pcb.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct inpcb { + struct inpcb *inp_next, *inp_prev; /* pointers to other pcb's */ + struct inpcb *inp_head; /* pointer back to chain of inpcb's */ + /* for this protocol */ + struct in_addr inp_faddr; /* foreign host table entry */ + ushort_t inp_fport; /* foreign port */ + struct in_addr inp_laddr; /* local host table entry */ + ushort_t inp_lport; /* local port */ + struct socket *inp_socket; /* back pointer to socket */ + caddr_t inp_ppcb; /* pointer to per-protocol pcb */ + struct route inp_route; /* placeholder for routing entry */ + struct mbuf *inp_options; /* IP options */ +}; + +#define INPLOOKUP_WILDCARD 1 +#define INPLOOKUP_SETLOCAL 2 + +#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_PCB_H */ diff --git a/usr/src/uts/common/netinet/in_systm.h b/usr/src/uts/common/netinet/in_systm.h new file mode 100644 index 0000000000..ac1deee903 --- /dev/null +++ b/usr/src/uts/common/netinet/in_systm.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 1997-1998, 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_IN_SYSTM_H +#define _NETINET_IN_SYSTM_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* in_systm.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Legacy "network types" -- these are provided for backwards compatibility + * only; new code should use uint16_t and uint32_t instead. + */ +typedef uint16_t n_short; /* short as received from the net */ +typedef uint32_t n_long; /* long as received from the net */ +typedef uint32_t n_time; /* ms since 00:00 GMT, byte rev */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_SYSTM_H */ diff --git a/usr/src/uts/common/netinet/in_var.h b/usr/src/uts/common/netinet/in_var.h new file mode 100644 index 0000000000..c49b2e9ff8 --- /dev/null +++ b/usr/src/uts/common/netinet/in_var.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1985, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Interface address, Internet version. One of these structures + * is allocated for each interface with an Internet address. + * The ifaddr structure contains the protocol-independent part + * of the structure and is assumed to be first. + */ + +#ifndef _NETINET_IN_VAR_H +#define _NETINET_IN_VAR_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* in_var.h 1.3 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct in_ifaddr { + struct ifaddr ia_ifa; /* protocol-independent info */ +#define ia_addr ia_ifa.ifa_addr +#define ia_broadaddr ia_ifa.ifa_broadaddr +#define ia_dstaddr ia_ifa.ifa_dstaddr +#define ia_ifp ia_ifa.ifa_ifp + ulong_t ia_net; /* network number of interface */ + ulong_t ia_netmask; /* mask of net part */ + ulong_t ia_subnet; /* subnet number, including net */ + ulong_t ia_subnetmask; /* mask of net + subnet */ + struct in_addr ia_netbroadcast; /* broadcast addr for (logical) net */ + int ia_flags; + struct in_ifaddr *ia_next; /* next in list of internet addresses */ +}; +/* + * Given a pointer to an in_ifaddr (ifaddr), + * return a pointer to the addr as a sockadd_in. + */ +#define IA_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_addr)) +/* + * ia_flags + */ +#define IFA_ROUTE 0x01 /* routing entry installed */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IN_VAR_H */ diff --git a/usr/src/uts/common/netinet/inetutil.h b/usr/src/uts/common/netinet/inetutil.h new file mode 100644 index 0000000000..b8dbbcb5d5 --- /dev/null +++ b/usr/src/uts/common/netinet/inetutil.h @@ -0,0 +1,49 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ifndef _NETINET_INETUTIL_H +#define _NETINET_INETUTIL_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Routines to convert binary data into hexidecimal ascii notation and + * vice versa. + */ +extern int octet_to_hexascii(const void *, uint_t, char *, uint_t *); +extern int hexascii_to_octet(const char *, uint_t, void *, uint_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_INETUTIL_H */ diff --git a/usr/src/uts/common/netinet/ip.h b/usr/src/uts/common/netinet/ip.h new file mode 100644 index 0000000000..f3aea0240d --- /dev/null +++ b/usr/src/uts/common/netinet/ip.h @@ -0,0 +1,184 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ + +#ifndef _NETINET_IP_H +#define _NETINET_IP_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* ip.h 1.13 88/08/19 SMI; from UCB 7.6.1.1 3/15/88 */ + +#include <sys/isa_defs.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + */ +struct ip { +#ifdef _BIT_FIELDS_LTOH + uchar_t ip_hl:4, /* header length */ + ip_v:4; /* version */ +#else + uchar_t ip_v:4, /* version */ + ip_hl:4; /* header length */ +#endif + uchar_t ip_tos; /* type of service */ + ushort_t ip_len; /* total length */ + ushort_t ip_id; /* identification */ + ushort_t ip_off; /* fragment offset field */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ + uchar_t ip_ttl; /* time to live */ + uchar_t ip_p; /* protocol */ + ushort_t ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ +}; + +#define IP_MAXPACKET 65535 /* maximum packet size */ + +/* + * Definitions for IP type of service (ip_tos) + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_ECT 0x02 /* ECN-Capable Transport flag */ +#define IPTOS_CE 0x01 /* ECN-Congestion Experienced flag */ + +/* + * Definitions for IP precedence (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ + +/* Bits in the option value */ +#define IPOPT_COPY 0x80 + +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0x00 /* end of option list */ +#define IPOPT_NOP 0x01 /* no operation */ + +#define IPOPT_RR 0x07 /* record packet route */ +#define IPOPT_RTRALERT 0x14 /* router alert */ +#define IPOPT_TS 0x44 /* timestamp */ +#define IPOPT_SECURITY 0x82 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 0x83 /* loose source route */ +#define IPOPT_EXTSEC 0x85 +#define IPOPT_COMSEC 0x86 +#define IPOPT_SATID 0x88 /* satnet id */ +#define IPOPT_SSRR 0x89 /* strict source route */ +#define IPOPT_RA 0x94 +#define IPOPT_SDMDD 0x95 + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_POS_OV_FLG 3 +#define IPOPT_MINOFF 4 /* min value of IPOPT_OFFSET */ + + +/* Minimum for src and record route options */ +#define IPOPT_MINOFF_SR IPOPT_MINOFF + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + uchar_t ipt_code; /* IPOPT_TS */ + uchar_t ipt_len; /* size of structure (variable) */ + uchar_t ipt_ptr; /* index of current entry */ +#ifdef _BIT_FIELDS_LTOH + uchar_t ipt_flg:4, /* flags, see below */ + ipt_oflw:4; /* overflow counter */ +#else + uchar_t ipt_oflw:4, /* overflow counter */ + ipt_flg:4; /* flags, see below */ +#endif + union ipt_timestamp { + uint32_t ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + uint32_t ipt_time; + } ipt_ta[1]; + } ipt_timestamp; +}; + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 2 /* specified modules only */ +#define IPOPT_TS_PRESPEC_RFC791 3 + +/* Minimum for timestamp option */ +#define IPOPT_MINOFF_IT 5 +#define IPOPT_MINLEN_IT 5 + +#define IPOPT_TS_TIMELEN 4 /* Timestamp size */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_H */ diff --git a/usr/src/uts/common/netinet/ip6.h b/usr/src/uts/common/netinet/ip6.h new file mode 100644 index 0000000000..e9a0d6bf00 --- /dev/null +++ b/usr/src/uts/common/netinet/ip6.h @@ -0,0 +1,249 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. + * All rights reserved. + * Use is subject to license terms. + */ + +/* + * ip6.h - Common structures and definitions as defined by + * advanced BSD API. + */ + +#ifndef _NETINET_IP6_H +#define _NETINET_IP6_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> +#include <netinet/in.h> + +struct ip6_hdr { + union { + struct ip6_hdrctl { + uint32_t ip6_un1_flow; /* 4 bits version, */ + /* 8 bits tclass, and */ + /* 20 bits flow-ID */ + uint16_t ip6_un1_plen; /* payload length */ + uint8_t ip6_un1_nxt; /* next header */ + uint8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + uint8_t ip6_un2_vfc; /* 4 bits version and */ + /* top 4 bits of tclass */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ +}; +typedef struct ip6_hdr ip6_t; + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc /* 4 bits version and */ + /* top 4 bits of tclass */ +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_vcf ip6_flow /* Version, tclass, flow-ID */ +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +/* Hop-by-Hop options header */ +struct ip6_hbh { + uint8_t ip6h_nxt; /* next header */ + uint8_t ip6h_len; /* length in units of 8 octets */ + /* followed by options */ +}; +typedef struct ip6_hbh ip6_hbh_t; + +/* Destination options header */ +struct ip6_dest { + uint8_t ip6d_nxt; /* next header */ + uint8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ +}; +typedef struct ip6_dest ip6_dest_t; + +/* Routing header */ +struct ip6_rthdr { + uint8_t ip6r_nxt; /* next header */ + uint8_t ip6r_len; /* length in units of 8 octets */ + uint8_t ip6r_type; /* routing type */ + uint8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ +}; +typedef struct ip6_rthdr ip6_rthdr_t; + +/* Type 0 Routing header */ +struct ip6_rthdr0 { + uint8_t ip6r0_nxt; /* next header */ + uint8_t ip6r0_len; /* length in units of 8 octets */ + uint8_t ip6r0_type; /* always zero */ + uint8_t ip6r0_segleft; /* segments left */ + uint32_t ip6r0_reserved; /* reserved field */ +}; +typedef struct ip6_rthdr0 ip6_rthdr0_t; + +/* Fragment header */ +struct ip6_frag { + uint8_t ip6f_nxt; /* next header */ + uint8_t ip6f_reserved; /* reserved field */ + uint16_t ip6f_offlg; /* offset, reserved, and flag */ + uint32_t ip6f_ident; /* identification */ +}; +typedef struct ip6_frag ip6_frag_t; + +/* ip6f_offlg field related constants (in network byte order) */ +#ifdef _BIG_ENDIAN +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ +#else +#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ +#endif + +/* IPv6 options */ +struct ip6_opt { + uint8_t ip6o_type; + uint8_t ip6o_len; +}; + +/* + * The high-order 3 bits of the option type define the behavior + * when processing an unknown option and whether or not the option + * content changes in flight. + */ +#define IP6OPT_TYPE(o) ((o) & 0xc0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xc0 +#define IP6OPT_MUTABLE 0x20 + +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xc2 /* 11 0 00010 = 194 */ +#define IP6OPT_NSAP_ADDR 0xc3 /* 11 0 00011 */ +#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */ +#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ +#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ +#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ +#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ +#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ +#define IP6OPT_EID 0x8a /* 10 0 01010 */ + +/* Jumbo Payload Option */ +struct ip6_opt_jumbo { + uint8_t ip6oj_type; + uint8_t ip6oj_len; + uint8_t ip6oj_jumbo_len[4]; +}; +#define IP6OPT_JUMBO_LEN 6 + +/* NSAP Address Option */ +struct ip6_opt_nsap { + uint8_t ip6on_type; + uint8_t ip6on_len; + uint8_t ip6on_src_nsap_len; + uint8_t ip6on_dst_nsap_len; + /* Followed by source NSAP */ + /* Followed by destination NSAP */ +}; + +/* Tunnel Limit Option */ +struct ip6_opt_tunnel { + uint8_t ip6ot_type; + uint8_t ip6ot_len; + uint8_t ip6ot_encap_limit; +}; + +/* Router Alert Option */ +struct ip6_opt_router { + uint8_t ip6or_type; + uint8_t ip6or_len; + uint8_t ip6or_value[2]; +}; + +/* Router alert values (in network byte order) */ +#ifdef _BIG_ENDIAN +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0001 +#define IP6_ALERT_AN 0x0002 +#else +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0100 +#define IP6_ALERT_AN 0x0200 +#endif + +/* Binding Update Option */ +struct ip6_opt_binding_update { + uint8_t ip6ou_type; + uint8_t ip6ou_len; + uint8_t ip6ou_flags; + uint8_t ip6ou_prefixlen; + uint8_t ip6ou_seqno[2]; + uint8_t ip6ou_lifetime[4]; + uint8_t ip6ou_coa[16]; /* Optional based on flags */ + /* Followed by sub-options */ +}; + +/* Binding Update Flags */ +#define IP6_BUF_ACK 0x80 /* Request a binding ack */ +#define IP6_BUF_HOME 0x40 /* Home Registration */ +#define IP6_BUF_COA 0x20 /* Care-of-address present in option */ +#define IP6_BUF_ROUTER 0x10 /* Sending mobile node is a router */ + +/* Binding Ack Option */ +struct ip6_opt_binding_ack { + uint8_t ip6oa_type; + uint8_t ip6oa_len; + uint8_t ip6oa_status; + uint8_t ip6oa_seqno[2]; + uint8_t ip6oa_lifetime[4]; + uint8_t ip6oa_refresh[4]; + /* Followed by sub-options */ +}; + +/* Binding Request Option */ +struct ip6_opt_binding_request { + uint8_t ip6or_type; + uint8_t ip6or_len; + /* Followed by sub-options */ +}; + +/* Home Address Option */ +struct ip6_opt_home_address { + uint8_t ip6oh_type; + uint8_t ip6oh_len; + uint8_t ip6oh_addr[16]; /* Home Address */ + /* Followed by sub-options */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP6_H */ diff --git a/usr/src/uts/common/netinet/ip_icmp.h b/usr/src/uts/common/netinet/ip_icmp.h new file mode 100644 index 0000000000..ed83ba9b54 --- /dev/null +++ b/usr/src/uts/common/netinet/ip_icmp.h @@ -0,0 +1,183 @@ +/* + * Copyright 1997-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Interface Control Message Protocol Definitions. + * Per RFC 792, September 1981. + */ + +#ifndef _NETINET_IP_ICMP_H +#define _NETINET_IP_ICMP_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* ip_icmp.h 1.9 88/08/19 SMI; from UCB 7.3 12/7/87 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Structure of an icmp header. + */ +struct icmp { + uchar_t icmp_type; /* type of message, see below */ + uchar_t icmp_code; /* type sub code */ + uint16_t icmp_cksum; /* ones complement cksum of struct */ + union { + uchar_t ih_pptr; /* ICMP_PARAMPROB */ + struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ + struct ih_idseq { + uint16_t icd_id; + uint16_t icd_seq; + } ih_idseq; + int ih_void; + + /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ + struct ih_pmtu { + uint16_t ipm_void; + uint16_t ipm_nextmtu; + } ih_pmtu; + + struct ih_rtradv { + uchar_t irt_num_addrs; + uchar_t irt_wpa; + uint16_t irt_lifetime; + } ih_rtradv; + } icmp_hun; +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu + union { + struct id_ts { + n_time its_otime; + n_time its_rtime; + n_time its_ttime; + } id_ts; + struct id_ip { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + uint32_t id_mask; + char id_data[1]; + } icmp_dun; +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ + +/* + * Definition of type and code field values. + */ +#define ICMP_ECHOREPLY 0 /* echo reply */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* prohibited access */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* pred violationn */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_REDIRECT 5 /* shorter route, codes: */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ +#define ICMP_ECHO 8 /* echo service */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERADVERT_COMMON 0 /* common traffic */ +#define ICMP_ROUTERADVERT_NOCOMMON 16 /* no common traffic */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ +#define ICMP_PARAMPROB_BADLENGTH 2 /* Bad Length */ +#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 + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_ICMP_H */ diff --git a/usr/src/uts/common/netinet/ip_mroute.h b/usr/src/uts/common/netinet/ip_mroute.h new file mode 100644 index 0000000000..8a658a0fca --- /dev/null +++ b/usr/src/uts/common/netinet/ip_mroute.h @@ -0,0 +1,300 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1991, 1997-1999, 2001, 2003 Sun Microsystems, Inc. + * All rights reserved. Use is subject to license terms. + */ +/* Copyright (c) 1990 Mentat Inc. */ + +#ifndef _NETINET_IP_MROUTE_H +#define _NETINET_IP_MROUTE_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions for the kernel part of DVMRP, + * a Distance-Vector Multicast Routing Protocol. + * (See RFC-1075.) + * + * Written by David Waitzman, BBN Labs, August 1988. + * Modified by Steve Deering, Stanford, February 1989. + * Modified by Ajit Thyagarajan, PARC, August 1993. + * Modified by Ajit Thyagarajan, PARC, August 1994. + * + * MROUTING 3.5 + */ + +/* + * DVMRP-specific setsockopt commands. + */ + +#define MRT_INIT 100 /* initialize forwarder */ +#define MRT_DONE 101 /* shut down forwarder */ +#define MRT_ADD_VIF 102 /* create virtual interface */ +#define MRT_DEL_VIF 103 /* delete virtual interface */ +#define MRT_ADD_MFC 104 /* insert forwarding cache entry */ +#define MRT_DEL_MFC 105 /* delete forwarding cache entry */ +#define MRT_VERSION 106 /* get kernel version number */ +#define MRT_ASSERT 107 /* enable PIM assert processing */ + +/* + * Types and macros for handling bitmaps with one bit per virtual interface. + */ +#define MAXVIFS 32 +typedef uint_t vifbitmap_t; +typedef ushort_t vifi_t; /* type of a vif index */ +#define ALL_VIFS (vifi_t)-1 + +#define VIFM_SET(n, m) ((m) |= (1 << (n))) +#define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) +#define VIFM_ISSET(n, m) ((m) & (1 << (n))) +#define VIFM_CLRALL(m) ((m) = 0x00000000) +#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) +#define VIFM_SAME(m1, m2) ((m1) == (m2)) + + +/* + * Argument structure for MRT_ADD_VIF. Also used for netstat. + * (MRT_DEL_VIF takes a single vifi_t argument.) + */ +struct vifctl { + vifi_t vifc_vifi; /* the index of the vif to be added */ + uchar_t vifc_flags; /* VIFF_ flags defined below */ + uchar_t vifc_threshold; /* min ttl required to forward on vif */ + uint_t vifc_rate_limit; /* max rate */ + struct in_addr vifc_lcl_addr; /* local interface address */ + struct in_addr vifc_rmt_addr; /* remote address(tunnels only) */ + /* + * vifc_pkt_in/out in Solaris, to report out of the kernel. + * Not nec. in BSD. + */ + uint_t vifc_pkt_in; /* # Pkts in on interface */ + uint_t vifc_pkt_out; /* # Pkts out on interface */ +}; + +#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ +#define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */ +#define VIFF_REGISTER 0x4 /* for RPF check of PIM Register msg */ + +/* + * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC + * (mfcc_tos to be added at a future point) + */ +struct mfcctl { + struct in_addr mfcc_origin; /* ip origin of mcasts */ + struct in_addr mfcc_mcastgrp; /* multicast group associated */ + vifi_t mfcc_parent; /* incoming vif */ + uint_t mfcc_pkt_cnt; /* pkt count for src-grp */ + uchar_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ +}; + +/* + * The kernel's multicast routing statistics. + */ +struct mrtstat { + uint_t mrts_mfcfind_lookups; /* #forwarding cache table lookups */ + uint_t mrts_mfcfind_misses; /* # forwarding cache table misses */ + uint_t mrts_mfc_hits; /* forwarding pkt mfctable hits */ + uint_t mrts_mfc_misses; /* forwarding pkt mfctable misses */ + uint_t mrts_upcalls; /* # calls to mrouted */ + uint_t mrts_fwd_in; /* # packets potentially forwarded */ + uint_t mrts_fwd_out; /* # resulting outgoing packets */ + uint_t mrts_fwd_drop; /* # dropped for lack of resources */ + uint_t mrts_bad_tunnel; /* malformed tunnel options */ + uint_t mrts_cant_tunnel; /* no room for tunnel options */ + uint_t mrts_wrong_if; /* arrived on wrong interface */ + uint_t mrts_upq_ovflw; /* upcall Q overflow */ + uint_t mrts_cache_cleanups; /* # entries with no upcalls */ + uint_t mrts_drop_sel; /* pkts dropped selectively */ + uint_t mrts_q_overflow; /* pkts dropped - Q overflow */ + uint_t mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ + uint_t mrts_vifctlSize; /* Size of vifctl */ + uint_t mrts_mfcctlSize; /* Size of mfcctl */ + uint_t mrts_pim_badversion; /* dtgrms dropped - bad version */ + uint_t mrts_pim_rcv_badcsum; /* dtgrms dropped - bad checksum */ + uint_t mrts_pim_badregisters; /* dtgrms dropped - bad register pkts */ + uint_t mrts_pim_regforwards; /* dtgrms to be forwd - register pkts */ + uint_t mrts_pim_regsend_drops; /* dtgrms dropped - register send */ + uint_t mrts_pim_malformed; /* dtgrms dropped - packet malformed */ + uint_t mrts_pim_nomemory; /* dtgrms dropped - no memory to fwd. */ +}; + +/* + * Argument structure used by mrouted to get src-grp pkt counts + */ +struct sioc_sg_req { + struct in_addr src; + struct in_addr grp; + uint_t pktcnt; + uint_t bytecnt; + uint_t wrong_if; +}; + +/* + * Argument structure used by mrouted to get vif pkt counts + */ +struct sioc_vif_req { + vifi_t vifi; /* vif number */ + uint_t icount; /* Input packet count on vif */ + uint_t ocount; /* Output packet count on vif */ + uint_t ibytes; /* Input byte count on vif */ + uint_t obytes; /* Output byte count on vif */ +}; + +#ifdef _KERNEL +/* + * The kernel's virtual-interface structure. + */ +struct vif { + uchar_t v_flags; /* VIFF_ flags defined above */ + uchar_t v_threshold; /* Min ttl required to forward on vif */ + uint_t v_rate_limit; /* Max rate, in kbits/sec */ + struct tbf *v_tbf; /* Token bkt structure at intf. */ + struct in_addr v_lcl_addr; /* Local interface address */ + struct in_addr v_rmt_addr; /* Remote address(tunnels only) */ + struct ipif_s *v_ipif; /* Pointer to logical interface */ + uint_t v_pkt_in; /* # Pkts in on interface */ + uint_t v_pkt_out; /* # Pkts out on interface */ + uint_t v_bytes_in; /* # Bytes in on interface */ + uint_t v_bytes_out; /* # Bytes out on interface */ + timeout_id_t v_timeout_id; /* Qtimeout return id */ + /* + * struct route v_route; Cached route if this is a tunnel + * Used in bsd for performance + */ + uint_t v_refcnt; + uchar_t v_marks; + kmutex_t v_lock; +}; + +/* + * vif is not being used. However if refcnt != 0 than its being initalized. + */ +#define VIF_MARK_NOTINUSE 0x0 /* see comment above */ + +#define VIF_MARK_CONDEMNED 0x1 /* delete when refcnt goes to zero. */ + +#define VIF_MARK_GOOD 0x2 /* vif is good */ + +#define VIF_MARK_INUSE VIF_MARK_CONDEMNED | VIF_MARK_GOOD + +/* + * The kernel's multicast forwarding cache entry structure + * (A field for the type of service (mfc_tos) is to be added + * at a future point) + */ +struct mfc { + struct in_addr mfc_origin; /* ip origin of mcasts */ + struct in_addr mfc_mcastgrp; /* multicast group associated */ + vifi_t mfc_parent; /* incoming vif */ + uchar_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ + uint_t mfc_pkt_cnt; /* pkt count for src-grp */ + uint_t mfc_byte_cnt; /* byte count for src-grp */ + uint_t mfc_wrong_if; /* wrong if for src-grp */ + struct timespec mfc_last_assert; /* last time I sent an assert */ + struct rtdetq *mfc_rte; /* pending upcall */ + timeout_id_t mfc_timeout_id; /* qtimeout return id */ + struct mfc *mfc_next; + uchar_t mfc_marks; + kmutex_t mfc_mutex; /* protects fields and rte list */ +}; + +/* + * mfc bucket structure. + */ +struct mfcb { + struct mfc *mfcb_mfc; /* first mfc in this bucket */ + kmutex_t mfcb_lock; + uint_t mfcb_refcnt; /* protected by mfcb_lock */ + uchar_t mfcb_marks; /* protected by mfcb_lock */ +}; + +#define MFCB_MARK_CONDEMNED 0x1 + +/* + * Argument structure used for pkt info. while upcall is made + */ +struct rtdetq { + mblk_t *mp; /* A copy of the packet */ + ill_t *ill; /* Interface pkt came in on */ + struct rtdetq *rte_next; +}; +#endif + +/* + * Struct used to communicate from kernel to multicast router + * note the convenient similarity to an IP packet + */ +struct igmpmsg { + uint_t unused1; + uint_t unused2; + uchar_t im_msgtype; /* what type of message */ +#define IGMPMSG_NOCACHE 1 +#define IGMPMSG_WRONGVIF 2 +#define IGMPMSG_WHOLEPKT 3 + uchar_t im_mbz; /* must be zero */ + uchar_t im_vif; /* vif rec'd on */ + uchar_t unused3; + struct in_addr im_src, im_dst; +}; + +#ifdef _KERNEL +#define MFCTBLSIZ 256 +#if (MFCTBLSIZ & (MFCTBLSIZ - 1)) == 0 /* from sys:route.h */ +#define MFCHASHMOD(h) ((h) & (MFCTBLSIZ - 1)) +#else +#define MFCHASHMOD(h) ((h) % MFCTBLSIZ) +#endif + +#define MAX_UPQ 4 /* max. no of pkts in upcall Q */ + +/* + * Token Bucket filter code + */ +#define MAX_BKT_SIZE 10000 /* 10K bytes size */ +#define MAXQSIZE 10 /* max # of pkts in queue */ +#define TOKEN_SIZE 8 /* number of bits in token */ + +/* + * The token bucket filter at each vif + */ +struct tbf { + timespec_t tbf_last_pkt_t; /* arr. time of last pkt */ + uint_t tbf_n_tok; /* no of tokens in bucket */ + uint_t tbf_q_len; /* length of queue at this vif */ + uint_t tbf_max_q_len; /* max queue length */ + mblk_t *tbf_q; /* Packet queue */ + mblk_t *tbf_t; /* Tail-insertion pointer */ + kmutex_t tbf_lock; /* lock on the tbf */ +}; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_MROUTE_H */ diff --git a/usr/src/uts/common/netinet/ip_var.h b/usr/src/uts/common/netinet/ip_var.h new file mode 100644 index 0000000000..bebb5b55b2 --- /dev/null +++ b/usr/src/uts/common/netinet/ip_var.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1997-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Overlay for ip header used by other protocols (tcp, udp). + */ + +#ifndef _NETINET_IP_VAR_H +#define _NETINET_IP_VAR_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* ip_var.h 1.11 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#include <sys/isa_defs.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct ipovly { +#ifdef _LP64 + uint32_t ih_next, ih_prev; +#else + caddr_t ih_next, ih_prev; /* for protocol sequence q's */ +#endif + uchar_t ih_x1; /* (unused) */ + uchar_t ih_pr; /* protocol */ + short ih_len; /* protocol length */ + struct in_addr ih_src; /* source internet address */ + struct in_addr ih_dst; /* destination internet address */ +}; + +/* + * Ip reassembly queue structure. Each fragment + * being reassembled is attached to one of these structures. + * They are timed out after ipq_ttl drops to 0, and may also + * be reclaimed if memory becomes tight. + */ +struct ipq { + struct ipq *next, *prev; /* to other reass headers */ + uchar_t ipq_ttl; /* time for reass q to live */ + uchar_t ipq_p; /* protocol of this fragment */ + ushort_t ipq_id; /* sequence id for reassembly */ + struct ipasfrag *ipq_next, *ipq_prev; + /* to ip headers of fragments */ + struct in_addr ipq_src, ipq_dst; +}; + +/* + * Ip header, when holding a fragment. + * + * Note: ipf_next must be at same offset as ipq_next above + */ +struct ipasfrag { +#ifdef _BIT_FIELDS_LTOH + uchar_t ip_hl:4, + ip_v:4; +#else + uchar_t ip_v:4, + ip_hl:4; +#endif + uchar_t ipf_mff; /* copied from (ip_off&IP_MF) */ + short ip_len; + ushort_t ip_id; + short ip_off; + uchar_t ip_ttl; + uchar_t ip_p; + ushort_t ip_sum; + struct ipasfrag *ipf_next; /* next fragment */ + struct ipasfrag *ipf_prev; /* previous fragment */ +}; + +/* + * Structure stored in mbuf in inpcb.ip_options + * and passed to ip_output when ip options are in use. + * The actual length of the options (including ipopt_dst) + * is in m_len. + */ +#define MAX_IPOPTLEN 40 + +struct ipoption { + struct in_addr ipopt_dst; /* first-hop dst if source routed */ + char ipopt_list[MAX_IPOPTLEN]; /* options proper */ +}; + +struct ipstat { + long ips_total; /* total packets received */ + long ips_badsum; /* checksum bad */ + long ips_tooshort; /* packet too short */ + long ips_toosmall; /* not enough data */ + long ips_badhlen; /* ip header length < data size */ + long ips_badlen; /* ip length < ip header length */ + long ips_fragments; /* fragments received */ + long ips_fragdropped; /* frags dropped (dups, out of space) */ + long ips_fragtimeout; /* fragments timed out */ + long ips_forward; /* packets forwarded */ + long ips_cantforward; /* packets rcvd for unreachable dest */ + long ips_redirectsent; /* packets forwarded on same net */ +}; + +#ifdef _KERNEL +/* flags passed to ip_output as last parameter */ +#define IP_FORWARDING 0x1 /* most of ip header exists */ +#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ +#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_IP_VAR_H */ diff --git a/usr/src/uts/common/netinet/pim.h b/usr/src/uts/common/netinet/pim.h new file mode 100644 index 0000000000..61a5b83f4c --- /dev/null +++ b/usr/src/uts/common/netinet/pim.h @@ -0,0 +1,133 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1996-1999 by the University of Southern California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation in source and binary forms for lawful + * purposes and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both + * the copyright notice and this permission notice appear in supporting + * documentation, and that any documentation, advertising materials, + * and other materials related to such distribution and use acknowledge + * that the software was developed by the University of Southern + * California and/or Information Sciences Institute. + * The name of the University of Southern California may not + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS + * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS + * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND + * NON-INFRINGEMENT. + * + * IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, + * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, + * THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Other copyrights might apply to parts of this software and are so + * noted when applicable. + */ + +#ifndef _NETINET_PIM_H +#define _NETINET_PIM_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Protocol Independent Multicast (PIM) definitions + * + * Written by Ahmed Helmy, USC/SGI, July 1996 + * Modified by George Edmond Eddy (Rusty), ISI, February 1998 + * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 + * + * $Id: pim.h,v 1.3 1999/08/31 03:03:08 pavlin Exp $ + */ + +/* + * PIM packet format. + */ +typedef struct pim { +#ifdef _BIT_FIELDS_LTOH + uint8_t pim_type:4, /* type of PIM message */ + pim_vers:4; /* PIM version */ +#else + uint8_t pim_vers:4, /* PIM version */ + pim_type:4; /* type of PIM message */ +#endif + uint8_t pim_reserved; /* Reserved */ + uint16_t pim_cksum; /* IP-style checksum */ +} pim_t; + +#define PIM_VERSION 2 +#define PIM_MINLEN 8 /* The header min. length is 8 */ + +/* Register message + inner IPheader */ +#define PIM_REG_MINLEN (PIM_MINLEN + IP_SIMPLE_HDR_LENGTH) + +/* + * From the PIM protocol spec (RFC 2362), the following PIM message types + * are defined. All of these, except PIM_REGISTER, are currently not defined + * in the USC/ISI distributed <netinet/pim.h> include file. So they are listed + * here commented out. + * + * #define PIM_HELLO 0x0 + * #define PIM_REGISTER 0x1 + * #define PIM_REGISTER_STOP 0x2 + * #define PIM_JOIN_PRUNE 0x3 + * #define PIM_BOOTSTRAP 0x4 + * #define PIM_ASSERT 0x5 + * #define PIM_GRAFT 0x6 + * #define PIM_GRAFT_ACK 0x7 + * #define PIM_CAND_RP_ADV 0x8 + * + */ +#define PIM_REGISTER 0x1 /* PIM Register type is 1 */ + +/* + * First bit in reg_head (right after PIM header) is the Border bit. + */ +#define PIM_BORDER_REGISTER 0x80000000 + +/* + * Second bit in reg_head (right after PIM header) is the Null-Register bit + */ +#define PIM_NULL_REGISTER 0x40000000 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_PIM_H */ diff --git a/usr/src/uts/common/netinet/sctp.h b/usr/src/uts/common/netinet/sctp.h new file mode 100644 index 0000000000..7e3f1869db --- /dev/null +++ b/usr/src/uts/common/netinet/sctp.h @@ -0,0 +1,739 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _NETINET_SCTP_H +#define _NETINET_SCTP_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> + +/* + * This file contains the structure defintions and function prototypes + * described in the IETF SCTP socket API document. + */ + +/* SCTP association ID type. */ +typedef int sctp_assoc_t; +typedef int32_t sctp_assoc32_t; + +/* + * SCTP socket options + */ +#define SCTP_RTOINFO 1 +#define SCTP_ASSOCINFO 2 +#define SCTP_INITMSG 3 +#define SCTP_NODELAY 4 +#define SCTP_AUTOCLOSE 5 +#define SCTP_SET_PEER_PRIMARY_ADDR 6 +#define SCTP_PRIMARY_ADDR 7 +#define SCTP_ADAPTION_LAYER 8 +#define SCTP_DISABLE_FRAGMENTS 9 +#define SCTP_PEER_ADDR_PARAMS 10 +#define SCTP_DEFAULT_SEND_PARAM 11 +#define SCTP_EVENTS 12 +#define SCTP_I_WANT_MAPPED_V4_ADDR 13 +#define SCTP_MAXSEG 14 +#define SCTP_STATUS 15 +#define SCTP_GET_PEER_ADDR_INFO 16 + +/* + * Private socket options + */ +#define SCTP_GET_NLADDRS 17 +#define SCTP_GET_LADDRS 18 +#define SCTP_GET_NPADDRS 19 +#define SCTP_GET_PADDRS 20 +#define SCTP_ADD_ADDR 21 +#define SCTP_REM_ADDR 22 + +/* + * Additional SCTP socket options. This socket option is used to enable or + * disable PR-SCTP support prior to establishing an association. By default, + * PR-SCTP support is disabled. + */ +#define SCTP_PRSCTP 23 + +/* + * Ancillary data identifiers + */ +#define SCTP_SNDRCV 0x100 +#define SCTP_INIT 0x101 + +/* + * Notification types + */ +#define SCTP_ASSOC_CHANGE 1 +#define SCTP_PEER_ADDR_CHANGE 2 +#define SCTP_REMOTE_ERROR 3 +#define SCTP_SEND_FAILED 4 +#define SCTP_SHUTDOWN_EVENT 5 +#define SCTP_ADAPTION_INDICATION 6 +#define SCTP_PARTIAL_DELIVERY_EVENT 7 + +/* + * SCTP Ancillary Data Definitions + */ + +/* + * sctp_initmsg structure provides information for initializing new SCTP + * associations with sendmsg(). The SCTP_INITMSG socket option uses + * this same data structure. + */ +struct sctp_initmsg { + uint16_t sinit_num_ostreams; + uint16_t sinit_max_instreams; + uint16_t sinit_max_attempts; + uint16_t sinit_max_init_timeo; +}; + +/* + * sctp_sndrcvinfo structure specifies SCTP options for sendmsg() and + * describes SCTP header information about a received message through + * recvmsg(). + */ +struct sctp_sndrcvinfo { + uint16_t sinfo_stream; + uint16_t sinfo_ssn; + uint16_t sinfo_flags; + uint32_t sinfo_ppid; + uint32_t sinfo_context; + uint32_t sinfo_timetolive; + uint32_t sinfo_tsn; + uint32_t sinfo_cumtsn; + sctp_assoc_t sinfo_assoc_id; +}; + +/* sinfo_flags */ +#define MSG_UNORDERED 0x01 /* Unordered data */ +#define MSG_ABORT 0x02 /* Abort the connection */ +#define MSG_EOF 0x04 /* Shutdown the connection */ + +/* + * Use destination addr passed as parameter, not the association primary one. + */ +#define MSG_ADDR_OVER 0x08 +/* + * This flag when set in sinfo_flags is used alongwith sinfo_timetolive to + * implement the "timed reliability" service discussed in RFC 3758. + */ +#define MSG_PR_SCTP 0x10 +/* + * SCTP notification definitions + */ + +/* + * To receive any ancillary data or notifications, the application can + * register it's interest by calling the SCTP_EVENTS setsockopt() with + * the sctp_event_subscribe structure. + */ +struct sctp_event_subscribe { + uint8_t sctp_data_io_event; + uint8_t sctp_association_event; + uint8_t sctp_address_event; + uint8_t sctp_send_failure_event; + uint8_t sctp_peer_error_event; + uint8_t sctp_shutdown_event; + uint8_t sctp_partial_delivery_event; + uint8_t sctp_adaption_layer_event; +}; + +/* Association events used in sctp_assoc_change structure */ +#define SCTP_COMM_UP 0 +#define SCTP_COMM_LOST 1 +#define SCTP_RESTART 2 +#define SCTP_SHUTDOWN_COMP 3 +#define SCTP_CANT_STR_ASSOC 4 + +/* + * Association flags. This flags is filled in the sac_flags for a SCTP_COMM_UP + * event if the association supports PR-SCTP. + */ +#define SCTP_PRSCTP_CAPABLE 0x01 + +/* + * sctp_assoc_change notification informs the socket that an SCTP association + * has either begun or ended. The identifier for a new association is + * provided by this notification. + */ +struct sctp_assoc_change { + uint16_t sac_type; + uint16_t sac_flags; + uint32_t sac_length; + uint16_t sac_state; + uint16_t sac_error; + uint16_t sac_outbound_streams; + uint16_t sac_inbound_streams; + sctp_assoc_t sac_assoc_id; + /* + * The assoc ID can be followed by the ABORT chunk if available. + */ +}; + +/* + * A remote peer may send an Operational Error message to its peer. This + * message indicates a variety of error conditions on an association. + * The entire ERROR chunk as it appears on the wire is included in a + * SCTP_REMOTE_ERROR event. Refer to the SCTP specification RFC2960 + * and any extensions for a list of possible error formats. + */ +struct sctp_remote_error { + uint16_t sre_type; + uint16_t sre_flags; + uint32_t sre_length; + uint16_t sre_error; + sctp_assoc_t sre_assoc_id; + /* + * The assoc ID is followed by the actual error chunk. + */ +}; + +/* + * Note: + * + * In order to keep the offsets and size of the structure having a + * struct sockaddr_storage field the same between a 32-bit application + * and a 64-bit amd64 kernel, we use a #pragma pack(4) for those + * structures. + */ +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* Address change event state */ +#define SCTP_ADDR_AVAILABLE 0 +#define SCTP_ADDR_UNREACHABLE 1 +#define SCTP_ADDR_REMOVED 2 +#define SCTP_ADDR_ADDED 3 +#define SCTP_ADDR_MADE_PRIM 4 + +/* + * When a destination address on a multi-homed peer encounters a change, + * an interface details event, sctp_paddr_change, is sent to the socket. + */ +struct sctp_paddr_change { + uint16_t spc_type; + uint16_t spc_flags; + uint32_t spc_length; + struct sockaddr_storage spc_aaddr; + int spc_state; + int spc_error; + sctp_assoc_t spc_assoc_id; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* flags used in sctp_send_failed notification. */ +#define SCTP_DATA_UNSENT 1 +#define SCTP_DATA_SENT 2 + +/* + * If SCTP cannot deliver a message it may return the message as a + * notification using the following structure. + */ +struct sctp_send_failed { + uint16_t ssf_type; + uint16_t ssf_flags; + uint32_t ssf_length; + uint32_t ssf_error; + struct sctp_sndrcvinfo ssf_info; + sctp_assoc_t ssf_assoc_id; + /* + * The assoc ID is followed by the failed message. + */ +}; + +/* + * When a peer sends a SHUTDOWN, SCTP delivers the sctp_shutdown_event + * notification to inform the socket user that it should cease sending data. + */ +struct sctp_shutdown_event { + uint16_t sse_type; + uint16_t sse_flags; + uint16_t sse_length; + sctp_assoc_t sse_assoc_id; +}; + +/* + * When a peer sends an Adaption Layer Indication parameter, SCTP + * delivers the sctp_adaption_event notification to inform the socket + * user the peer's requested adaption layer. + */ +struct sctp_adaption_event { + uint16_t sai_type; + uint16_t sai_flags; + uint32_t sai_length; + uint32_t sai_adaption_ind; + sctp_assoc_t sai_assoc_id; +}; + +/* Possible values in pdapi_indication for sctp_pdapi_event notification. */ +#define SCTP_PARTIAL_DELIVERY_ABORTED 1 + +/* + * When a receiver is engaged in a partial delivery of a message the + * sctp_pdapi_event notification is used to indicate various events. + */ +struct sctp_pdapi_event { + uint16_t pdapi_type; + uint16_t pdapi_flags; + uint32_t pdapi_length; + uint32_t pdapi_indication; + sctp_assoc_t pdapi_assoc_id; +}; + +/* + * The sctp_notification structure is defined as the union of all + * notification types defined above. + */ +union sctp_notification { + struct { + uint16_t sn_type; /* Notification type. */ + uint16_t sn_flags; + uint32_t sn_length; + } sn_header; + struct sctp_assoc_change sn_assoc_change; + struct sctp_paddr_change sn_paddr_change; + struct sctp_remote_error sn_remote_error; + struct sctp_send_failed sn_send_failed; + struct sctp_shutdown_event sn_shutdown_event; + struct sctp_adaption_event sn_adaption_event; + struct sctp_pdapi_event sn_pdapi_event; +}; + +/* + * sctp_opt_info() option definitions + */ + +/* + * The protocol parameters used to initialize and bound retransmission + * timeout (RTO) are tunable. See RFC2960 for more information on + * how these parameters are used in RTO calculation. + * + * The sctp_rtoinfo structure is used to access and modify these + * parameters. + */ +struct sctp_rtoinfo { + sctp_assoc_t srto_assoc_id; + uint32_t srto_initial; + uint32_t srto_max; + uint32_t srto_min; +}; + +/* + * The sctp_assocparams option is used to both examine and set various + * association and endpoint parameters. See RFC2960 for more information + * on how this parameter is used. The peer address parameter is ignored + * for one-to-one style socket. + */ +struct sctp_assocparams { + sctp_assoc_t sasoc_assoc_id; + uint16_t sasoc_asocmaxrxt; + uint16_t sasoc_number_peer_destinations; + uint32_t sasoc_peer_rwnd; + uint32_t sasoc_local_rwnd; + uint32_t sasoc_cookie_life; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) +#endif + +/* sctp_paddrinfo reachability state. */ +#define SCTP_INACTIVE 1 +#define SCTP_ACTIVE 2 + +/* + * Applications can retrieve information about a specific peer address + * of an association, including its reachability state, congestion + * window, and retransmission timer values. This information is + * read-only. The sctp_paddrinfo structure is used to access this + * information: + */ +struct sctp_paddrinfo { + sctp_assoc_t spinfo_assoc_id; + struct sockaddr_storage spinfo_address; + int32_t spinfo_state; + uint32_t spinfo_cwnd; + uint32_t spinfo_srtt; + uint32_t spinfo_rto; + uint32_t spinfo_mtu; +}; + +/* + * Applications can enable or disable heartbeats for any peer address of + * an association, modify an address's heartbeat interval, force a + * heartbeat to be sent immediately, and adjust the address's maximum + * number of retransmissions sent before an address is considered + * unreachable. The sctp_paddrparams structure is used to access and modify + * an address' parameters. + */ +struct sctp_paddrparams { + sctp_assoc_t spp_assoc_id; + struct sockaddr_storage spp_address; + uint32_t spp_hbinterval; + uint16_t spp_pathmaxrxt; +}; + +/* + * A socket user can request that the peer mark the enclosed address as the + * association's primary. The enclosed address must be one of the + * association's locally bound addresses. The sctp_setpeerprim structure is + * used to make such request. + */ +struct sctp_setpeerprim { + sctp_assoc_t sspp_assoc_id; + struct sockaddr_storage sspp_addr; +}; + +/* + * A socket user can request that the local SCTP stack use the enclosed peer + * address as the association primary. The enclosed address must be one of + * the association peer's addresses. The sctp_setprim structure is used to + * make such request. + */ +struct sctp_setprim { + sctp_assoc_t ssp_assoc_id; + struct sockaddr_storage ssp_addr; +}; + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif + +/* SCTP association states */ +#define SCTPS_IDLE -5 /* idle (opened, but not bound) */ +#define SCTPS_BOUND -4 /* bound, ready to connect or accept */ +#define SCTPS_LISTEN -3 /* listening for connection */ +#define SCTPS_COOKIE_WAIT -2 +#define SCTPS_COOKIE_ECHOED -1 +/* states < SCTPS_ESTABLISHED are those where connections not established */ +#define SCTPS_ESTABLISHED 0 /* established */ +#define SCTPS_SHUTDOWN_PENDING 1 +#define SCTPS_SHUTDOWN_SENT 2 +#define SCTPS_SHUTDOWN_RECEIVED 3 +#define SCTPS_SHUTDOWN_ACK_SENT 4 + +/* + * Applications can retrieve current status information about an + * association, including association state, peer receiver window size, + * number of unacked data chunks, and number of data chunks pending + * receipt. This information is read-only. The sctp_status structure is + * used to access this information: + */ +struct sctp_status { + sctp_assoc_t sstat_assoc_id; + int32_t sstat_state; + uint32_t sstat_rwnd; + uint16_t sstat_unackdata; + uint16_t sstat_penddata; + uint16_t sstat_instrms; + uint16_t sstat_outstrms; + uint32_t sstat_fragmentation_point; + struct sctp_paddrinfo sstat_primary; +}; + +/* Possible values for sstat_state */ +#define SCTP_CLOSED SCTPS_IDLE +#define SCTP_BOUND SCTPS_BOUND +#define SCTP_LISTEN SCTPS_LISTEN +#define SCTP_COOKIE_WAIT SCTPS_COOKIE_WAIT +#define SCTP_COOKIE_ECHOED SCTPS_COOKIE_ECHOED +#define SCTP_ESTABLISHED SCTPS_ESTABLISHED +#define SCTP_SHUTDOWN_PENDING SCTPS_SHUTDOWN_PENDING +#define SCTP_SHUTDOWN_SENT SCTPS_SHUTDOWN_SENT +#define SCTP_SHUTDOWN_RECEIVED SCTPS_SHUTDOWN_RECEIVED +#define SCTP_SHUTDOWN_ACK_SENT SCTPS_SHUTDOWN_ACK_SENT + +/* + * A socket user can request that the local endpoint set the specified + * Adaption Layer Indication parameter for all future INIT and INIT-ACK + * exchanges. The sctp_setadaption structure is used to make such request. + */ +struct sctp_setadaption { + uint32_t ssb_adaption_ind; +}; + +/* + * Private ioctl option structure + */ +struct sctpopt { + sctp_assoc_t sopt_aid; + int sopt_name; + uint_t sopt_len; + caddr_t sopt_val; +}; + +#if defined(_SYSCALL32) +struct sctpopt32 { + sctp_assoc32_t sopt_aid; + int32_t sopt_name; + uint32_t sopt_len; + caddr32_t sopt_val; +}; +#endif /* _SYSCALL32 */ + +/* Forward Cumulative TSN chunk entry. */ +typedef struct ftsn_entry_s { + uint16_t ftsn_sid; + uint16_t ftsn_ssn; +} ftsn_entry_t; + +/* + * New socket functions for SCTP + */ + +/* sctp_bindx() operations. */ +#define SCTP_BINDX_ADD_ADDR 1 +#define SCTP_BINDX_REM_ADDR 2 + +#if !defined(_KERNEL) || defined(_BOOT) +#ifdef __STDC__ +extern int sctp_bindx(int, void *, int, int); +extern void sctp_freeladdrs(void *); +extern void sctp_freepaddrs(void *); +extern int sctp_getladdrs(int, sctp_assoc_t, void **); +extern int sctp_getpaddrs(int, sctp_assoc_t, void **); +extern int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *); +extern int sctp_peeloff(int, sctp_assoc_t); +extern ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *, + socklen_t *, struct sctp_sndrcvinfo *, int *msg_flags); +extern ssize_t sctp_send(int, const void *, size_t, + const struct sctp_sndrcvinfo *, int); +extern ssize_t sctp_sendmsg(int, const void *, size_t, const struct sockaddr *, + socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t); +#else /* __STDC__ */ +extern int sctp_bindx(); +extern void sctp_freeladdrs(); +extern void sctp_freepaddrs(); +extern int sctp_getladdrs(); +extern int sctp_getpaddrs(); +extern int sctp_opt_info(); +extern int sctp_peeloff(); +extern ssize_t sctp_recvmsg(); +extern ssize_t sctp_send(); +extern ssize_t sctp_sendmsg(); +#endif /* __STDC__ */ +#endif /* !defined(_KERNEL) || defined(_BOOT) */ + + +/* + * SCTP protocol related elements. + */ + +/* All SCTP chunks and parameters are 32-bit aligned */ +#define SCTP_ALIGN 4 + +/* + * Data chunk bit manipulations + */ +#define SCTP_DATA_EBIT 0x01 +#define SCTP_TBIT 0x01 +#define SCTP_DATA_BBIT 0x02 +#define SCTP_DATA_UBIT 0x04 + +#define SCTP_DATA_GET_BBIT(sdc) ((sdc)->sdh_flags & SCTP_DATA_BBIT) +#define SCTP_GET_TBIT(cp) ((cp)->sch_flags & SCTP_TBIT) +#define SCTP_DATA_GET_EBIT(sdc) ((sdc)->sdh_flags & SCTP_DATA_EBIT) +#define SCTP_DATA_GET_UBIT(sdc) ((sdc)->sdh_flags & SCTP_DATA_UBIT) + +#define SCTP_DATA_SET_BBIT(sdc) ((sdc)->sdh_flags |= SCTP_DATA_BBIT) +#define SCTP_SET_TBIT(cp) ((cp)->sch_flags |= SCTP_TBIT) +#define SCTP_DATA_SET_EBIT(sdc) ((sdc)->sdh_flags |= SCTP_DATA_EBIT) +#define SCTP_DATA_SET_UBIT(sdc) ((sdc)->sdh_flags |= SCTP_DATA_UBIT) + +/* SCTP common header */ +typedef struct sctp_hdr { + uint16_t sh_sport; + uint16_t sh_dport; + uint32_t sh_verf; + uint32_t sh_chksum; +} sctp_hdr_t; + +/* Chunk IDs */ +typedef enum { + CHUNK_DATA, + CHUNK_INIT, + CHUNK_INIT_ACK, + CHUNK_SACK, + CHUNK_HEARTBEAT, + CHUNK_HEARTBEAT_ACK, + CHUNK_ABORT, + CHUNK_SHUTDOWN, + CHUNK_SHUTDOWN_ACK, + CHUNK_ERROR, + CHUNK_COOKIE, + CHUNK_COOKIE_ACK, + CHUNK_ECNE, + CHUNK_CWR, + CHUNK_SHUTDOWN_COMPLETE, + CHUNK_ASCONF_ACK = 128, + CHUNK_FORWARD_TSN = 192, + CHUNK_ASCONF = 193 +} sctp_chunk_id_t; + +/* Common chunk header */ +typedef struct sctp_chunk_hdr { + uint8_t sch_id; + uint8_t sch_flags; + uint16_t sch_len; +} sctp_chunk_hdr_t; + +/* INIT chunk data definition */ +typedef struct sctp_init_chunk { + uint32_t sic_inittag; + uint32_t sic_a_rwnd; + uint16_t sic_outstr; + uint16_t sic_instr; + uint32_t sic_inittsn; +} sctp_init_chunk_t; + +/* SCTP DATA chunk */ +typedef struct sctp_data_chunk { + uint32_t sdc_tsn; + uint16_t sdc_sid; + uint16_t sdc_ssn; + uint32_t sdc_payload_id; +} sctp_data_chunk_t; + +/* sctp_data_hdr includes the SCTP chunk hdr and the DATA chunk */ +typedef struct sctp_data_hdr { + sctp_chunk_hdr_t sdh_chdr; + sctp_data_chunk_t sdh_data; +#define sdh_id sdh_chdr.sch_id +#define sdh_flags sdh_chdr.sch_flags +#define sdh_len sdh_chdr.sch_len +#define sdh_tsn sdh_data.sdc_tsn +#define sdh_sid sdh_data.sdc_sid +#define sdh_ssn sdh_data.sdc_ssn +#define sdh_payload_id sdh_data.sdc_payload_id +} sctp_data_hdr_t; + +typedef struct sctp_sack_chunk { + uint32_t ssc_cumtsn; + uint32_t ssc_a_rwnd; + uint16_t ssc_numfrags; + uint16_t ssc_numdups; +} sctp_sack_chunk_t; + +typedef struct sctp_sack_frag { + uint16_t ssf_start; + uint16_t ssf_end; +} sctp_sack_frag_t; + +/* Parameter types */ +#define PARM_UNKNOWN 0 +#define PARM_HBINFO 1 +#define PARM_ADDR4 5 +#define PARM_ADDR6 6 +#define PARM_COOKIE 7 +#define PARM_UNRECOGNIZED 8 +#define PARM_COOKIE_PRESERVE 9 +#define PARM_ADDR_HOST_NAME 11 +#define PARM_SUPP_ADDRS 12 +#define PARM_ECN 0x8000 +#define PARM_ECN_CAPABLE PARM_ECN +#define PARM_FORWARD_TSN 0xc000 +#define PARM_ADD_IP 0xc001 +#define PARM_DEL_IP 0xc002 +#define PARM_ERROR_IND 0xc003 +#define PARM_ASCONF_ERROR PARM_ERROR_IND +#define PARM_SET_PRIMARY 0xc004 +#define PARM_PRIMARY_ADDR PARM_SET_PRIMARY +#define PARM_SUCCESS 0xc005 +#define PARM_ASCONF_SUCCESS PARM_SUCCESS +#define PARM_ADAPT_LAYER_IND 0xc006 + + +/* Lengths from SCTP spec */ +#define PARM_ADDR4_LEN 8 +#define PARM_ADDR6_LEN 20 + +/* Parameter header */ +typedef struct sctp_parm_hdr { + uint16_t sph_type; + uint16_t sph_len; +} sctp_parm_hdr_t; + +/* Error causes */ +#define SCTP_ERR_UNKNOWN 0 +#define SCTP_ERR_BAD_SID 1 +#define SCTP_ERR_MISSING_PARM 2 +#define SCTP_ERR_STALE_COOKIE 3 +#define SCTP_ERR_NO_RESOURCES 4 +#define SCTP_ERR_BAD_ADDR 5 +#define SCTP_ERR_UNREC_CHUNK 6 +#define SCTP_ERR_BAD_MANDPARM 7 +#define SCTP_ERR_UNREC_PARM 8 +#define SCTP_ERR_NO_USR_DATA 9 +#define SCTP_ERR_COOKIE_SHUT 10 +#define SCTP_ERR_RESTART_NEW_ADDRS 11 +#define SCTP_ERR_USER_ABORT 12 +#define SCTP_ERR_DELETE_LASTADDR 256 +#define SCTP_ERR_RESOURCE_SHORTAGE 257 +#define SCTP_ERR_DELETE_SRCADDR 258 +#define SCTP_ERR_AUTH_ERR 260 + +/* + * Extensions + */ + +/* Extended Chunk Types */ +#define CHUNK_ASCONF 0xc1 +#define CHUNK_ASCONF_ACK 0x80 + +/* Extension Error Causes */ +#define SCTP_ERR_DEL_LAST_ADDR 0x0100 +#define SCTP_ERR_RES_SHORTAGE 0x0101 +#define SCTP_ERR_DEL_SRC_ADDR 0x0102 +#define SCTP_ERR_ILLEGAL_ACK 0x0103 +#define SCTP_ERR_UNAUTHORIZED 0x0104 + +typedef struct sctp_addip4 { + sctp_parm_hdr_t sad4_addip_ph; + uint32_t asconf_req_cid; + sctp_parm_hdr_t sad4_addr4_ph; + ipaddr_t sad4_addr; +} sctp_addip4_t; + +typedef struct sctp_addip6 { + sctp_parm_hdr_t sad6_addip_ph; + uint32_t asconf_req_cid; + sctp_parm_hdr_t sad6_addr6_ph; + in6_addr_t sad6_addr; +} sctp_addip6_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_SCTP_H */ diff --git a/usr/src/uts/common/netinet/tcp.h b/usr/src/uts/common/netinet/tcp.h new file mode 100644 index 0000000000..046015d7c9 --- /dev/null +++ b/usr/src/uts/common/netinet/tcp.h @@ -0,0 +1,110 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcp.h 1.11 88/08/19 SMI; from UCB 7.2 10/28/86 */ + + +#include <sys/isa_defs.h> +#include <sys/inttypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t tcp_seq; +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr { + uint16_t th_sport; /* source port */ + uint16_t th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#ifdef _BIT_FIELDS_LTOH + uint_t th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#else + uint_t th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + uchar_t th_flags; +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 + uint16_t th_win; /* window */ + uint16_t th_sum; /* checksum */ + uint16_t th_urp; /* urgent pointer */ +}; + +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOPT_WSCALE 3 +#define TCPOPT_SACK_PERMITTED 4 +#define TCPOPT_SACK 5 +#define TCPOPT_TSTAMP 8 + +/* + * Default maximum segment size for TCP. + * With an IP MTU of 576, this is 536. + */ +#define TCP_MSS 536 + +/* + * Options for use with [gs]etsockopt at the TCP level. + * + * Note: Some of the TCP_ namespace has conflict with and + * and is exposed through <xti.h>. (It also requires exposing + * options not implemented). The options with potential + * for conflicts use #ifndef guards. + */ +#ifndef TCP_NODELAY +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#endif + +#ifndef TCP_MAXSEG +#define TCP_MAXSEG 0x02 /* set maximum segment size */ +#endif + +#ifndef TCP_KEEPALIVE +#define TCP_KEEPALIVE 0x8 /* set keepalive timer */ +#endif + + +#define TCP_NOTIFY_THRESHOLD 0x10 +#define TCP_ABORT_THRESHOLD 0x11 +#define TCP_CONN_NOTIFY_THRESHOLD 0x12 +#define TCP_CONN_ABORT_THRESHOLD 0x13 +#define TCP_RECVDSTADDR 0x14 +#define TCP_INIT_CWND 0x15 +#define TCP_KEEPALIVE_THRESHOLD 0x16 +#define TCP_KEEPALIVE_ABORT_THRESHOLD 0x17 +#define TCP_CORK 0x18 + +/* gap for expansion of ``standard'' options */ +#define TCP_ANONPRIVBIND 0x20 /* for internal use only */ +#define TCP_EXCLBIND 0x21 /* for internal use only */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_H */ diff --git a/usr/src/uts/common/netinet/tcp_debug.h b/usr/src/uts/common/netinet/tcp_debug.h new file mode 100644 index 0000000000..6b6f247d0e --- /dev/null +++ b/usr/src/uts/common/netinet/tcp_debug.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_TCP_DEBUG_H +#define _NETINET_TCP_DEBUG_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcp_debug.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct tcp_debug { + n_time td_time; + short td_act; + short td_ostate; + caddr_t td_tcb; + struct tcpiphdr td_ti; + short td_req; + struct tcpcb td_cb; +}; + +#define TA_INPUT 0 +#define TA_OUTPUT 1 +#define TA_USER 2 +#define TA_RESPOND 3 +#define TA_DROP 4 + +#ifdef TANAMES +char *tanames[] = + { "input", "output", "user", "respond", "drop" }; +#endif + +#define TCP_NDEBUG 100 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_DEBUG_H */ diff --git a/usr/src/uts/common/netinet/tcp_fsm.h b/usr/src/uts/common/netinet/tcp_fsm.h new file mode 100644 index 0000000000..af8352bd54 --- /dev/null +++ b/usr/src/uts/common/netinet/tcp_fsm.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * TCP FSM state definitions. + * Per RFC793, September, 1981. + */ + +#ifndef _NETINET_TCP_FSM_H +#define _NETINET_TCP_FSM_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcp_fsm.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define TCP_NSTATES 11 + +#define TCPS_CLOSED 0 /* closed */ +#define TCPS_LISTEN 1 /* listening for connection */ +#define TCPS_SYN_SENT 2 /* active, have sent syn */ +#define TCPS_SYN_RECEIVED 3 /* have send and received syn */ +/* states < TCPS_ESTABLISHED are those where connections not established */ +#define TCPS_ESTABLISHED 4 /* established */ +#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ +/* states > TCPS_CLOSE_WAIT are those where user has closed */ +#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ +#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ +#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ +/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ +#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ +#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ + +#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) +#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT) + +#ifdef TCPOUTFLAGS +/* + * Flags used when sending segments in tcp_output. + * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally + * determined by state, with the proviso that TH_FIN is sent only + * if all data queued for output is included in the segment. + */ +uchar_t tcp_outflags[TCP_NSTATES] = { + TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK, + TH_ACK, TH_ACK, + TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK, +}; +#endif + +#ifdef KPROF +int tcp_acounts[TCP_NSTATES][PRU_NREQ]; +#endif + +#ifdef TCPSTATES +char *tcpstates[] = { + "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", + "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", + "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT", +}; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_FSM_H */ diff --git a/usr/src/uts/common/netinet/tcp_seq.h b/usr/src/uts/common/netinet/tcp_seq.h new file mode 100644 index 0000000000..1d9bf8935a --- /dev/null +++ b/usr/src/uts/common/netinet/tcp_seq.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _NETINET_TCP_SEQ_H +#define _NETINET_TCP_SEQ_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcp_seq.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/85 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * TCP sequence numbers are 32 bit integers operated + * on with modular arithmetic. These macros can be + * used to compare such integers. + */ +#define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) +#define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) +#define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) +#define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) + +/* + * Macros to initialize tcp sequence numbers for + * send and receive from initial send and receive + * sequence numbers. + */ +#define tcp_rcvseqinit(tp) \ + (tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1 + +#define tcp_sendseqinit(tp) \ + (tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \ + (tp)->iss + +#define TCP_ISSINCR (125*1024) /* increment for tcp_iss each second */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_SEQ_H */ diff --git a/usr/src/uts/common/netinet/tcp_timer.h b/usr/src/uts/common/netinet/tcp_timer.h new file mode 100644 index 0000000000..e19bb3ce85 --- /dev/null +++ b/usr/src/uts/common/netinet/tcp_timer.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + */ + +/* + * Definitions of the TCP timers. These timers are counted + * down PR_SLOWHZ times a second. + */ + +#ifndef _NETINET_TCP_TIMER_H +#define _NETINET_TCP_TIMER_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcp_timer.h 1.13 89/06/16 SMI; from UCB 7.6 6/29/88 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define TCPT_NTIMERS 4 + +#define TCPT_REXMT 0 /* retransmit */ +#define TCPT_PERSIST 1 /* retransmit persistance */ +#define TCPT_KEEP 2 /* keep alive */ +#define TCPT_2MSL 3 /* 2*msl quiet time timer */ + +/* + * The TCPT_REXMT timer is used to force retransmissions. + * The TCP has the TCPT_REXMT timer set whenever segments + * have been sent for which ACKs are expected but not yet + * received. If an ACK is received which advances tp->snd_una, + * then the retransmit timer is cleared (if there are no more + * outstanding segments) or reset to the base value (if there + * are more ACKs expected). Whenever the retransmit timer goes off, + * we retransmit one unacknowledged segment, and do a backoff + * on the retransmit timer. + * + * The TCPT_PERSIST timer is used to keep window size information + * flowing even if the window goes shut. If all previous transmissions + * have been acknowledged (so that there are no retransmissions in progress), + * and the window is too small to bother sending anything, then we start + * the TCPT_PERSIST timer. When it expires, if the window is nonzero, + * we go to transmit state. Otherwise, at intervals send a single byte + * into the peer's window to force him to update our window information. + * We do this at most as often as TCPT_PERSMIN time intervals, + * but no more frequently than the current estimate of round-trip + * packet time. The TCPT_PERSIST timer is cleared whenever we receive + * a window update from the peer. + * + * The TCPT_KEEP timer is used to keep connections alive. If a + * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time, + * but not yet established, then we drop the connection. Once the connection + * is established, if the connection is idle for TCPTV_KEEP_IDLE time + * (and keepalives have been enabled on the socket), we begin to probe + * the connection. We force the peer to send us a segment by sending: + * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> + * This segment is (deliberately) outside the window, and should elicit + * an ack segment in response from the peer. If, despite the TCPT_KEEP + * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE + * amount of time probing, then we drop the connection. + */ + +#define TCP_TTL 60 /* default time to live for TCP segs */ +/* + * Time constants. + */ +#define TCPTV_MSL (30*PR_SLOWHZ) /* max seg lifetime (hah!) */ +#define TCPTV_SRTTBASE 0 /* base roundtrip time; */ + /* if 0, no idea yet */ +#define TCPTV_SRTTDFLT (3*PR_SLOWHZ) /* assumed RTT if no info */ + +#define TCPTV_PERSMIN (5*PR_SLOWHZ) /* retransmit persistance */ +#define TCPTV_PERSMAX (60*PR_SLOWHZ) /* maximum persist interval */ + +#define TCPTV_KEEP_INIT (75*PR_SLOWHZ) /* initial connect keep alive */ +#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */ +#define TCPTV_KEEPINTVL (75*PR_SLOWHZ) /* default probe interval */ +#define TCPTV_KEEPCNT 8 /* max probes before drop */ + +#define TCPTV_MIN (1*PR_SLOWHZ) /* minimum allowable value */ +#define TCPTV_REXMTMAX (64*PR_SLOWHZ) /* max allowable REXMT value */ + +#define TCP_LINGERTIME 120 /* linger at most 2 minutes */ + +#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ + +#ifdef TCPTIMERS +char *tcptimers[] = + { "REXMT", "PERSIST", "KEEP", "2MSL" }; +#endif + +/* + * Force a time value to be in a certain range. + */ +#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ + (tv) = (value); \ + if ((tv) < (tvmin)) \ + (tv) = (tvmin); \ + else if ((tv) > (tvmax)) \ + (tv) = (tvmax); \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_TIMER_H */ diff --git a/usr/src/uts/common/netinet/tcp_var.h b/usr/src/uts/common/netinet/tcp_var.h new file mode 100644 index 0000000000..636ffca6ee --- /dev/null +++ b/usr/src/uts/common/netinet/tcp_var.h @@ -0,0 +1,162 @@ +/* + * Copyright (c) 1997-1998 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Kernel variables for tcp. + */ + +#ifndef _NETINET_TCP_VAR_H +#define _NETINET_TCP_VAR_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcp_var.h 1.11 88/08/19 SMI; from UCB 7.3 6/30/87 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Tcp control block, one per tcp; fields: + */ +struct tcpcb { + struct tcpiphdr *seg_next; /* sequencing queue */ + struct tcpiphdr *seg_prev; + short t_state; /* state of this connection */ + short t_timer[TCPT_NTIMERS]; /* tcp timers */ + short t_rxtshift; /* log(2) of rexmt exp. backoff */ + short t_rxtcur; /* current retransmit value */ + short t_dupacks; /* consecutive dup acks recd */ + ushort_t t_maxseg; /* maximum segment size */ + char t_force; /* 1 if forcing out a byte */ + uchar_t t_flags; +#define TF_ACKNOW 0x01 /* ack peer immediately */ +#define TF_DELACK 0x02 /* ack, but try to delay it */ +#define TF_NODELAY 0x04 /* don't delay packets to coalesce */ +#define TF_NOOPT 0x08 /* don't use tcp options */ +#define TF_SENTFIN 0x10 /* have sent FIN */ + struct tcpiphdr *t_template; /* skeletal packet for transmit */ + struct inpcb *t_inpcb; /* back pointer to internet pcb */ +/* + * The following fields are used as in the protocol specification. + * See RFC783, Dec. 1981, page 21. + */ +/* send sequence variables */ + tcp_seq snd_una; /* send unacknowledged */ + tcp_seq snd_nxt; /* send next */ + tcp_seq snd_up; /* send urgent pointer */ + tcp_seq snd_wl1; /* window update seg seq number */ + tcp_seq snd_wl2; /* window update seg ack number */ + tcp_seq iss; /* initial send sequence number */ + ushort_t snd_wnd; /* send window */ +/* receive sequence variables */ + ushort_t rcv_wnd; /* receive window */ + tcp_seq rcv_nxt; /* receive next */ + tcp_seq rcv_up; /* receive urgent pointer */ + tcp_seq irs; /* initial receive sequence number */ +/* + * Additional variables for this implementation. + */ +/* receive variables */ + tcp_seq rcv_adv; /* advertised window */ +/* retransmit variables */ + tcp_seq snd_max; /* highest sequence number sent */ + /* used to recognize retransmits */ + +/* congestion control (for slow start, source quench, retransmit after loss) */ + ushort_t snd_cwnd; /* congestion-controlled window */ + ushort_t snd_ssthresh; /* snd_cwnd size threshhold for */ + /* for slow start exponential to */ +/* + * transmit timing stuff. + * srtt and rttvar are stored as fixed point; for convenience in smoothing, + * srtt has 3 bits to the right of the binary point, rttvar has 2. + * "Variance" is actually smoothed difference. + */ + short t_idle; /* inactivity time */ + short t_rtt; /* round trip time */ + tcp_seq t_rtseq; /* sequence number being timed */ + short t_srtt; /* smoothed round-trip time */ + short t_rttvar; /* variance in round-trip time */ + ushort_t max_rcvd; /* most peer has sent into window */ + ushort_t max_sndwnd; /* largest window peer has offered */ +/* out-of-band data */ + char t_oobflags; /* have some */ + char t_iobc; /* input character */ +#define TCPOOB_HAVEDATA 0x01 +#define TCPOOB_HADDATA 0x02 +}; + +#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) +#define sototcpcb(so) (intotcpcb(sotoinpcb(so))) + +/* + * TCP statistics. + * Many of these should be kept per connection, + * but that's inconvenient at the moment. + */ +struct tcpstat { + uint_t tcps_connattempt; /* connections initiated */ + uint_t tcps_accepts; /* connections accepted */ + uint_t tcps_connects; /* connections established */ + uint_t tcps_drops; /* connections dropped */ + uint_t tcps_conndrops; /* embryonic connections dropped */ + uint_t tcps_closed; /* conn. closed (includes drops) */ + uint_t tcps_segstimed; /* segs where we tried to get rtt */ + uint_t tcps_rttupdated; /* times we succeeded */ + uint_t tcps_delack; /* delayed acks sent */ + uint_t tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ + uint_t tcps_rexmttimeo; /* retransmit timeouts */ + uint_t tcps_persisttimeo; /* persist timeouts */ + uint_t tcps_keeptimeo; /* keepalive timeouts */ + uint_t tcps_keepprobe; /* keepalive probes sent */ + uint_t tcps_keepdrops; /* connections dropped in keepalive */ + + uint_t tcps_sndtotal; /* total packets sent */ + uint_t tcps_sndpack; /* data packets sent */ + uint_t tcps_sndbyte; /* data bytes sent */ + uint_t tcps_sndrexmitpack; /* data packets retransmitted */ + uint_t tcps_sndrexmitbyte; /* data bytes retransmitted */ + uint_t tcps_sndacks; /* ack-only packets sent */ + uint_t tcps_sndprobe; /* window probes sent */ + uint_t tcps_sndurg; /* packets sent with URG only */ + uint_t tcps_sndwinup; /* window update-only packets sent */ + uint_t tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ + + uint_t tcps_rcvtotal; /* total packets received */ + uint_t tcps_rcvpack; /* packets received in sequence */ + uint_t tcps_rcvbyte; /* bytes received in sequence */ + uint_t tcps_rcvbadsum; /* packets received with ccksum errs */ + uint_t tcps_rcvbadoff; /* packets received with bad offset */ + uint_t tcps_rcvshort; /* packets received too short */ + uint_t tcps_rcvduppack; /* duplicate-only packets received */ + uint_t tcps_rcvdupbyte; /* duplicate-only bytes received */ + uint_t tcps_rcvpartduppack; /* packets with some duplicate data */ + uint_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ + uint_t tcps_rcvoopack; /* out-of-order packets received */ + uint_t tcps_rcvoobyte; /* out-of-order bytes received */ + uint_t tcps_rcvpackafterwin; /* packets with data after window */ + uint_t tcps_rcvbyteafterwin; /* bytes rcvd after window */ + uint_t tcps_rcvafterclose; /* packets rcvd after "close" */ + uint_t tcps_rcvwinprobe; /* rcvd window probe packets */ + uint_t tcps_rcvdupack; /* rcvd duplicate acks */ + uint_t tcps_rcvacktoomuch; /* rcvd acks for unsent data */ + uint_t tcps_rcvackpack; /* rcvd ack packets */ + uint_t tcps_rcvackbyte; /* bytes acked by rcvd acks */ + uint_t tcps_rcvwinupd; /* rcvd window update packets */ +}; + +#define TCP_COMPAT_42 + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCP_VAR_H */ diff --git a/usr/src/uts/common/netinet/tcpip.h b/usr/src/uts/common/netinet/tcpip.h new file mode 100644 index 0000000000..9f31198752 --- /dev/null +++ b/usr/src/uts/common/netinet/tcpip.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Tcp+ip header, after ip options removed. + */ + +#ifndef _NETINET_TCPIP_H +#define _NETINET_TCPIP_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* tcpip.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/85 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct tcpiphdr { + struct ipovly ti_i; /* overlaid ip structure */ + struct tcphdr ti_t; /* tcp header */ +}; +#define ti_next ti_i.ih_next +#define ti_prev ti_i.ih_prev +#define ti_x1 ti_i.ih_x1 +#define ti_pr ti_i.ih_pr +#define ti_len ti_i.ih_len +#define ti_src ti_i.ih_src +#define ti_dst ti_i.ih_dst +#define ti_sport ti_t.th_sport +#define ti_dport ti_t.th_dport +#define ti_seq ti_t.th_seq +#define ti_ack ti_t.th_ack +#define ti_x2 ti_t.th_x2 +#define ti_off ti_t.th_off +#define ti_flags ti_t.th_flags +#define ti_win ti_t.th_win +#define ti_sum ti_t.th_sum +#define ti_urp ti_t.th_urp + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_TCPIP_H */ diff --git a/usr/src/uts/common/netinet/udp.h b/usr/src/uts/common/netinet/udp.h new file mode 100644 index 0000000000..8a7d5f4577 --- /dev/null +++ b/usr/src/uts/common/netinet/udp.h @@ -0,0 +1,52 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Udp protocol header. + * Per RFC 768, September, 1981. + */ + +#ifndef _NETINET_UDP_H +#define _NETINET_UDP_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* udp.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct udphdr { + in_port_t uh_sport; /* source port */ + in_port_t uh_dport; /* destination port */ + int16_t uh_ulen; /* udp length */ + uint16_t uh_sum; /* udp checksum */ +}; + +/* Option definitions. */ +#define UDP_ANONPRIVBIND 0x0100 /* for internal use only */ +#define UDP_EXCLBIND 0x0101 /* for internal use only */ +#define UDP_RCVHDR 0x0102 /* for internal use only */ +/* + * Following option in UDP_ namespace required to be exposed through + * <xti.h> (It also requires exposing options not implemented). The options + * with potential for conflicts use #ifndef guards. + * + */ +#ifndef UDP_CHECKSUM +#define UDP_CHECKSUM 0x0600 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_UDP_H */ diff --git a/usr/src/uts/common/netinet/udp_var.h b/usr/src/uts/common/netinet/udp_var.h new file mode 100644 index 0000000000..a26527daa6 --- /dev/null +++ b/usr/src/uts/common/netinet/udp_var.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * UDP kernel structures and variables. + */ + +#ifndef _NETINET_UDP_VAR_H +#define _NETINET_UDP_VAR_H + +#pragma ident "%Z%%M% %I% %E% SMI" +/* udp_var.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86 */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct udpiphdr { + struct ipovly ui_i; /* overlaid ip structure */ + struct udphdr ui_u; /* udp header */ +}; +#define ui_next ui_i.ih_next +#define ui_prev ui_i.ih_prev +#define ui_x1 ui_i.ih_x1 +#define ui_pr ui_i.ih_pr +#define ui_len ui_i.ih_len +#define ui_src ui_i.ih_src +#define ui_dst ui_i.ih_dst +#define ui_sport ui_u.uh_sport +#define ui_dport ui_u.uh_dport +#define ui_ulen ui_u.uh_ulen +#define ui_sum ui_u.uh_sum + +struct udpstat { + int udps_hdrops; + int udps_badsum; + int udps_badlen; + int udps_fullsock; +}; + +#define UDP_TTL 30 /* time to live for UDP packets */ + +#ifdef __cplusplus +} +#endif + +#endif /* _NETINET_UDP_VAR_H */ |