|
|
1.1 ! root 1: #ifndef _KERN_SOCK_H ! 2: #define _KERN_SOCK_H ! 3: ! 4: #define NSOCKETS 128 /* should be dynamic, later... */ ! 5: ! 6: typedef enum { ! 7: SS_FREE = 0, /* not allocated */ ! 8: SS_UNCONNECTED, /* unconnected to any socket */ ! 9: SS_CONNECTING, /* in process of connecting */ ! 10: SS_CONNECTED, /* connected to socket */ ! 11: SS_DISCONNECTING, /* in process of disconnecting */ ! 12: } socket_state; ! 13: ! 14: #define SO_ACCEPTCON (1<<16) /* performed a listen */ ! 15: ! 16: /* ! 17: * internel representation of a socket. not all the fields are used by ! 18: * all configurations: ! 19: * ! 20: * server client ! 21: * conn client connected to server connected to ! 22: * iconn list of clients -unused- ! 23: * awaiting connections ! 24: * wait sleep for clients, sleep for connection, ! 25: * sleep for i/o sleep for i/o ! 26: */ ! 27: struct socket { ! 28: short type; /* SOCK_STREAM, ... */ ! 29: socket_state state; ! 30: long flags; ! 31: struct proto_ops *ops; /* protocols do most everything */ ! 32: char *data; /* protocol data */ ! 33: struct socket *conn; /* server socket connected to */ ! 34: struct socket *iconn; /* incomplete client connections */ ! 35: struct socket *next; ! 36: struct task_struct **wait; /* ptr to place to wait on */ ! 37: void *dummy; ! 38: }; ! 39: ! 40: struct proto_ops { ! 41: int (*init)(void); ! 42: int (*create)(struct socket *sock, int protocol); ! 43: int (*dup)(struct socket *newsock, struct socket *oldsock); ! 44: int (*release)(struct socket *sock, struct socket *peer); ! 45: int (*bind)(struct socket *sock, struct sockaddr *umyaddr, ! 46: int sockaddr_len); ! 47: int (*connect)(struct socket *sock, struct sockaddr *uservaddr, ! 48: int sockaddr_len); ! 49: int (*socketpair)(struct socket *sock1, struct socket *sock2); ! 50: int (*accept)(struct socket *sock, struct socket *newsock); ! 51: int (*getname)(struct socket *sock, struct sockaddr *uaddr, ! 52: int *usockaddr_len, int peer); ! 53: int (*read)(struct socket *sock, char *ubuf, int size, int nonblock); ! 54: int (*write)(struct socket *sock, char *ubuf, int size, int nonblock); ! 55: int (*select)(struct socket *sock, int which); ! 56: int (*ioctl)(struct socket *sock, unsigned int cmd, unsigned long arg); ! 57: }; ! 58: ! 59: extern int sock_awaitconn(struct socket *mysock, struct socket *servsock); ! 60: ! 61: #ifdef SOCK_DEBUG ! 62: #define PRINTK printk ! 63: #else ! 64: #define PRINTK (void) ! 65: #endif ! 66: ! 67: #endif /* _KERN_SOCK_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.