12 #include <linux/errno.h>
13 #include <linux/hdlc.h>
14 #include <linux/if_arp.h>
17 #include <linux/kernel.h>
18 #include <linux/module.h>
20 #include <linux/poll.h>
21 #include <linux/rtnetlink.h>
24 #undef DEBUG_HARD_HEADER
26 #define CISCO_MULTICAST 0x8F
27 #define CISCO_UNICAST 0x0F
28 #define CISCO_KEEPALIVE 0x8035
29 #define CISCO_SYS_INFO 0x2000
30 #define CISCO_ADDR_REQ 0
31 #define CISCO_ADDR_REPLY 1
32 #define CISCO_KEEPALIVE_REQ 2
49 #define CISCO_PACKET_LEN 18
50 #define CISCO_BIG_PACKET_LEN 20
79 #ifdef DEBUG_HARD_HEADER
97 static void cisco_keepalive_send(
struct net_device *dev,
u32 type,
106 netdev_warn(dev,
"Memory squeeze on cisco_keepalive_send()\n");
123 skb_reset_network_header(skb);
153 static int cisco_rx(
struct sk_buff *skb)
160 struct in_device *in_dev;
182 netdev_info(dev,
"Invalid length of Cisco control packet (%d bytes)\n",
190 switch (
ntohl (cisco_data->type)) {
193 in_dev = __in_dev_get_rcu(dev);
197 if (in_dev !=
NULL) {
198 struct in_ifaddr **ifap = &in_dev->ifa_list;
200 while (*ifap !=
NULL) {
202 (*ifap)->ifa_label) == 0) {
203 addr = (*ifap)->ifa_local;
204 mask = (*ifap)->ifa_mask;
207 ifap = &(*ifap)->ifa_next;
218 netdev_info(dev,
"Unexpected Cisco IP address reply\n");
222 spin_lock(&st->
lock);
231 sec =
ntohl(cisco_data->time) / 1000;
232 min = sec / 60; sec -= min * 60;
233 hrs = min / 60; min -= hrs * 60;
234 days = hrs / 24; hrs -= days * 24;
235 netdev_info(dev,
"Link up (peer uptime %ud%uh%um%us)\n",
236 days, hrs, min, sec);
237 netif_dormant_off(dev);
241 spin_unlock(&st->
lock);
248 netdev_info(dev,
"Unsupported protocol %x\n",
ntohs(data->
protocol));
253 dev->
stats.rx_errors++;
260 static void cisco_timer(
unsigned long arg)
266 spin_lock(&st->
lock);
270 netdev_info(dev,
"Link down\n");
271 netif_dormant_on(dev);
276 spin_unlock(&st->
lock);
279 st->
timer.function = cisco_timer;
286 static void cisco_start(
struct net_device *dev)
294 spin_unlock_irqrestore(&st->
lock, flags);
298 st->
timer.function = cisco_timer;
305 static void cisco_stop(
struct net_device *dev)
314 netif_dormant_on(dev);
316 spin_unlock_irqrestore(&st->
lock, flags);
321 .start = cisco_start,
323 .type_trans = cisco_type_trans,
324 .ioctl = cisco_ioctl,
325 .netif_rx = cisco_rx,
329 static const struct header_ops cisco_header_ops = {
330 .create = cisco_hard_header,
341 switch (ifr->ifr_settings.type) {
343 if (dev_to_hdlc(dev)->proto != &proto)
346 if (ifr->ifr_settings.size < size) {
347 ifr->ifr_settings.size =
size;
377 memcpy(&
state(hdlc)->settings, &new_settings, size);
381 netif_dormant_on(dev);
389 static int __init mod_init(
void)
397 static void __exit mod_exit(
void)