/*1* Copyright (c) 2004, 20082* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _KERN_SOCKET_H_30#define _KERN_SOCKET_H_3132/*33* Socket-related definitions, for <sys/socket.h>.34*/353637/*38* Important39*/4041/* Socket types that we (might) support. */42#define SOCK_STREAM 1 /* stream */43#define SOCK_DGRAM 2 /* packet */44#define SOCK_RAW 3 /* raw packet */4546/* Address families that we (might) support. */47#define AF_UNSPEC 048#define AF_UNIX 149#define AF_INET 250#define AF_INET6 35152/* Protocol families. Pointless layer of indirection in the standard API. */53#define PF_UNSPEC AF_UNSPEC54#define PF_UNIX AF_UNIX55#define PF_INET AF_INET56#define PF_INET6 AF_INET65758/*59* Socket address structures. Socket addresses are polymorphic, and60* the polymorphism is handled by casting pointers. It's fairly gross,61* but way too deeply standardized to ever change.62*63* Each address family defines a sockaddr type (sockaddr_un,64* sockaddr_in, etc.) struct sockaddr is the common prefix of all65* these, and struct sockaddr_storage is defined to be large enough to66* hold any of them.67*68* The complex padding in sockaddr_storage forces it to be aligned,69* which wouldn't happen if it were just a char array.70*/7172struct sockaddr {73__u8 sa_len;74__u8 sa_family;75};7677#define _SS_SIZE 12878struct sockaddr_storage {79__u8 ss_len;80__u8 ss_family;81__u8 __ss_pad1;82__u8 __ss_pad2;83__u32 __ss_pad3;84__u64 __ss_pad4;85char __ss_pad5[_SS_SIZE - sizeof(__u64) - sizeof(__u32) - 4*sizeof(__u8)];86};878889/*90* Not very important.91*/9293/*94* msghdr structures for sendmsg() and recvmsg().95*/9697struct msghdr {98void *msg_name; /* really sockaddr; address, or null */99socklen_t msg_namelen; /* size of msg_name object, or 0 */100struct iovec *msg_iov; /* I/O buffers */101int msg_iovlen; /* number of iovecs */102void *msg_control; /* auxiliary data area, or null */103socklen_t msg_controllen; /* size of msg_control area */104int msg_flags; /* flags */105};106107struct cmsghdr {108socklen_t cmsg_len; /* length of control data, including header */109int cmsg_level; /* protocol layer item originates from */110int cmsg_type; /* protocol-specific message type */111/* char cmsg_data[];*/ /* data follows the header */112};113114115#endif /* _KERN_SOCKET_H_ */116117118