21 #include <linux/netdevice.h>
23 #include <linux/slab.h>
24 #include <linux/wanrouter.h>
29 #define MY_DEVNAME(dev) ((dev) ? (dev)->name : "DEVICE UNSPECIFIED")
44 static void isdn_x25iface_proto_del(
struct concap_proto *);
45 static int isdn_x25iface_proto_close(
struct concap_proto *);
46 static int isdn_x25iface_proto_restart(
struct concap_proto *,
51 static int isdn_x25iface_connect_ind(
struct concap_proto *);
52 static int isdn_x25iface_disconn_ind(
struct concap_proto *);
57 &isdn_x25iface_proto_del,
58 &isdn_x25iface_proto_restart,
59 &isdn_x25iface_proto_close,
61 &isdn_x25iface_receive,
62 &isdn_x25iface_connect_ind,
63 &isdn_x25iface_disconn_ind
67 static void illegal_state_warn(
unsigned state,
unsigned char firstbyte)
70 "current state %d\n", firstbyte, state);
78 "isdn_x25iface_xxx: illegal pointer to proto data\n");
96 tmp->
priv.pops = &ix25_pops;
99 return (&(tmp->
priv));
106 static int isdn_x25iface_proto_close(
struct concap_proto *cprot) {
114 "invalid concap_proto pointer\n");
122 if (pdata_is_bad(tmp)) {
127 spin_unlock_irqrestore(&cprot->
lock, flags);
133 static void isdn_x25iface_proto_del(
struct concap_proto *cprot) {
140 "concap_proto pointer is NULL\n");
146 "proto_data pointer (maybe already deleted?)\n");
150 if (cprot->
dops) isdn_x25iface_proto_close(cprot);
162 static int isdn_x25iface_proto_restart(
struct concap_proto *cprot,
171 if (pdata_is_bad(pda))
return -1;
177 isdn_x25iface_proto_close(cprot);
182 cprot->
pops = &ix25_pops;
185 spin_unlock_irqrestore(&cprot->
lock, flags);
210 static int isdn_x25iface_connect_ind(
struct concap_proto *cprot)
215 IX25DEBUG(
"isdn_x25iface_connect_ind %s \n"
219 "isdn_x25iface_connect_ind while unconfigured %s\n"
225 skb = dev_alloc_skb(1);
233 " out of memory -- disconnecting\n");
234 cprot->
dops->disconn_req(cprot);
241 static int isdn_x25iface_disconn_ind(
struct concap_proto *cprot)
249 "isdn_x25iface_disconn_ind while unconfigured\n");
252 if (!cprot->
net_dev)
return -1;
254 skb = dev_alloc_skb(1);
272 unsigned char firstbyte = skb->
data[0];
275 IX25DEBUG(
"isdn_x25iface_xmit: %s first=%x state=%d\n",
282 ret = (cprot->
dops->data_req(cprot, skb));
287 illegal_state_warn(*state, firstbyte);
292 ret = cprot->
dops->connect_req(cprot);
296 isdn_x25iface_disconn_ind(cprot);
299 illegal_state_warn(*state, firstbyte);
310 " requested while disconnected\n");
311 isdn_x25iface_disconn_ind(cprot);
316 cprot->
dops->disconn_req(cprot);
319 illegal_state_warn(*state, firstbyte);
324 " options not yet supported\n");
328 " first byte %x ignored:\n", firstbyte);