case SIOCX25CALLACCPTAPPRV: { rc = -EINVAL; if (sk->sk_state != TCP_CLOSE) break; x25->accptapprv = X25_ALLOW_ACCPT_APPRV; rc = 0; break; }  case SIOCX25SENDCALLACCPT:  { rc = -EINVAL; if (sk->sk_state != TCP_ESTABLISHED) break; if (x25->accptapprv)	/* must call accptapprv above */ break; x25_write_internal(sk, X25_CALL_ACCEPTED); x25->state = X25_STATE_3; rc = 0; break; }  
static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg){	struct sock *sk = sock->sk;	struct x25_sock *x25 = x25_sk(sk);	void __user *argp = (void __user *)arg;	int rc;	switch (cmd) {		case TIOCOUTQ: {			int amount = sk->sk_sndbuf -				     atomic_read(&sk->sk_wmem_alloc);			if (amount < 0)				amount = 0;			rc = put_user(amount, (unsigned int __user *)argp);			break;		}		case TIOCINQ: {			struct sk_buff *skb;			int amount = 0;			/*			 * These two are safe on a single CPU system as			 * only user tasks fiddle here			 */			if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)				amount = skb->len;			rc = put_user(amount, (unsigned int __user *)argp);			break;		}		case SIOCGSTAMP:			rc = -EINVAL;			if (sk)				rc = sock_get_timestamp(sk, 						(struct timeval __user *)argp); 			break;		case SIOCGIFADDR:		case SIOCSIFADDR:		case SIOCGIFDSTADDR:		case SIOCSIFDSTADDR:		case SIOCGIFBRDADDR:		case SIOCSIFBRDADDR:		case SIOCGIFNETMASK:		case SIOCSIFNETMASK:		case SIOCGIFMETRIC:		case SIOCSIFMETRIC:			rc = -EINVAL;			break;		case SIOCADDRT:		case SIOCDELRT:			rc = -EPERM;			if (!capable(CAP_NET_ADMIN))				break;			rc = x25_route_ioctl(cmd, argp);			break;		case SIOCX25GSUBSCRIP:			rc = x25_subscr_ioctl(cmd, argp);			break;		case SIOCX25SSUBSCRIP:			rc = -EPERM;			if (!capable(CAP_NET_ADMIN))				break;			rc = x25_subscr_ioctl(cmd, argp);			break;		case SIOCX25GFACILITIES: {			struct x25_facilities fac = x25->facilities;			rc = copy_to_user(argp, &fac,					  sizeof(fac)) ? -EFAULT : 0;			break;		}		case SIOCX25SFACILITIES: {			struct x25_facilities facilities;			rc = -EFAULT;			if (copy_from_user(&facilities, argp,					   sizeof(facilities)))				break;			rc = -EINVAL;			if (sk->sk_state != TCP_LISTEN &&			    sk->sk_state != TCP_CLOSE)				break;			if (facilities.pacsize_in < X25_PS16 ||			    facilities.pacsize_in > X25_PS4096)				break;			if (facilities.pacsize_out < X25_PS16 ||			    facilities.pacsize_out > X25_PS4096)				break;			if (facilities.winsize_in < 1 ||			    facilities.winsize_in > 127)				break;			if (facilities.throughput < 0x03 ||			    facilities.throughput > 0xDD)				break;			if (facilities.reverse && facilities.reverse != 1)				break;			x25->facilities = facilities;			rc = 0;			break;		}		case SIOCX25GCALLUSERDATA: {			struct x25_calluserdata cud = x25->calluserdata;			rc = copy_to_user(argp, &cud,					  sizeof(cud)) ? -EFAULT : 0;			break;		}		case SIOCX25SCALLUSERDATA: {			struct x25_calluserdata calluserdata;			rc = -EFAULT;			if (copy_from_user(&calluserdata, argp,					   sizeof(calluserdata)))				break;			rc = -EINVAL;			if (calluserdata.cudlength > X25_MAX_CUD_LEN)				break;			x25->calluserdata = calluserdata;			rc = 0;			break;		}		case SIOCX25GCAUSEDIAG: {			struct x25_causediag causediag;			causediag = x25->causediag;			rc = copy_to_user(argp, &causediag,					  sizeof(causediag)) ? -EFAULT : 0;			break;		}		case SIOCX25SCUDMATCHLEN: {			struct x25_subaddr sub_addr;			rc = -EINVAL;			if(sk->sk_state != TCP_CLOSE)				break;			rc = -EFAULT;			if (copy_from_user(&sub_addr, argp,					sizeof(sub_addr)))				break;		 	rc = -EINVAL;			if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN)				break;			x25->cudmatchlength = sub_addr.cudmatchlength;			rc = 0;			break;		} 		default:			rc = dev_ioctl(cmd, argp);			break;	}	return rc;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/ebc3f64b864fc16a594c2e63bf55a55c7d42084b/af_x25.c/clean/net/x25/af_x25.c