开源,一个时髦的话题,混计算机的, 不提开源您都不好意思跟人打招呼。
这是去年我做的一个开源小项目,非常简单了,今天拿出来放在blog上吧,如果喜您欢,请评论之。
Ksocket is a linux 2.6 kernel module that provides bsd-style socket interfaces (namely socket, bind, listen, connect, accept, ...) for kernel developers to facilitate their network progaramming in linux kernel space.
The interfaces ksocket presented are much the same as their equivalent in glibc, so even new developers for kernel space will have no barrier in developing kernel network-related programms.
Ksocket provides the following interfaces for now:
ksocket_t ksocket(int domain, int type, int protocol)
int kshutdown(ksocket_t socket, int how)
int kclose(ksocket_t socket)
int kbind(ksocket_t socket, struct sockaddr *address, int address_len)
int klisten(ksocket_t socket, int backlog)
int kconnect(ksocket_t socket, struct sockaddr *address, int address_len)
ksocket_t kaccept(ksocket_t socket, struct sockaddr *address, int *address_len)
ssize_t krecv(ksocket_t socket, void *buffer, size_t length, int flags)
ssize_t ksend(ksocket_t socket, const void *buffer, size_t length, int flags)
ssize_t krecvfrom(ksocket_t socket, void * buffer, size_t length, int flags, struct sockaddr * address, int * address_len)
ssize_t ksendto(ksocket_t socket, void *message, size_t length, int flags, const struct sockaddr *dest_addr, int dest_len)
int kgetsockname(ksocket_t socket, struct sockaddr *address, int *address_len)
int kgetpeername(ksocket_t socket, struct sockaddr *address, int *address_len)
int ksetsockopt(ksocket_t socket, int level, int optname, void *optval, int optlen)
int kgetsockopt(ksocket_t socket, int level, int optname, void *optval, int *optlen)
阅读(2048) | 评论(2) | 转发(0) |