1 #ifndef _NET_SOCKET_H 2 #define _NET_SOCKET_H 3 4 #include <sys/socketvar.h> 5 #include <mbuf.h> 6 7 /* Function prototypes */ 8 9 /* These functions are exported through the core module */ 10 11 int socket_init (struct socket **nso); 12 int socket_create (struct socket *so, int dom, int type, int proto); 13 int socket_shutdown (struct socket *so, int how); // XXX this one is not used at all 14 int socket_close (struct socket *so); 15 16 int socket_bind (struct socket *so, char *, int); 17 int socket_listen (struct socket *so, int backlog); 18 int socket_connect (struct socket *so, char *, int); 19 int socket_accept (struct socket *so, struct socket **nso, void *, int *); 20 21 int socket_writev (struct socket *so, struct iovec *, int flags); 22 int socket_readv (struct socket *so, struct iovec *, int *flags); 23 int socket_send (struct socket *so, struct msghdr *, int flags, int *retsize); 24 int socket_recv (struct socket *so, struct msghdr *, caddr_t namelenp, int *retsize); 25 26 int socket_setsockopt (struct socket *so, int, int, const void *, size_t); 27 int socket_getsockopt (struct socket *so, int, int, void *, size_t *); 28 int socket_ioctl (struct socket *so, int cmd, caddr_t data); 29 30 int socket_getpeername (struct socket *so, struct sockaddr *, int *); 31 int socket_getsockname (struct socket *so, struct sockaddr *, int *); 32 33 int socket_set_event_callback(struct socket *so, socket_event_callback, void *, int); 34 35 36 /* these are all private to the stack...although may be shared with 37 * other network modules. 38 */ 39 40 41 struct socket *sonewconn(struct socket *head, int connstatus); 42 int soreserve (struct socket *so, uint32 sndcc, uint32 rcvcc); 43 44 void sockbuf_release(struct sockbuf *sb); 45 int sockbuf_reserve(struct sockbuf *sb, uint32 cc); 46 void sockbuf_drop(struct sockbuf *sb, int len); 47 void sockbuf_droprecord(struct sockbuf *sb); 48 void sockbuf_flush(struct sockbuf *sb); 49 int sockbuf_wait(struct sockbuf *sb); 50 void sockbuf_append(struct sockbuf *sb, struct mbuf *m); 51 int sockbuf_appendaddr(struct sockbuf *sb, struct sockaddr *asa, 52 struct mbuf *m0, struct mbuf *control); 53 int sockbuf_appendcontrol(struct sockbuf *sb, struct mbuf *m0, 54 struct mbuf *control); 55 void sockbuf_appendrecord(struct sockbuf *sb, struct mbuf *m0); 56 void sockbuf_compress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n); 57 void sockbuf_insertoob(struct sockbuf *, struct mbuf *); 58 59 void sowakeup(struct socket *so, struct sockbuf *sb); 60 61 int sodisconnect(struct socket *); 62 63 void socket_set_hasoutofband(struct socket *so); 64 void socket_set_cantsendmore(struct socket *so); 65 void socket_set_cantrcvmore(struct socket *so); 66 void socket_set_connected(struct socket *so); 67 void socket_set_connecting(struct socket *so); 68 void socket_set_disconnected(struct socket *so); 69 void socket_set_disconnecting(struct socket *so); 70 71 int sorflush(struct socket *so); 72 73 int sockbuf_lock(struct sockbuf *sb); 74 int nsleep(sem_id chan, char *msg, int timeo); 75 void wakeup(sem_id chan); 76 77 #endif 78