lsocket.h

Go to the documentation of this file.
00001 /*
00002 ** sockaddr.h for  in /home/anoman/work/lse/atomix/lseos-net
00003 ** 
00004 ** Copyright (c)2004 Arthur Kopatsy
00005 ** Login   <kopats_a@epita.fr>
00006 ** 
00007 ** Started on  Wed Jul 28 15:53:56 2004 
00008 ** Last update Mon Nov 29 10:42:23 2004 Arthur Kopatsy
00009 */
00010 
00011 #ifndef LIBINET_SOCKET_H_
00012 #define LIBINET_SOCKET_H_
00013 
00014 #define AF_LINK         0
00015 #define AF_INET         1
00016 #define AF_LOCAL        2
00017 
00018 /* Socket domains */
00019 #define PF_INET         0
00020 #define PF_PACKET       1
00021 
00022 /* Socket type */
00023 #define SOCK_STREAM     0
00024 #define SOCK_DGRAM      1 
00025 #define SOCK_RAW        2
00026 
00027 typedef size_t  socklen_t;
00028 
00029 typedef struct sockaddr
00030 {
00031   u_int8_t      sa_len;
00032   u_int8_t      sa_family;
00033   u_int8_t      sa_data[14];
00034 } t_sockaddr;
00035 
00036 /* 
00037 ** sockaddr_mac
00038 */
00039 
00040 #define MAC_ADDR_SIZE   6
00041 
00042 struct mac_addr {
00043   unsigned char s_addr[MAC_ADDR_SIZE];
00044 };
00045 
00046 struct ether_addr {
00047   unsigned char ether_addr_octet[MAC_ADDR_SIZE];
00048 };
00049 
00050 struct sockaddr_mac {
00051   u_int8_t              smac_len;
00052   u_int8_t              smac_family;
00053   struct mac_addr       smac_addr;
00054   u_int8_t              smac_zero[8];
00055 };
00056 
00057 
00058 /*
00059  * Definitions for UNIX IPC domain.
00060  */
00061 struct  sockaddr_un {
00062   u_int8_t        sun_len;        /* total sockaddr length */
00063   u_int8_t        sun_family;     /* AF_LOCAL */
00064   char            sun_path[104];  /* path name (gag) */
00065 };
00066 
00067 int                             socket(int      domain,
00068                                        int      type,
00069                                        int      protocol);
00070 int                             bind(int                sockfd,
00071                                      struct sockaddr    *my_addr,
00072                                      size_t             addrlen);
00073 
00074 struct s_recvfrom_args
00075 {
00076   int                   s;
00077   vaddr_t               buf;
00078   size_t                len;
00079   int                   flags;
00080   struct sockaddr       *from;
00081   socklen_t             *fromlen;
00082 };
00083 
00084 #define MSG_OOB         (1<<0)
00085 #define MSG_PEEK        (1<<1)
00086 #define MSG_WAITALL     (1<<2)
00087 #define MSG_TRUNC       (1<<3)
00088 #define MSG_ERRQUEUE    (1<<4)
00089 #define MSG_EOR         (1<<5)
00090 #define MSG_CTRUNC      (1<<6)
00091 #define MSG_DONTWAIT    (1<<7)
00092 
00093 ssize_t                         recvfrom(int                    s,
00094                                          void                   *buf,
00095                                          size_t                 len,
00096                                          int                    flags,
00097                                          struct sockaddr        *from,
00098                                          socklen_t              *fromlen);
00099 
00100 struct s_sendto_args
00101 {
00102   int                   s;
00103   const void            *buf;
00104   size_t                len;
00105   int                   flags;
00106   const struct sockaddr *to;
00107   socklen_t             tolen;
00108 };
00109 
00110 /* PROTO lib_socket.c lib_sockaddr.c */
00111 /* lib_socket.c */
00112 int socket(int domain, int type, int protocol);
00113 int bind(int sockfd, struct sockaddr *my_addr, size_t addrlen);
00114 ssize_t sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
00115 ssize_t recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
00116 int connect(int s, const struct sockaddr *name, socklen_t namelen);
00117 int getsockname(int s, struct sockaddr *name, socklen_t *namelen);
00118 int listen(int s, int backlog);
00119 int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
00120 int getpeername(int s, struct sockaddr *name, socklen_t *namelen);
00121 /* lib_sockaddr.c */
00122 char *inet_ntoa(struct in_addr in);
00123 int inet_aton(const char *cp, struct in_addr *inp);
00124 int inet_addr(const char *cp);
00125 char *mac_ntoa(struct mac_addr mac);
00126 int mac_aton(const char *cp, struct mac_addr *macp);
00127 #endif

Generated on Wed May 24 23:05:52 2006 for LSE/OS by  doxygen 1.4.6