root/kern/include/kern/socket.h

/* [<][>][^][v][top][bottom][index][help] */
   1 /*
   2  * Copyright (c) 2004, 2008
   3  *      The President and Fellows of Harvard College.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. Neither the name of the University nor the names of its contributors
  14  *    may be used to endorse or promote products derived from this software
  15  *    without specific prior written permission.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 
  30 #ifndef _KERN_SOCKET_H_
  31 #define _KERN_SOCKET_H_
  32 
  33 /*
  34  * Socket-related definitions, for <sys/socket.h>.
  35  */
  36 
  37 
  38 /*
  39  * Important
  40  */
  41 
  42 /* Socket types that we (might) support. */
  43 #define SOCK_STREAM     1       /* stream */
  44 #define SOCK_DGRAM      2       /* packet */
  45 #define SOCK_RAW        3       /* raw packet */
  46 
  47 /* Address families that we (might) support. */
  48 #define AF_UNSPEC       0
  49 #define AF_UNIX         1
  50 #define AF_INET         2
  51 #define AF_INET6        3
  52 
  53 /* Protocol families. Pointless layer of indirection in the standard API. */
  54 #define PF_UNSPEC       AF_UNSPEC
  55 #define PF_UNIX         AF_UNIX
  56 #define PF_INET         AF_INET
  57 #define PF_INET6        AF_INET6
  58 
  59 /*
  60  * Socket address structures. Socket addresses are polymorphic, and
  61  * the polymorphism is handled by casting pointers. It's fairly gross,
  62  * but way too deeply standardized to ever change.
  63  *
  64  * Each address family defines a sockaddr type (sockaddr_un,
  65  * sockaddr_in, etc.) struct sockaddr is the common prefix of all
  66  * these, and struct sockaddr_storage is defined to be large enough to
  67  * hold any of them.
  68  *
  69  * The complex padding in sockaddr_storage forces it to be aligned,
  70  * which wouldn't happen if it were just a char array.
  71  */
  72 
  73 struct sockaddr {
  74    __u8 sa_len;
  75    __u8 sa_family;
  76 };
  77 
  78 #define _SS_SIZE        128
  79 struct sockaddr_storage {
  80    __u8 ss_len;
  81    __u8 ss_family;
  82    __u8 __ss_pad1;
  83    __u8 __ss_pad2;
  84    __u32 __ss_pad3;
  85    __u64 __ss_pad4;
  86    char __ss_pad5[_SS_SIZE - sizeof(__u64) - sizeof(__u32) - 4*sizeof(__u8)];
  87 };
  88 
  89 
  90 /*
  91  * Not very important.
  92  */
  93 
  94 /*
  95  * msghdr structures for sendmsg() and recvmsg().
  96  */
  97 
  98 struct msghdr {
  99         void *msg_name;         /* really sockaddr; address, or null */
 100         socklen_t msg_namelen;  /* size of msg_name object, or 0 */
 101         struct iovec *msg_iov;  /* I/O buffers */
 102         int msg_iovlen;         /* number of iovecs */
 103         void *msg_control;      /* auxiliary data area, or null */
 104         socklen_t msg_controllen; /* size of msg_control area */
 105         int msg_flags;          /* flags */
 106 };
 107 
 108 struct cmsghdr {
 109         socklen_t cmsg_len;     /* length of control data, including header */
 110         int cmsg_level;         /* protocol layer item originates from */
 111         int cmsg_type;          /* protocol-specific message type */
 112         /* char cmsg_data[];*/  /* data follows the header */
 113 };
 114 
 115 
 116 #endif /* _KERN_SOCKET_H_ */

/* [<][>][^][v][top][bottom][index][help] */