/* Handle the ioctls that control the routing functions.  */
int x25_route_ioctl(unsigned int cmd, void __user *arg)
/* Handle the ioctls that control the routing functions.  */
int x25_route_ioctl(unsigned int cmd, void __user *arg)
{
	struct x25_route_struct rt;
	struct net_device *dev;
	int rc = -EINVAL;
	if (cmd != SIOCADDRT && cmd != SIOCDELRT)
		goto out;
	rc = -EFAULT;
	if (copy_from_user(&rt, arg, sizeof(rt)))
		goto out;
	rc = -EINVAL;
	if (rt.sigdigits > 15)
		goto out;
	dev = x25_dev_get(rt.device);
	if (!dev)
		goto out;
	if (cmd == SIOCADDRT)
		rc = x25_add_route(&rt.address, rt.sigdigits, dev);
	else
		rc = x25_del_route(&rt.address, rt.sigdigits, dev);
	dev_put(dev);
out:
	return rc;
}