5 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
7 #include <linux/string.h>
9 #include <linux/errno.h>
10 #include <linux/kernel.h>
12 #include <linux/wait.h>
13 #include <linux/sched.h>
14 #include <linux/fcntl.h>
16 #include <linux/atm.h>
19 #include <linux/atmdev.h>
20 #include <linux/bitops.h>
23 #include <linux/export.h>
40 static int svc_shutdown(
struct socket *
sock,
int how)
45 static void svc_disconnect(
struct atm_vcc *
vcc)
49 struct sock *
sk = sk_atm(vcc);
76 struct sock *sk = sock->
sk;
98 struct sock *sk = sock->
sk;
149 static int svc_connect(
struct socket *sock,
struct sockaddr *sockaddr,
150 int sockaddr_len,
int flags)
153 struct sock *sk = sock->
sk;
155 struct atm_vcc *vcc = ATM_SD(sock);
165 switch (sock->
state) {
198 if (!vcc->
qos.txtp.traffic_class &&
199 !vcc->
qos.rxtp.traffic_class) {
216 if (!signal_pending(
current)) {
272 vcc->
qos.txtp.pcr = 0;
273 vcc->
qos.txtp.min_pcr = 0;
281 (
void)svc_disconnect(vcc);
290 struct sock *sk = sock->
sk;
291 struct atm_vcc *vcc = ATM_SD(sock);
326 static int svc_accept(
struct socket *sock,
struct socket *newsock,
int flags)
328 struct sock *sk = sock->
sk;
331 struct atm_vcc *old_vcc = ATM_SD(sock);
337 error =
svc_create(sock_net(sk), newsock, 0, 0);
341 new_vcc = ATM_SD(newsock);
343 pr_debug(
"%p -> %p\n", old_vcc, new_vcc);
356 if (flags & O_NONBLOCK) {
384 msg->
pvc.sap_addr.vpi,
385 msg->
pvc.sap_addr.vci);
390 &old_vcc->
qos, error);
411 if (!sk_atm(new_vcc)->sk_err)
414 error = -sk_atm(new_vcc)->sk_err;
424 static int svc_getname(
struct socket *sock,
struct sockaddr *sockaddr,
425 int *sockaddr_len,
int peer)
431 memcpy(addr, peer ? &ATM_SD(sock)->remote : &ATM_SD(sock)->local,
438 struct sock *sk = sk_atm(vcc);
455 static int svc_setsockopt(
struct socket *sock,
int level,
int optname,
456 char __user *optval,
unsigned int optlen)
458 struct sock *sk = sock->
sk;
459 struct atm_vcc *vcc = ATM_SD(sock);
460 int value, error = 0;
476 if (level !=
SOL_ATM || optlen !=
sizeof(
int)) {
480 if (
get_user(value, (
int __user *)optval)) {
500 static int svc_getsockopt(
struct socket *sock,
int level,
int optname,
501 char __user *optval,
int __user *optlen)
503 struct sock *sk = sock->
sk;
528 static int svc_addparty(
struct socket *sock,
struct sockaddr *sockaddr,
529 int sockaddr_len,
int flags)
532 struct sock *sk = sock->
sk;
533 struct atm_vcc *vcc = ATM_SD(sock);
541 if (flags & O_NONBLOCK) {
558 static int svc_dropparty(
struct socket *sock,
int ep_ref)
561 struct sock *sk = sock->
sk;
562 struct atm_vcc *vcc = ATM_SD(sock);
584 static int svc_ioctl(
struct socket *sock,
unsigned int cmd,
unsigned long arg)
588 struct atm_vcc *vcc = ATM_SD(sock);
596 error = svc_addparty(sock, (
struct sockaddr *)&
sa,
sizeof(
sa),
604 error = svc_dropparty(sock, ep_ref);
614 static int svc_compat_ioctl(
struct socket *sock,
unsigned int cmd,
620 if (cmd == COMPAT_ATM_ADDPARTY)
624 return svc_ioctl(sock, cmd, arg);
630 static const struct proto_ops svc_proto_ops = {
634 .release = svc_release,
636 .connect = svc_connect,
638 .accept = svc_accept,
639 .getname = svc_getname,
643 .compat_ioctl = svc_compat_ioctl,
645 .listen = svc_listen,
646 .shutdown = svc_shutdown,
647 .setsockopt = svc_setsockopt,
648 .getsockopt = svc_getsockopt,
664 sock->
ops = &svc_proto_ops;
668 ATM_SD(sock)->local.sas_family =
AF_ATMSVC;
669 ATM_SD(sock)->remote.sas_family =
AF_ATMSVC;