Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFran├žois Romieu <romieu@cogenit.fr>2002-03-06 16:44:32 -0500
committerJeff Garzik <jgarzik@mandrakesoft.com>2002-03-06 16:44:32 -0500
commit0a1e27af6e612f17b4ca03bdc062506b8ea931e0 (patch)
tree585fae1f78c322194f64e7f5b40765556ed913cb
parentfd0812f699324d111225cc9a7e51ad8a81d2859c (diff)
WAN driver update 4/5:
Clean up WAN device protocol structure accesses to be type-safe, and not have to store the data length of structures.
-rw-r--r--drivers/net/wan/hdlc_cisco.c19
-rw-r--r--drivers/net/wan/hdlc_fr.c23
-rw-r--r--drivers/net/wan/hdlc_generic.c4
-rw-r--r--drivers/net/wan/hdlc_ppp.c8
-rw-r--r--drivers/net/wan/hdlc_raw.c21
-rw-r--r--drivers/net/wan/hdlc_x25.c8
6 files changed, 25 insertions, 58 deletions
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index 143ef3dfa7bf..038db895a46f 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -247,21 +247,16 @@ static void cisco_close(hdlc_device *hdlc)
int hdlc_cisco_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
{
+ cisco_proto *cisco_s = &ifr->ifr_settings->ifs_hdlc.cisco;
const size_t size = sizeof(cisco_proto);
struct net_device *dev = hdlc_to_dev(hdlc);
int result;
- switch (ifr->ifr_settings.type) {
+ switch (ifr->ifr_settings->type) {
case IF_GET_PROTO:
- ifr->ifr_settings.type = IF_PROTO_CISCO;
- if (ifr->ifr_settings.data_length == 0)
- return 0; /* return protocol only */
- if (ifr->ifr_settings.data_length < size)
- return -ENOMEM; /* buffer too small */
- if (copy_to_user(ifr->ifr_settings.data,
- &hdlc->state.cisco.settings, size))
+ ifr->ifr_settings->type = IF_PROTO_CISCO;
+ if (copy_to_user(cisco_s, &hdlc->state.cisco.settings, size))
return -EFAULT;
- ifr->ifr_settings.data_length = size;
return 0;
case IF_PROTO_CISCO:
@@ -271,11 +266,7 @@ int hdlc_cisco_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if(dev->flags & IFF_UP)
return -EBUSY;
- if (ifr->ifr_settings.data_length != size)
- return -ENOMEM; /* incorrect data length */
-
- if (copy_from_user(&hdlc->state.cisco.settings,
- ifr->ifr_settings.data, size))
+ if (copy_from_user(&hdlc->state.cisco.settings, cisco_s, size))
return -EFAULT;
/* FIXME - put sanity checks here */
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 89f2aa84ebda..b0b9d6743299 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -776,22 +776,17 @@ static void fr_destroy(hdlc_device *hdlc)
int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
{
+ fr_proto *fr_s = &ifr->ifr_settings->ifs_hdlc.fr;
const size_t size = sizeof(fr_proto);
struct net_device *dev = hdlc_to_dev(hdlc);
fr_proto_pvc pvc;
int result;
- switch (ifr->ifr_settings.type) {
+ switch (ifr->ifr_settings->type) {
case IF_GET_PROTO:
- ifr->ifr_settings.type = IF_PROTO_FR;
- if (ifr->ifr_settings.data_length == 0)
- return 0; /* return protocol only */
- if (ifr->ifr_settings.data_length < size)
- return -ENOMEM; /* buffer too small */
- if (copy_to_user(ifr->ifr_settings.data,
- &hdlc->state.fr.settings, size))
+ ifr->ifr_settings->type = IF_PROTO_FR;
+ if (copy_to_user(fr_s, &hdlc->state.fr.settings, size))
return -EFAULT;
- ifr->ifr_settings.data_length = size;
return 0;
case IF_PROTO_FR:
@@ -801,11 +796,7 @@ int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if(dev->flags & IFF_UP)
return -EBUSY;
- if (ifr->ifr_settings.data_length != size)
- return -ENOMEM; /* incorrect data length */
-
- if (copy_from_user(&hdlc->state.fr.settings,
- ifr->ifr_settings.data, size))
+ if (copy_from_user(&hdlc->state.fr.settings, fr_s, size))
return -EFAULT;
/* FIXME - put sanity checks here */
@@ -839,12 +830,12 @@ int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if(!capable(CAP_NET_ADMIN))
return -EPERM;
- if (copy_from_user(&pvc, ifr->ifr_settings.data,
+ if (copy_from_user(&pvc, &ifr->ifr_settings->ifs_hdlc.fr_pvc,
sizeof(fr_proto_pvc)))
return -EFAULT;
return fr_pvc(hdlc, pvc.dlci,
- ifr->ifr_settings.type == IF_PROTO_FR_ADD_PVC);
+ ifr->ifr_settings->type == IF_PROTO_FR_ADD_PVC);
}
return -EINVAL;
diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c
index 8eb43ef30e2f..4f74808cbd7b 100644
--- a/drivers/net/wan/hdlc_generic.c
+++ b/drivers/net/wan/hdlc_generic.c
@@ -75,13 +75,13 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (cmd != SIOCWANDEV)
return -EINVAL;
- switch(ifr->ifr_settings.type) {
+ switch(ifr->ifr_settings->type) {
case IF_PROTO_HDLC:
case IF_PROTO_PPP:
case IF_PROTO_CISCO:
case IF_PROTO_FR:
case IF_PROTO_X25:
- proto = ifr->ifr_settings.type;
+ proto = ifr->ifr_settings->type;
break;
default:
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 0f95449a6cdc..3632f7a1fff6 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -82,10 +82,9 @@ int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
struct net_device *dev = hdlc_to_dev(hdlc);
int result;
- switch (ifr->ifr_settings.type) {
+ switch (ifr->ifr_settings->type) {
case IF_GET_PROTO:
- ifr->ifr_settings.type = IF_PROTO_PPP;
- ifr->ifr_settings.data_length = 0;
+ ifr->ifr_settings->type = IF_PROTO_PPP;
return 0; /* return protocol only, no settable parameters */
case IF_PROTO_PPP:
@@ -95,8 +94,7 @@ int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if(dev->flags & IFF_UP)
return -EBUSY;
- if (ifr->ifr_settings.data_length != 0)
- return -EINVAL; /* no settable parameters */
+ /* no settable parameters */
hdlc_detach(hdlc);
diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c
index 851bb40fddd0..00400730dfb0 100644
--- a/drivers/net/wan/hdlc_raw.c
+++ b/drivers/net/wan/hdlc_raw.c
@@ -37,21 +37,15 @@ static void raw_rx(struct sk_buff *skb)
int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
{
- const size_t size = sizeof(hdlc_proto);
+ raw_hdlc_proto *raw_s = &ifr->ifr_settings->ifs_hdlc.raw_hdlc;
+ const size_t size = sizeof(raw_hdlc_proto);
struct net_device *dev = hdlc_to_dev(hdlc);
int result;
- switch (ifr->ifr_settings.type) {
+ switch (ifr->ifr_settings->type) {
case IF_GET_PROTO:
- ifr->ifr_settings.type = IF_PROTO_HDLC;
- if (ifr->ifr_settings.data_length == 0)
- return 0; /* return protocol only */
- if (ifr->ifr_settings.data_length < size)
- return -ENOMEM; /* buffer too small */
- if (copy_to_user(ifr->ifr_settings.data,
- &hdlc->state.raw_hdlc.settings, size))
+ if (copy_to_user(raw_s, &hdlc->state.raw_hdlc.settings, size))
return -EFAULT;
- ifr->ifr_settings.data_length = size;
return 0;
case IF_PROTO_HDLC:
@@ -61,13 +55,10 @@ int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if(dev->flags & IFF_UP)
return -EBUSY;
- if (ifr->ifr_settings.data_length != size)
- return -ENOMEM; /* incorrect data length */
-
- if (copy_from_user(&hdlc->state.raw_hdlc.settings,
- ifr->ifr_settings.data, size))
+ if (copy_from_user(&hdlc->state.raw_hdlc.settings, raw_s, size))
return -EFAULT;
+
/* FIXME - put sanity checks here */
hdlc_detach(hdlc);
diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
index b0bbce528a9f..55c3f173565b 100644
--- a/drivers/net/wan/hdlc_x25.c
+++ b/drivers/net/wan/hdlc_x25.c
@@ -184,10 +184,9 @@ int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
struct net_device *dev = hdlc_to_dev(hdlc);
int result;
- switch (ifr->ifr_settings.type) {
+ switch (ifr->ifr_settings->type) {
case IF_GET_PROTO:
- ifr->ifr_settings.type = IF_PROTO_X25;
- ifr->ifr_settings.data_length = 0;
+ ifr->ifr_settings->type = IF_PROTO_X25;
return 0; /* return protocol only, no settable parameters */
case IF_PROTO_X25:
@@ -197,9 +196,6 @@ int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr)
if(dev->flags & IFF_UP)
return -EBUSY;
- if (ifr->ifr_settings.data_length != 0)
- return -EINVAL; /* no settable parameters */
-
hdlc_detach(hdlc);
result=hdlc->attach(hdlc, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT);