25 #include <linux/isdn.h>
26 #include <linux/slab.h>
33 #ifdef CONFIG_ISDN_PPP
36 #ifdef CONFIG_ISDN_X25
82 return netif_running(dev);
92 netif_wake_queue(lp->
master);
94 netif_wake_queue(lp->
netdev->dev);
104 netif_stop_queue(lp->
master);
106 netif_stop_queue(lp->
netdev->dev);
120 if (!isdn_net_lp_busy(lp))
131 if (!isdn_net_lp_busy(nlp)) {
132 spin_unlock_irqrestore(&nd->
queue_lock, flags);
137 spin_unlock_irqrestore(&nd->
queue_lock, flags);
144 if (isdn_net_device_busy(lp))
145 isdn_net_device_stop_queue(lp);
152 if (!(isdn_net_device_busy(lp))) {
156 isdn_net_device_wake_queue(lp);
175 #define ISDN_NET_TX_TIMEOUT (20 * HZ)
201 (reason !=
NULL) ? reason :
"unknown",
202 (proto !=
ETH_P_IP) ?
"Protocol != ETH_P_IP" :
"");
204 dst_link_failure(skb);
209 (reason !=
NULL) ? reason :
"reason unknown");
216 #ifdef CONFIG_ISDN_X25
222 #ifdef CONFIG_ISDN_X25
223 if (cprot && cprot->
pops && dops)
224 cprot->
pops->restart(cprot, dev, dops);
234 struct in_device *in_dev;
239 netif_start_queue(dev);
249 struct in_ifaddr *ifa = in_dev->ifa_list;
292 qdisc_reset_all_tx(lp->
netdev->dev);
318 static unsigned long last_jiffies = -
HZ;
334 if (dev->net_verbose > 3)
361 "isdn_net: %s: chtime = %lu, chint = %d\n",
384 isdn_net_rm_from_bundle(lp);
401 #ifdef CONFIG_ISDN_X25
410 isdn_net_dec_frame_cnt(lp);
411 lp->
stats.tx_packets++;
430 #ifdef CONFIG_ISDN_X25
442 isdn_net_ciscohdlck_disconnected(lp);
443 #ifdef CONFIG_ISDN_PPP
447 isdn_net_lp_disconnected(lp);
452 isdn_net_unbind_channel(lp);
456 #ifdef CONFIG_ISDN_X25
470 isdn_net_zero_frame_cnt(lp);
483 dev->rx_netdev[
idx] =
p;
487 isdn_net_ciscohdlck_connected(lp);
491 isdn_net_add_to_bundle(nd, lp);
504 #ifdef CONFIG_ISDN_PPP
508 #ifdef CONFIG_ISDN_X25
516 isdn_net_device_wake_queue(lp);
570 #ifdef ISDN_DEBUG_NET_DIAL
620 s =
"dial suppressed: isdn system stopped";
622 s =
"dial suppressed: dialmode `off'";
623 isdn_net_unreachable(p->
dev,
NULL, s);
651 isdn_net_unreachable(p->
dev,
NULL,
"dial: timed out");
662 if ((*phone_number ==
'v') ||
663 (*phone_number ==
'V')) {
681 isdn_net_unreachable(p->
dev,
NULL,
"dial: tried all numbers dialmax times");
699 #ifdef ISDN_DEBUG_NET_DIAL
742 #ifdef ISDN_DEBUG_NET_DIAL
753 #ifdef ISDN_DEBUG_NET_DIAL
784 #ifdef ISDN_DEBUG_NET_DIAL
832 #ifdef CONFIG_ISDN_X25
842 "isdn_net: hang up slave %s before %s\n",
848 #ifdef CONFIG_ISDN_PPP
852 isdn_net_lp_disconnected(lp);
853 #ifdef CONFIG_ISDN_X25
868 isdn_net_unbind_channel(lp);
880 const u_char *p = skb_network_header(skb);
908 #ifdef CONFIG_ISDN_PPP
916 data_ofs = ((p[0] & 15) * 4);
950 p + 12, p + 16, addinfo);
975 if (!isdn_net_lp_busy(lp)) {
992 while (!isdn_net_lp_busy(lp)) {
1012 if (isdn_net_lp_busy(lp)) {
1013 printk(
"isdn BUG at %s:%d!\n", __FILE__, __LINE__);
1018 printk(
"isdn BUG at %s:%d!\n", __FILE__, __LINE__);
1029 isdn_net_inc_frame_cnt(lp);
1034 lp->
stats.tx_errors++;
1059 printk(
"isdn BUG at %s:%d!\n", __FILE__, __LINE__);
1065 #ifdef CONFIG_ISDN_PPP
1071 lp = isdn_net_get_locked_lp(nd);
1123 const int pullsize = skb_network_offset(skb) -
ETH_HLEN;
1132 static void isdn_net_tx_timeout(
struct net_device *ndev)
1138 lp->
stats.tx_errors++;
1157 netif_wake_queue(ndev);
1169 #ifdef CONFIG_ISDN_X25
1182 if (cprot && cprot->
pops) {
1183 int ret = cprot->
pops->encap_and_xmit(cprot, skb);
1186 netif_stop_queue(ndev);
1192 #ifdef ISDN_DEBUG_NET_DUMP
1195 isdn_net_adjust_hdr(skb, ndev);
1196 #ifdef ISDN_DEBUG_NET_DUMP
1198 isdn_dumppkt(
"S:", buf, skb->
len, 40);
1205 isdn_net_unreachable(ndev, skb,
"dial rejected: interface not in dialmode `auto'");
1218 isdn_net_unreachable(ndev, skb,
"dial rejected: retry-time not reached");
1244 spin_unlock_irqrestore(&dev->lock, flags);
1245 isdn_net_unreachable(ndev, skb,
1251 if (dev->net_verbose)
1252 isdn_net_log_skb(skb, lp);
1255 isdn_net_bind_channel(lp, chi);
1256 #ifdef CONFIG_ISDN_PPP
1261 isdn_net_unbind_channel(lp);
1262 spin_unlock_irqrestore(&dev->lock, flags);
1265 #ifdef CONFIG_IPPP_FILTER
1268 isdn_net_unbind_channel(lp);
1269 spin_unlock_irqrestore(&dev->lock, flags);
1270 isdn_net_unreachable(ndev, skb,
"dial rejected: packet filtered");
1275 spin_unlock_irqrestore(&dev->lock, flags);
1277 netif_stop_queue(ndev);
1282 spin_unlock_irqrestore(&dev->lock, flags);
1284 isdn_net_device_stop_queue(lp);
1287 isdn_net_unreachable(ndev, skb,
1298 ret = (isdn_net_xmit(ndev, skb));
1299 if (ret) netif_stop_queue(ndev);
1302 netif_stop_queue(ndev);
1315 #ifdef CONFIG_ISDN_X25
1321 #ifdef CONFIG_ISDN_X25
1322 if (cprot && cprot->
pops) cprot->
pops->close(cprot);
1324 netif_stop_queue(dev);
1329 #ifdef CONFIG_ISDN_X25
1332 if (cprot && cprot->
pops)
1333 cprot->
pops->close(cprot);
1367 unsigned char *rawp;
1369 skb_reset_mac_header(skb);
1399 if (*(
unsigned short *) rawp == 0xFFFF)
1414 unsigned short hl = dev->drv[lp->
isdn_device]->interface->hl_hdrlen;
1419 skb_reserve(skb, hl);
1421 printk(
"isdn out of mem at %s:%d!\n", __FILE__, __LINE__);
1430 unsigned long len = 0;
1431 unsigned long expires = 0;
1453 if ((period > 0) && (period <= 32767))
1458 expires = (
unsigned long)(jiffies +
1477 ifr->ifr_data, len))
1479 if ((debserint >= 0) && (debserint <= 64))
1493 static int isdn_net_ioctl(
struct net_device *dev,
1494 struct ifreq *ifr,
int cmd)
1499 #ifdef CONFIG_ISDN_PPP
1504 return isdn_ciscohdlck_dev_ioctl(dev, ifr, cmd);
1512 isdn_net_ciscohdlck_slarp_send_keepalive(
unsigned long data)
1521 printk(
"isdn BUG at %s:%d!\n", __FILE__, __LINE__);
1531 "UPDOWN: Line protocol on Interface %s,"
1532 " changed state to down\n", lp->
netdev->dev->name);
1535 (myseq_diff >= 0) && (myseq_diff <= 2)) {
1539 "UPDOWN: Line protocol on Interface %s,"
1540 " changed state to up\n", lp->
netdev->dev->name);
1546 "myseq %lu, mineseen %lu%c, yourseen %lu, %s\n",
1552 skb = isdn_net_ciscohdlck_alloc_skb(lp, 4 + 14);
1583 skb = isdn_net_ciscohdlck_alloc_skb(lp, 4 + 14);
1616 isdn_net_ciscohdlck_slarp_send_request(lp);
1620 lp->
cisco_timer.function = isdn_net_ciscohdlck_slarp_send_keepalive;
1636 struct in_device *in_dev =
NULL;
1640 if ((in_dev = lp->
netdev->dev->ip_ptr) !=
NULL) {
1642 struct in_ifaddr *ifa = in_dev->ifa_list;
1644 addr = ifa->ifa_local;
1645 mask = ifa->ifa_mask;
1649 skb = isdn_net_ciscohdlck_alloc_skb(lp, 4 + 14);
1692 isdn_net_ciscohdlck_slarp_send_reply(lp);
1696 mask = (
__be32 *)(p + 4);
1698 goto slarp_reply_out;
1701 goto slarp_reply_out;
1703 printk(
KERN_INFO "%s: got slarp reply: remote ip: %pI4, local ip: %pI4 mask: %pI4\n",
1704 lp->
netdev->dev->name, addr, &local, mask);
1707 printk(
KERN_INFO "%s: got invalid slarp reply (%pI4/%pI4) - ignored\n",
1708 lp->
netdev->dev->name, addr, mask);
1712 +
HZ / 2 - 1) /
HZ);
1717 "is %d but should be %d.\n",
1718 lp->
netdev->dev->name, period,
1743 addr = *(
u8 *)(p + 0);
1744 ctrl = *(
u8 *)(p + 1);
1751 lp->
netdev->dev->name, addr);
1756 lp->
netdev->dev->name, ctrl);
1762 isdn_net_ciscohdlck_slarp_in(lp, skb);
1767 "\"no cdp enable\" on cisco.\n",
1789 #ifdef CONFIG_ISDN_X25
1794 lp->
stats.rx_packets++;
1801 lp = netdev_priv(ndev);
1802 lp->
stats.rx_packets++;
1807 skb_reset_mac_header(skb);
1808 #ifdef ISDN_DEBUG_NET_DUMP
1809 isdn_dumppkt(
"R:", skb->
data, skb->
len, 40);
1816 skb->
protocol = isdn_net_type_trans(skb, ndev);
1831 isdn_net_ciscohdlck_receive(lp, skb);
1843 if (*(
unsigned short *) skb->
data == 0xFFFF)
1846 #ifdef CONFIG_ISDN_PPP
1854 #ifdef CONFIG_ISDN_X25
1856 if (cprot)
if (cprot->
pops)
1857 if (cprot->
pops->data_ind) {
1858 cprot->
pops->data_ind(cprot, skb);
1886 isdn_net_receive(p->
dev, skb);
1899 unsigned short type,
1908 len =
eth_header(skb, dev, type, daddr, saddr, plen);
1910 #ifdef CONFIG_ISDN_PPP
1940 #ifdef CONFIG_ISDN_X25
1956 isdn_net_rebuild_header(
struct sk_buff *skb)
1971 "isdn_net: %s don't know how to resolve type %d addresses?\n",
1997 static void isdn_header_cache_update(
struct hh_cache *hh,
1999 const unsigned char *haddr)
2006 static const struct header_ops isdn_header_ops = {
2007 .create = isdn_net_header,
2008 .rebuild = isdn_net_rebuild_header,
2009 .cache = isdn_header_cache,
2010 .cache_update = isdn_header_cache_update,
2019 ushort max_hlhdr_len = 0;
2028 if (dev->drv[drvidx])
2029 if (max_hlhdr_len < dev->drv[drvidx]->
interface->hl_hdrlen)
2030 max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen;
2037 isdn_net_swapbind(
int drvidx)
2041 #ifdef ISDN_DEBUG_NET_ICALL
2060 isdn_net_swap_usage(
int i1,
int i2)
2065 #ifdef ISDN_DEBUG_NET_ICALL
2069 dev->usage[i1] |= u2;
2071 dev->usage[i2] |= u1;
2109 if (!setup->
phone[0]) {
2112 printk(
KERN_INFO "isdn_net: Incoming call without OAD, assuming '0'\n");
2116 si2 = (
int) setup->
si2;
2122 if (dev->net_verbose > 1)
2123 printk(
KERN_INFO "isdn_net: call from %s,%d,%d -> %s\n", nr, si1, si2, eaz);
2127 if ((si1 != 7) && (si1 != 1)) {
2128 if (dev->net_verbose > 1)
2129 printk(
KERN_INFO "isdn_net: Service-Indicator not 1 or 7, ignored\n");
2134 ematch = wret = swapped = 0;
2135 #ifdef ISDN_DEBUG_NET_ICALL
2146 isdn_net_swap_usage(idx, sidx);
2149 isdn_net_swapbind(di);
2156 if (*my_eaz ==
'v' || *my_eaz ==
'V' ||
2157 *my_eaz ==
'b' || *my_eaz ==
'B')
2162 if (*my_eaz ==
'b' || *my_eaz ==
'B')
2173 if (matchret > wret)
2175 #ifdef ISDN_DEBUG_NET_ICALL
2186 #ifdef ISDN_DEBUG_NET_ICALL
2204 #ifdef ISDN_DEBUG_NET_ICALL
2210 if (dev->usage[sidx] & ISDN_USAGE_EXCLUSIVE) {
2211 #ifdef ISDN_DEBUG_NET_ICALL
2218 isdn_net_swapbind(di);
2226 #ifdef ISDN_DEBUG_NET_ICALL
2230 isdn_net_swap_usage(idx, sidx);
2231 isdn_net_swapbind(di);
2235 #ifdef ISDN_DEBUG_NET_ICALL
2238 if ((dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) &&
2241 #ifdef ISDN_DEBUG_NET_ICALL
2250 #ifdef ISDN_DEBUG_NET_ICALL
2256 #ifdef ISDN_DEBUG_NET_ICALL
2268 #ifdef ISDN_DEBUG_NET_ICALL
2279 printk(
KERN_INFO "incoming call, interface %s `stopped' -> rejected\n",
2287 if (!isdn_net_device_started(p)) {
2302 while (mlp->
slave) {
2324 printk(
KERN_INFO "incoming call for callback, interface %s `off' -> rejected\n",
2329 p->
dev->name, nr, eaz);
2345 spin_unlock_irqrestore(&dev->lock, flags);
2352 isdn_net_bind_channel(lp, chi);
2353 #ifdef CONFIG_ISDN_PPP
2356 spin_unlock_irqrestore(&dev->lock, flags);
2357 isdn_net_unbind_channel(lp);
2361 spin_unlock_irqrestore(&dev->lock, flags);
2370 p->
dev->name, nr, eaz);
2374 #ifdef CONFIG_ISDN_PPP
2378 isdn_net_lp_disconnected(lp);
2385 strcpy(dev->num[idx], nr);
2398 #ifdef CONFIG_ISDN_PPP
2401 isdn_net_unbind_channel(lp);
2402 spin_unlock_irqrestore(&dev->lock, flags);
2407 spin_unlock_irqrestore(&dev->lock, flags);
2415 if (!ematch || dev->net_verbose)
2416 printk(
KERN_INFO "isdn_net: call from %s -> %d %s ignored\n", nr, di, eaz);
2417 return (wret == 2) ? 5 : 0;
2460 spin_unlock_irqrestore(&dev->lock, flags);
2465 isdn_net_bind_channel(lp, chi);
2466 #ifdef CONFIG_ISDN_PPP
2469 isdn_net_unbind_channel(lp);
2470 spin_unlock_irqrestore(&dev->lock, flags);
2475 spin_unlock_irqrestore(&dev->lock, flags);
2495 return isdn_net_force_dial_lp(lp);
2509 return (isdn_net_force_dial_lp(p->
local));
2514 .ndo_init = isdn_net_init,
2515 .ndo_open = isdn_net_open,
2516 .ndo_stop = isdn_net_close,
2517 .ndo_do_ioctl = isdn_net_ioctl,
2519 .ndo_start_xmit = isdn_net_start_xmit,
2520 .ndo_get_stats = isdn_net_get_stats,
2521 .ndo_tx_timeout = isdn_net_tx_timeout,
2527 static void _isdn_setup(
struct net_device *dev)
2597 netdev->
local = netdev_priv(netdev->
dev);
2633 netdev->
next = (
void *) dev->netdev;
2634 dev->netdev = netdev;
2635 return netdev->
dev->name;
2641 char *p =
strchr(parm,
',');
2658 if (isdn_net_device_started(n))
2691 if (i == ISDN_MAX_DRIVERS) {
2696 #ifdef CONFIG_ISDN_X25
2699 if (isdn_net_device_started(p)) {
2704 #ifdef CONFIG_ISDN_X25
2705 if (cprot && cprot->
pops)
2706 cprot->
pops->proto_del(cprot);
2724 #ifndef CONFIG_ISDN_PPP
2730 p->
dev->addr_len = 0;
2734 #ifndef CONFIG_ISDN_X25
2740 p->
dev->addr_len = 0;
2750 "%s: encapsulation protocol %d not supported\n",
2765 if ((c =
strchr(drvid,
','))) {
2774 if (!(
strcmp(dev->drvid[i], drvid))) {
2778 if ((drvidx == -1) || (chidx == -1))
2787 unsigned long flags;
2793 chidx, lp->
msn)) < 0) {
2796 spin_unlock_irqrestore(&dev->lock, flags);
2802 spin_unlock_irqrestore(&dev->lock, flags);
2853 "Old isdnctrl version detected! Please update.\n");
2876 p->
dev->header_ops = &isdn_header_ops;
2906 cfg->
drvid[0] =
'\0';
2937 cfg->
slave[0] =
'\0';
3023 if (ch < 0 && dv < 0)
3029 if (
strncmp(dev->num[idx],
"???", 3) == 0)
3080 for (i = 0; i < 2; i++) {
3125 if (isdn_net_device_started(p)) {
3128 #ifdef CONFIG_ISDN_X25
3129 if (p->cprot && p->cprot->pops)
3130 p->cprot->pops->proto_del(p->cprot);
3133 isdn_net_rmallphone(p);
3152 dev->netdev = p->
next;
3160 spin_unlock_irqrestore(&dev->lock, flags);
3161 isdn_net_realrm(n, q);
3169 spin_unlock_irqrestore(&dev->lock, flags);
3171 if (dev->netdev ==
NULL)
3195 spin_unlock_irqrestore(&dev->lock, flags);
3196 return (isdn_net_realrm(p, q));
3201 spin_unlock_irqrestore(&dev->lock, flags);
3203 if (dev->netdev ==
NULL)
3219 while (dev->netdev) {
3220 if (!dev->netdev->local->
master) {
3222 spin_unlock_irqrestore(&dev->lock, flags);
3223 if ((ret = isdn_net_realrm(dev->netdev,
NULL))) {
3230 spin_unlock_irqrestore(&dev->lock, flags);