/* * This file implement the WSMP(Wave Short Message Protocol) priv API. * * Authors : Tata P Vamsi Krishna * Copyright 2014 Tata P Vamsi Krishna * * (As all part of the Linux kernel, this file is GPL) */ #include #include #include #include #include #include #include #include #include #include #include"wsmp.h" static void wsmp_sock_kill(struct sock *sk); static int wsmp_sock_shutdown(struct socket *sock, int how) { struct sock *sk = sock->sk; int err = 0; if (!sk) return 0; if (!sk->sk_shutdown) sk->sk_shutdown = SHUTDOWN_MASK; // __rfcomm_sock_close(sk); if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) // err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime); release_sock(sk); printk("This is wsmp_sock_shutdown\n"); return err; } static int wsmp_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err = 0; if (!sk) return 0; wsmp_sock_shutdown(sock,2); sock_orphan(sk); wsmp_sock_kill(sk); printk("This is wsmp_sock_release..\n"); return 0; } static void wsmp_sock_kill(struct sock *sk){ if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) return; sock_set_flag(sk, SOCK_DEAD); sock_put(sk); printk("This is wsmp_sock_kill..\n"); } static int wsmp_sock_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in *addr = (struct sockaddr_in *)uaddr; struct sock *sk = sock->sk; struct inet_sock *inet = inet_sk(sk); struct net *net = sock_net(sk); unsigned short snum; int chk_addr_ret; int err,i; /* If the socket has its own bind function then use it. (RAW) */ if (sk->sk_prot->bind) { err = sk->sk_prot->bind(sk, uaddr, addr_len); printk("error message");; } printk("This family....%d\n",uaddr->sa_family); printk("This address: "); for(i=0;i<14;i++) printk("%d ",uaddr->sa_data[i]); printk("\n"); printk("This is wsmp_sock_bind..\n"); return 0; } static int wsmp_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) { printk("This is wsmp_sock_connect..\n"); return 0; } static int wsmp_sock_listen(struct socket *sock, int backlog) { printk("This is wsmp_sock_listen\n"); return 0; } static int wsmp_sock_accept(struct socket *sock, struct socket *newsock, int flags) { printk("This is wsmp_sock_accept\n"); return 0; } static int wsmp_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) { printk("This is wsmp_sock_getname\n"); return 0; } static int wsmp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; return sk->sk_prot->sendmsg(iocb, sk, msg, len); } int wsmp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) { printk("This is wsmp_sock_recvmsg\n"); return 0; } int wsmp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { printk("This is wsmp_sock_ioctl\n"); return 0; } struct proto_ops wsmp_sock_ops = { .family = PF_WSMP, .owner = THIS_MODULE, .release = wsmp_sock_release, .bind = wsmp_sock_bind, .connect = wsmp_sock_connect, .listen = wsmp_sock_listen, .accept = wsmp_sock_accept, .getname = wsmp_sock_getname, .sendmsg = wsmp_sock_sendmsg, .recvmsg = wsmp_sock_recvmsg, .ioctl = wsmp_sock_ioctl, .mmap = sock_no_mmap, .socketpair = sock_no_socketpair, .shutdown = wsmp_sock_shutdown, }; MODULE_LICENSE("GPL");