summaryrefslogtreecommitdiffstats
path: root/net/rose
diff options
context:
space:
mode:
Diffstat (limited to 'net/rose')
-rw-r--r--net/rose/af_rose.c338
-rw-r--r--net/rose/rose_dev.c21
-rw-r--r--net/rose/rose_in.c20
-rw-r--r--net/rose/rose_link.c24
-rw-r--r--net/rose/rose_out.c11
-rw-r--r--net/rose/rose_route.c263
-rw-r--r--net/rose/rose_subr.c41
-rw-r--r--net/rose/rose_timer.c9
-rw-r--r--net/rose/sysctl_net_rose.c10
9 files changed, 398 insertions, 339 deletions
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index f3309ade9..bd0ecd843 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,10 +10,13 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from af_netrom.c.
+ * ROSE 001 Jonathan(G4KLX) Cloned from af_netrom.c.
* Alan(GW4PTS) Hacked up for newer API stuff
* Terry (VK2KTJ) Added support for variable length
* address masks.
+ * ROSE 002 Jonathan(G4KLX) Changed hdrincl to qbitincl.
+ * Added random number facilities entry.
+ * Variable number of ROSE devices.
*/
#include <linux/config.h>
@@ -54,6 +54,8 @@
#include <linux/if_arp.h>
#include <linux/init.h>
+int rose_ndevs = 6;
+
int sysctl_rose_restart_request_timeout = ROSE_DEFAULT_T0;
int sysctl_rose_call_request_timeout = ROSE_DEFAULT_T1;
int sysctl_rose_reset_request_timeout = ROSE_DEFAULT_T2;
@@ -62,8 +64,8 @@ int sysctl_rose_no_activity_timeout = ROSE_DEFAULT_IDLE;
int sysctl_rose_ack_hold_back_timeout = ROSE_DEFAULT_HB;
int sysctl_rose_routing_control = ROSE_DEFAULT_ROUTING;
int sysctl_rose_link_fail_timeout = ROSE_DEFAULT_FAIL_TIMEOUT;
-
-static unsigned int lci = 1;
+int sysctl_rose_maximum_vcs = ROSE_DEFAULT_MAXVC;
+int sysctl_rose_window_size = ROSE_DEFAULT_WINDOW_SIZE;
static struct sock *volatile rose_list = NULL;
@@ -72,7 +74,7 @@ static struct proto_ops rose_proto_ops;
ax25_address rose_callsign;
/*
- * Convert a Rose address into text.
+ * Convert a ROSE address into text.
*/
char *rose2asc(rose_address *addr)
{
@@ -94,7 +96,7 @@ char *rose2asc(rose_address *addr)
}
/*
- * Compare two Rose addresses, 0 == equal.
+ * Compare two ROSE addresses, 0 == equal.
*/
int rosecmp(rose_address *addr1, rose_address *addr2)
{
@@ -108,7 +110,7 @@ int rosecmp(rose_address *addr1, rose_address *addr2)
}
/*
- * Compare two Rose addresses for only mask digits, 0 == equal.
+ * Compare two ROSE addresses for only mask digits, 0 == equal.
*/
int rosecmpm(rose_address *addr1, rose_address *addr2, unsigned short mask)
{
@@ -134,7 +136,7 @@ int rosecmpm(rose_address *addr1, rose_address *addr2, unsigned short mask)
static void rose_free_sock(struct sock *sk)
{
- kfree_s(sk->protinfo.rose, sizeof(*sk->protinfo.rose));
+ kfree(sk->protinfo.rose);
sk_free(sk);
@@ -149,7 +151,7 @@ static struct sock *rose_alloc_sock(void)
if ((sk = sk_alloc(GFP_ATOMIC)) == NULL)
return NULL;
- if ((rose = (rose_cb *)kmalloc(sizeof(*rose), GFP_ATOMIC)) == NULL) {
+ if ((rose = kmalloc(sizeof(*rose), GFP_ATOMIC)) == NULL) {
sk_free(sk);
return NULL;
}
@@ -195,6 +197,27 @@ static void rose_remove_socket(struct sock *sk)
}
/*
+ * Kill all bound sockets on a broken link layer connection to a
+ * particular neighbour.
+ */
+void rose_kill_by_neigh(struct rose_neigh *neigh)
+{
+ struct sock *s;
+
+ for (s = rose_list; s != NULL; s = s->next) {
+ if (s->protinfo.rose->neighbour == neigh) {
+ s->protinfo.rose->state = ROSE_STATE_0;
+ s->protinfo.rose->neighbour = NULL;
+ s->state = TCP_CLOSE;
+ s->err = ENETUNREACH;
+ s->shutdown |= SEND_SHUTDOWN;
+ s->state_change(s);
+ s->dead = 1;
+ }
+ }
+}
+
+/*
* Kill all bound sockets on a dropped device.
*/
static void rose_kill_by_device(struct device *dev)
@@ -224,9 +247,15 @@ static int rose_device_event(struct notifier_block *this, unsigned long event, v
if (event != NETDEV_DOWN)
return NOTIFY_DONE;
- rose_kill_by_device(dev);
- rose_rt_device_down(dev);
- rose_link_device_down(dev);
+ switch (dev->type) {
+ case ARPHRD_ROSE:
+ rose_kill_by_device(dev);
+ break;
+ case ARPHRD_AX25:
+ rose_link_device_down(dev);
+ rose_rt_device_down(dev);
+ break;
+ }
return NOTIFY_DONE;
}
@@ -251,7 +280,7 @@ static void rose_insert_socket(struct sock *sk)
* Find a socket that wants to accept the Call Request we just
* received.
*/
-static struct sock *rose_find_listener(ax25_address *call)
+static struct sock *rose_find_listener(rose_address *addr, ax25_address *call)
{
unsigned long flags;
struct sock *s;
@@ -260,14 +289,14 @@ static struct sock *rose_find_listener(ax25_address *call)
cli();
for (s = rose_list; s != NULL; s = s->next) {
- if (ax25cmp(&s->protinfo.rose->source_call, call) == 0 && s->protinfo.rose->source_ndigis == 0 && s->state == TCP_LISTEN) {
+ if (rosecmp(&s->protinfo.rose->source_addr, addr) == 0 && ax25cmp(&s->protinfo.rose->source_call, call) == 0 && s->protinfo.rose->source_ndigis == 0 && s->state == TCP_LISTEN) {
restore_flags(flags);
return s;
}
}
for (s = rose_list; s != NULL; s = s->next) {
- if (ax25cmp(&s->protinfo.rose->source_call, &null_ax25_address) == 0 && s->state == TCP_LISTEN) {
+ if (rosecmp(&s->protinfo.rose->source_addr, addr) == 0 && ax25cmp(&s->protinfo.rose->source_call, &null_ax25_address) == 0 && s->state == TCP_LISTEN) {
restore_flags(flags);
return s;
}
@@ -278,9 +307,9 @@ static struct sock *rose_find_listener(ax25_address *call)
}
/*
- * Find a connected Rose socket given my LCI and device.
+ * Find a connected ROSE socket given my LCI and device.
*/
-struct sock *rose_find_socket(unsigned int lci, struct device *dev)
+struct sock *rose_find_socket(unsigned int lci, struct rose_neigh *neigh)
{
struct sock *s;
unsigned long flags;
@@ -289,7 +318,7 @@ struct sock *rose_find_socket(unsigned int lci, struct device *dev)
cli();
for (s = rose_list; s != NULL; s = s->next) {
- if (s->protinfo.rose->lci == lci && s->protinfo.rose->neighbour->dev == dev) {
+ if (s->protinfo.rose->lci == lci && s->protinfo.rose->neighbour == neigh) {
restore_flags(flags);
return s;
}
@@ -303,17 +332,21 @@ struct sock *rose_find_socket(unsigned int lci, struct device *dev)
/*
* Find a unique LCI for a given device.
*/
-unsigned int rose_new_lci(struct device *dev)
+unsigned int rose_new_lci(struct rose_neigh *neigh)
{
- lci++;
- if (lci > 4095) lci = 1;
+ int lci;
- while (rose_find_socket(lci, dev) != NULL) {
- lci++;
- if (lci > 4095) lci = 1;
+ if (neigh->dce_mode) {
+ for (lci = 1; lci <= sysctl_rose_maximum_vcs; lci++)
+ if (rose_find_socket(lci, neigh) == NULL && rose_route_free_lci(lci, neigh) == NULL)
+ return lci;
+ } else {
+ for (lci = sysctl_rose_maximum_vcs; lci > 0; lci--)
+ if (rose_find_socket(lci, neigh) == NULL && rose_route_free_lci(lci, neigh) == NULL)
+ return lci;
}
- return lci;
+ return 0;
}
/*
@@ -374,94 +407,9 @@ void rose_destroy_socket(struct sock *sk) /* Not static as it's used by the time
/*
* Handling for system calls applied via the various interfaces to a
- * Rose socket object.
+ * ROSE socket object.
*/
-/*
- * dl1bke 960311: set parameters for existing Rose connections,
- * includes a KILL command to abort any connection.
- * VERY useful for debugging ;-)
- */
-static int rose_ctl_ioctl(const unsigned int cmd, void *arg)
-{
- struct rose_ctl_struct rose_ctl;
- struct sock *sk;
- unsigned long flags;
- struct device *dev;
- int err;
-
- if ((err = verify_area(VERIFY_READ, arg, sizeof(rose_ctl))) != 0)
- return err;
-
- copy_from_user(&rose_ctl, arg, sizeof(rose_ctl));
-
- if ((dev = rose_ax25_dev_get(rose_ctl.dev)) == NULL)
- return -EINVAL;
-
- if ((sk = rose_find_socket(rose_ctl.lci, dev)) == NULL)
- return -ENOTCONN;
-
- switch (rose_ctl.cmd) {
- case ROSE_KILL:
- rose_clear_queues(sk);
- rose_write_internal(sk, ROSE_CLEAR_REQUEST);
- sk->protinfo.rose->state = ROSE_STATE_0;
- sk->state = TCP_CLOSE;
- sk->err = ENETRESET;
- sk->shutdown |= SEND_SHUTDOWN;
- if (!sk->dead)
- sk->state_change(sk);
- sk->dead = 1;
- rose_set_timer(sk);
- break;
-
- case ROSE_T1:
- if (rose_ctl.arg < 1)
- return -EINVAL;
- save_flags(flags); cli();
- sk->protinfo.rose->t1 = rose_ctl.arg * ROSE_SLOWHZ;
- restore_flags(flags);
- break;
-
- case ROSE_T2:
- if (rose_ctl.arg < 1)
- return -EINVAL;
- save_flags(flags); cli();
- sk->protinfo.rose->t2 = rose_ctl.arg * ROSE_SLOWHZ;
- restore_flags(flags);
- break;
-
- case ROSE_T3:
- if (rose_ctl.arg < 1)
- return -EINVAL;
- save_flags(flags); cli();
- sk->protinfo.rose->t3 = rose_ctl.arg * ROSE_SLOWHZ;
- restore_flags(flags);
- break;
-
- case ROSE_HOLDBACK:
- if (rose_ctl.arg < 1)
- return -EINVAL;
- save_flags(flags); cli();
- sk->protinfo.rose->hb = rose_ctl.arg * ROSE_SLOWHZ;
- restore_flags(flags);
- break;
-
- case ROSE_IDLE:
- if (rose_ctl.arg < 1)
- return -EINVAL;
- save_flags(flags); cli();
- sk->protinfo.rose->idle = rose_ctl.arg * 60 * ROSE_SLOWHZ;
- restore_flags(flags);
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static int rose_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen)
{
@@ -508,8 +456,8 @@ static int rose_setsockopt(struct socket *sock, int level, int optname,
sk->protinfo.rose->idle = opt * 60 * ROSE_SLOWHZ;
return 0;
- case ROSE_HDRINCL:
- sk->protinfo.rose->hdrincl = opt ? 1 : 0;
+ case ROSE_QBITINCL:
+ sk->protinfo.rose->qbitincl = opt ? 1 : 0;
return 0;
default:
@@ -551,8 +499,8 @@ static int rose_getsockopt(struct socket *sock, int level, int optname,
val = sk->protinfo.rose->idle / (ROSE_SLOWHZ * 60);
break;
- case ROSE_HDRINCL:
- val = sk->protinfo.rose->hdrincl;
+ case ROSE_QBITINCL:
+ val = sk->protinfo.rose->qbitincl;
break;
default:
@@ -654,8 +602,8 @@ static struct sock *rose_make_new(struct sock *osk)
rose->hb = osk->protinfo.rose->hb;
rose->idle = osk->protinfo.rose->idle;
- rose->device = osk->protinfo.rose->device;
- rose->hdrincl = osk->protinfo.rose->hdrincl;
+ rose->device = osk->protinfo.rose->device;
+ rose->qbitincl = osk->protinfo.rose->qbitincl;
return sk;
}
@@ -736,7 +684,7 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
return -EINVAL;
if ((dev = rose_dev_get(&addr->srose_addr)) == NULL) {
- SOCK_DEBUG(sk, "Rose: bind failed: invalid address\n");
+ SOCK_DEBUG(sk, "ROSE: bind failed: invalid address\n");
return -EADDRNOTAVAIL;
}
@@ -760,7 +708,7 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
rose_insert_socket(sk);
sk->zapped = 0;
- SOCK_DEBUG(sk, "Rose: socket is bound\n");
+ SOCK_DEBUG(sk, "ROSE: socket is bound\n");
return 0;
}
@@ -793,7 +741,10 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
if (addr->srose_family != AF_ROSE)
return -EINVAL;
- if ((sk->protinfo.rose->neighbour = rose_get_neigh(&addr->srose_addr)) == NULL)
+ if ((sk->protinfo.rose->neighbour = rose_get_neigh(&addr->srose_addr)) == NULL)
+ return -ENETUNREACH;
+
+ if ((sk->protinfo.rose->lci = rose_new_lci(sk->protinfo.rose->neighbour)) == 0)
return -ENETUNREACH;
if (sk->zapped) { /* Must bind first - autobinding in this may or may not work */
@@ -814,11 +765,12 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
sk->protinfo.rose->dest_addr = addr->srose_addr;
sk->protinfo.rose->dest_call = addr->srose_call;
+ sk->protinfo.rose->rand = ((int)sk->protinfo.rose & 0xFFFF) + sk->protinfo.rose->lci;
+
if (addr->srose_ndigis == 1) {
sk->protinfo.rose->dest_ndigis = 1;
sk->protinfo.rose->dest_digi = addr->srose_digi;
}
- sk->protinfo.rose->lci = rose_new_lci(sk->protinfo.rose->neighbour->dev);
/* Move to connecting socket, start sending Connect Requests */
sock->state = SS_CONNECTING;
@@ -954,7 +906,7 @@ int rose_rx_call_request(struct sk_buff *skb, struct device *dev, struct rose_ne
{
struct sock *sk;
struct sock *make;
- rose_cb rose;
+ struct rose_facilities facilities;
skb->sk = NULL; /* Initially we don't know who it's for */
@@ -965,11 +917,11 @@ int rose_rx_call_request(struct sk_buff *skb, struct device *dev, struct rose_ne
/*
* XXX This is an error.
*/
- if (!rose_parse_facilities(skb, &rose)) {
+ if (!rose_parse_facilities(skb, &facilities)) {
return 0;
}
- sk = rose_find_listener(&rose.source_call);
+ sk = rose_find_listener(&facilities.source_addr, &facilities.source_call);
/*
* We can't accept the Call Request.
@@ -983,14 +935,14 @@ int rose_rx_call_request(struct sk_buff *skb, struct device *dev, struct rose_ne
make->state = TCP_ESTABLISHED;
make->protinfo.rose->lci = lci;
- make->protinfo.rose->dest_addr = rose.dest_addr;
- make->protinfo.rose->dest_call = rose.dest_call;
- make->protinfo.rose->dest_ndigis = rose.dest_ndigis;
- make->protinfo.rose->dest_digi = rose.dest_digi;
- make->protinfo.rose->source_addr = rose.source_addr;
- make->protinfo.rose->source_call = rose.source_call;
- make->protinfo.rose->source_ndigis = rose.source_ndigis;
- make->protinfo.rose->source_digi = rose.source_digi;
+ make->protinfo.rose->dest_addr = facilities.dest_addr;
+ make->protinfo.rose->dest_call = facilities.dest_call;
+ make->protinfo.rose->dest_ndigis = facilities.dest_ndigis;
+ make->protinfo.rose->dest_digi = facilities.dest_digi;
+ make->protinfo.rose->source_addr = facilities.source_addr;
+ make->protinfo.rose->source_call = facilities.source_call;
+ make->protinfo.rose->source_ndigis = facilities.source_ndigis;
+ make->protinfo.rose->source_digi = facilities.source_digi;
make->protinfo.rose->neighbour = neigh;
make->protinfo.rose->device = dev;
@@ -1026,7 +978,7 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct sockaddr_rose srose;
struct sk_buff *skb;
unsigned char *asmptr;
- int size;
+ int size, qbit = 0;
if (msg->msg_flags & ~MSG_DONTWAIT)
return -EINVAL;
@@ -1039,7 +991,7 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
return -EPIPE;
}
- if (sk->protinfo.rose->device == NULL)
+ if (sk->protinfo.rose->neighbour == NULL || sk->protinfo.rose->device == NULL)
return -ENETUNREACH;
if (usrose != NULL) {
@@ -1069,44 +1021,55 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
srose.srose_digi = sk->protinfo.rose->dest_digi;
}
}
- SOCK_DEBUG(sk, "Rose: sendto: Addresses built.\n");
+
+ SOCK_DEBUG(sk, "ROSE: sendto: Addresses built.\n");
/* Build a packet */
- SOCK_DEBUG(sk, "Rose: sendto: building packet.\n");
+ SOCK_DEBUG(sk, "ROSE: sendto: building packet.\n");
size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN;
if ((skb = sock_alloc_send_skb(sk, size, 0, msg->msg_flags & MSG_DONTWAIT, &err)) == NULL)
return err;
- skb_reserve(skb, size - len);
+ skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN);
/*
- * Push down the Rose header
+ * Put the data on the end
*/
+ SOCK_DEBUG(sk, "ROSE: Appending user data\n");
- asmptr = skb_push(skb, ROSE_MIN_LEN);
- SOCK_DEBUG(sk, "Building Rose Header.\n");
+ asmptr = skb->h.raw = skb_put(skb, len);
- /* Build a Rose Transport header */
+ memcpy_fromiovec(asmptr, msg->msg_iov, len);
- *asmptr++ = ((sk->protinfo.rose->lci >> 8) & 0x0F) | ROSE_GFI;
- *asmptr++ = (sk->protinfo.rose->lci >> 0) & 0xFF;
- *asmptr++ = ROSE_DATA;
- SOCK_DEBUG(sk, "Built header.\n");
+ /*
+ * If the Q BIT Include socket option is in force, the first
+ * byte of the user data is the logical value of the Q Bit.
+ */
+ if (sk->protinfo.rose->qbitincl) {
+ qbit = skb->data[0];
+ skb_pull(skb, 1);
+ }
/*
- * Put the data on the end
+ * Push down the ROSE header
*/
+ asmptr = skb_push(skb, ROSE_MIN_LEN);
- skb->h.raw = skb_put(skb, len);
+ SOCK_DEBUG(sk, "ROSE: Building Network Header.\n");
- asmptr = skb->h.raw;
- SOCK_DEBUG(sk, "Rose: Appending user data\n");
+ /* Build a ROSE Network header */
+ asmptr[0] = ((sk->protinfo.rose->lci >> 8) & 0x0F) | ROSE_GFI;
+ asmptr[1] = (sk->protinfo.rose->lci >> 0) & 0xFF;
+ asmptr[2] = ROSE_DATA;
- /* User data follows immediately after the Rose transport header */
- memcpy_fromiovec(asmptr, msg->msg_iov, len);
- SOCK_DEBUG(sk, "Rose: Transmitting buffer\n");
+ if (qbit)
+ asmptr[0] |= ROSE_Q_BIT;
+
+ SOCK_DEBUG(sk, "ROSE: Built header.\n");
+ SOCK_DEBUG(sk, "ROSE: Transmitting buffer\n");
+
if (sk->state != TCP_ESTABLISHED) {
kfree_skb(skb, FREE_WRITE);
return -ENOTCONN;
@@ -1123,7 +1086,8 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, int size,
{
struct sock *sk = sock->sk;
struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name;
- int copied;
+ int copied, qbit;
+ unsigned char *asmptr;
struct sk_buff *skb;
int er;
@@ -1138,12 +1102,17 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, int size,
if ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL)
return er;
- if (!sk->protinfo.rose->hdrincl) {
- skb_pull(skb, ROSE_MIN_LEN);
- skb->h.raw = skb->data;
+ qbit = (skb->data[0] & ROSE_Q_BIT) == ROSE_Q_BIT;
+
+ skb_pull(skb, ROSE_MIN_LEN);
+
+ if (sk->protinfo.rose->qbitincl) {
+ asmptr = skb_push(skb, 1);
+ *asmptr = qbit;
}
- copied = skb->len;
+ skb->h.raw = skb->data;
+ copied = skb->len;
if (copied > size) {
copied = size;
@@ -1231,10 +1200,6 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
if (!suser()) return -EPERM;
return rose_rt_ioctl(cmd, (void *)arg);
- case SIOCRSCTLCON:
- if (!suser()) return -EPERM;
- return rose_ctl_ioctl(cmd, (void *)arg);
-
case SIOCRSL2CALL:
if (!suser()) return -EPERM;
if ((err = verify_area(VERIFY_READ, (void *)arg, sizeof(ax25_address))) != 0)
@@ -1373,14 +1338,7 @@ static struct proc_dir_entry proc_net_rose_routes = {
};
#endif
-static struct device dev_rose[] = {
- {"rose0", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, rose_init},
- {"rose1", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, rose_init},
- {"rose2", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, rose_init},
- {"rose3", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, rose_init},
- {"rose4", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, rose_init},
- {"rose5", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, rose_init}
-};
+static struct device *dev_rose;
__initfunc(void rose_proto_init(struct net_proto *pro))
{
@@ -1388,17 +1346,26 @@ __initfunc(void rose_proto_init(struct net_proto *pro))
rose_callsign = null_ax25_address;
- sock_register(&rose_family_ops);
- register_netdevice_notifier(&rose_dev_notifier);
- printk(KERN_INFO "G4KLX Rose for Linux. Version 0.1 for AX25.035 Linux 2.1\n");
+ if ((dev_rose = kmalloc(rose_ndevs * sizeof(struct device), GFP_KERNEL)) == NULL) {
+ printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
+ return;
+ }
- if (!ax25_protocol_register(AX25_P_ROSE, rose_route_frame))
- printk(KERN_ERR "Rose unable to register protocol with AX.25\n");
- if (!ax25_linkfail_register(rose_link_failed))
- printk(KERN_ERR "Rose unable to register linkfail handler with AX.25\n");
+ memset(dev_rose, 0x00, rose_ndevs * sizeof(struct device));
- for (i = 0; i < 6; i++)
+ for (i = 0; i < rose_ndevs; i++) {
+ dev_rose[i].name = kmalloc(20, GFP_KERNEL);
+ sprintf(dev_rose[i].name, "rose%d", i);
+ dev_rose[i].init = rose_init;
register_netdev(&dev_rose[i]);
+ }
+
+ sock_register(&rose_family_ops);
+ register_netdevice_notifier(&rose_dev_notifier);
+ printk(KERN_INFO "G4KLX ROSE for Linux. Version 0.2 for AX25.035 Linux 2.1\n");
+
+ ax25_protocol_register(AX25_P_ROSE, rose_route_frame);
+ ax25_linkfail_register(rose_link_failed);
#ifdef CONFIG_SYSCTL
rose_register_sysctl();
@@ -1415,6 +1382,12 @@ __initfunc(void rose_proto_init(struct net_proto *pro))
#ifdef MODULE
EXPORT_NO_SYMBOLS;
+MODULE_PARM(rose_ndevs, "i");
+MODULE_PARM_DESC(rose_ndevs, "number of ROSE devices");
+
+MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
+MODULE_DESCRIPTION("The amateur radio ROSE network layer protocol");
+
int init_module(void)
{
rose_proto_init(NULL);
@@ -1447,13 +1420,16 @@ void cleanup_module(void)
sock_unregister(AF_ROSE);
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < rose_ndevs; i++) {
if (dev_rose[i].priv != NULL) {
kfree(dev_rose[i].priv);
dev_rose[i].priv = NULL;
unregister_netdev(&dev_rose[i]);
}
+ kfree(dev_rose[i].name);
}
+
+ kfree(dev_rose);
}
#endif
diff --git a/net/rose/rose_dev.c b/net/rose/rose_dev.c
index ebab50e0d..73d0aa552 100644
--- a/net/rose/rose_dev.c
+++ b/net/rose/rose_dev.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from nr_dev.c.
+ * ROSE 001 Jonathan(G4KLX) Cloned from nr_dev.c.
* Hans(PE1AYX) Fixed interface to IP layer.
*/
@@ -52,7 +49,7 @@
#include <net/rose.h>
/*
- * Only allow IP over Rose frames through if the netrom device is up.
+ * Only allow IP over ROSE frames through if the netrom device is up.
*/
int rose_rx_ip(struct sk_buff *skb, struct device *dev)
@@ -175,7 +172,7 @@ static int rose_xmit(struct sk_buff *skb, struct device *dev)
return 0;
if (!dev->start) {
- printk(KERN_ERR "rose: xmit call when iface is down\n");
+ printk(KERN_ERR "ROSE: rose_xmit - called when iface is down\n");
return 1;
}
@@ -226,10 +223,12 @@ int rose_init(struct device *dev)
dev->flags = 0;
dev->family = AF_INET;
- dev->pa_addr = 0;
- dev->pa_brdaddr = 0;
- dev->pa_mask = 0;
- dev->pa_alen = sizeof(unsigned long);
+#ifdef CONFIG_INET
+ dev->pa_addr = in_aton("192.168.0.1");
+ dev->pa_brdaddr = in_aton("192.168.0.255");
+ dev->pa_mask = in_aton("255.255.255.0");
+ dev->pa_alen = 4;
+#endif
if ((dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL)) == NULL)
return -ENOMEM;
diff --git a/net/rose/rose_in.c b/net/rose/rose_in.c
index 66521efa8..3c3e17b2b 100644
--- a/net/rose/rose_in.c
+++ b/net/rose/rose_in.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -19,7 +16,7 @@
* easy to break;
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from nr_in.c
+ * ROSE 001 Jonathan(G4KLX) Cloned from nr_in.c
*/
#include <linux/config.h>
@@ -116,8 +113,7 @@ static int rose_state1_machine(struct sock *sk, struct sk_buff *skb, int framety
sk->dead = 1;
break;
- default: /* XXX */
- printk(KERN_WARNING "rose: unknown %02X in state 1\n", frametype);
+ default:
break;
}
@@ -146,8 +142,7 @@ static int rose_state2_machine(struct sock *sk, struct sk_buff *skb, int framety
sk->dead = 1;
break;
- default: /* XXX */
- printk(KERN_WARNING "rose: unknown %02X in state 2\n", frametype);
+ default:
break;
}
@@ -245,7 +240,7 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
* If the window is full, ack the frame, else start the
* acknowledge hold back timer.
*/
- if (((sk->protinfo.rose->vl + ROSE_MAX_WINDOW_SIZE) % ROSE_MODULUS) == sk->protinfo.rose->vr) {
+ if (((sk->protinfo.rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == sk->protinfo.rose->vr) {
sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
sk->protinfo.rose->timer = 0;
rose_enquiry_response(sk);
@@ -256,7 +251,7 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
break;
default:
- printk(KERN_WARNING "rose: unknown %02X in state 3\n", frametype);
+ printk(KERN_WARNING "ROSE: unknown %02X in state 3\n", frametype);
break;
}
@@ -297,8 +292,7 @@ static int rose_state4_machine(struct sock *sk, struct sk_buff *skb, int framety
sk->dead = 1;
break;
- default: /* XXX */
- printk(KERN_WARNING "rose: unknown %02X in state 4\n", frametype);
+ default:
break;
}
diff --git a/net/rose/rose_link.c b/net/rose/rose_link.c
index 9f1a0c0f5..86626511e 100644
--- a/net/rose/rose_link.c
+++ b/net/rose/rose_link.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from rose_timer.c
+ * ROSE 001 Jonathan(G4KLX) Cloned from rose_timer.c
*/
#include <linux/config.h>
@@ -62,7 +59,7 @@ void rose_link_set_timer(struct rose_neigh *neigh)
}
/*
- * Rose Link Timer
+ * ROSE Link Timer
*
* This routine is called every 100ms. Decrement timer by this
* amount - if expired then process the event.
@@ -79,7 +76,8 @@ static void rose_link_timer(unsigned long param)
if (neigh->t0timer == 0) {
rose_transmit_restart_request(neigh);
- neigh->t0timer = sysctl_rose_restart_request_timeout;
+ neigh->dce_mode = 0;
+ neigh->t0timer = sysctl_rose_restart_request_timeout;
}
}
@@ -134,6 +132,7 @@ void rose_link_rx_restart(struct sk_buff *skb, struct rose_neigh *neigh, unsigne
case ROSE_RESTART_REQUEST:
neigh->t0timer = 0;
neigh->restarted = 1;
+ neigh->dce_mode = (skb->data[3] == 0x00);
del_timer(&neigh->timer);
rose_transmit_restart_confirmation(neigh);
break;
@@ -145,11 +144,11 @@ void rose_link_rx_restart(struct sk_buff *skb, struct rose_neigh *neigh, unsigne
break;
case ROSE_DIAGNOSTIC:
- printk(KERN_WARNING "rose: diagnostic #%d\n", skb->data[3]);
+ printk(KERN_WARNING "ROSE: received diagnostic #%d - %02X %02X %02X\n", skb->data[3], skb->data[4], skb->data[5], skb->data[6]);
break;
default:
- printk(KERN_WARNING "rose: received unknown %02X with LCI 000\n", frametype);
+ printk(KERN_WARNING "ROSE: received unknown %02X with LCI 000\n", frametype);
break;
}
@@ -278,8 +277,10 @@ void rose_transmit_link(struct sk_buff *skb, struct rose_neigh *neigh)
{
unsigned char *dptr;
- if (call_fw_firewall(PF_ROSE, skb->dev, skb->data, NULL,&skb) != FW_ACCEPT)
+ if (call_fw_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT) {
+ kfree_skb(skb, FREE_WRITE);
return;
+ }
if (!rose_link_up(neigh))
neigh->restarted = 0;
@@ -295,7 +296,8 @@ void rose_transmit_link(struct sk_buff *skb, struct rose_neigh *neigh)
if (neigh->t0timer == 0) {
rose_transmit_restart_request(neigh);
- neigh->t0timer = sysctl_rose_restart_request_timeout;
+ neigh->dce_mode = 0;
+ neigh->t0timer = sysctl_rose_restart_request_timeout;
rose_link_set_timer(neigh);
}
}
diff --git a/net/rose/rose_out.c b/net/rose/rose_out.c
index 8ab4d9325..f0e212dc3 100644
--- a/net/rose/rose_out.c
+++ b/net/rose/rose_out.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from nr_out.c
+ * ROSE 001 Jonathan(G4KLX) Cloned from nr_out.c
*/
#include <linux/config.h>
@@ -41,7 +38,7 @@
#include <net/rose.h>
/*
- * This is where all Rose frames pass;
+ * This is where all ROSE frames pass;
*/
void rose_output(struct sock *sk, struct sk_buff *skb)
{
@@ -109,7 +106,7 @@ void rose_kick(struct sock *sk)
del_timer(&sk->timer);
- end = (sk->protinfo.rose->va + ROSE_MAX_WINDOW_SIZE) % ROSE_MODULUS;
+ end = (sk->protinfo.rose->va + sysctl_rose_window_size) % ROSE_MODULUS;
if (!(sk->protinfo.rose->condition & ROSE_COND_PEER_RX_BUSY) &&
sk->protinfo.rose->vs != end &&
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 19a53d40d..5b1338609 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,9 +10,11 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from nr_route.c.
+ * ROSE 001 Jonathan(G4KLX) Cloned from nr_route.c.
* Terry(VK2KTJ) Added support for variable length
* address masks.
+ * ROSE 002 Jonathan(G4KLX) Uprated through routing of packets.
+ * Routing loop detection.
*/
#include <linux/config.h>
@@ -76,13 +75,14 @@ static int rose_add_node(struct rose_route_struct *rose_route, struct device *de
break;
if (rose_neigh == NULL) {
- if ((rose_neigh = (struct rose_neigh *)kmalloc(sizeof(*rose_neigh), GFP_ATOMIC)) == NULL)
+ if ((rose_neigh = kmalloc(sizeof(*rose_neigh), GFP_ATOMIC)) == NULL)
return -ENOMEM;
rose_neigh->callsign = rose_route->neighbour;
rose_neigh->digipeat = NULL;
rose_neigh->dev = dev;
rose_neigh->count = 0;
+ rose_neigh->dce_mode = 0;
rose_neigh->number = rose_neigh_no++;
rose_neigh->restarted = 0;
skb_queue_head_init(&rose_neigh->queue);
@@ -92,7 +92,7 @@ static int rose_add_node(struct rose_route_struct *rose_route, struct device *de
if (rose_route->ndigis != 0) {
if ((rose_neigh->digipeat = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) {
- kfree_s(rose_neigh, sizeof(*rose_neigh));
+ kfree(rose_neigh);
return -ENOMEM;
}
rose_neigh->digipeat->ndigi = rose_route->ndigis;
@@ -127,7 +127,7 @@ static int rose_add_node(struct rose_route_struct *rose_route, struct device *de
}
/* create new node */
- if ((rose_node = (struct rose_node *)kmalloc(sizeof(*rose_node), GFP_ATOMIC)) == NULL)
+ if ((rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC)) == NULL)
return -ENOMEM;
rose_node->address = rose_route->address;
@@ -183,7 +183,7 @@ static void rose_remove_node(struct rose_node *rose_node)
if ((s = rose_node_list) == rose_node) {
rose_node_list = rose_node->next;
restore_flags(flags);
- kfree_s(rose_node, sizeof(struct rose_node));
+ kfree(rose_node);
return;
}
@@ -191,7 +191,7 @@ static void rose_remove_node(struct rose_node *rose_node)
if (s->next == rose_node) {
s->next = rose_node->next;
restore_flags(flags);
- kfree_s(rose_node, sizeof(struct rose_node));
+ kfree(rose_node);
return;
}
@@ -219,8 +219,8 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
rose_neigh_list = rose_neigh->next;
restore_flags(flags);
if (rose_neigh->digipeat != NULL)
- kfree_s(rose_neigh->digipeat, sizeof(ax25_digi));
- kfree_s(rose_neigh, sizeof(struct rose_neigh));
+ kfree(rose_neigh->digipeat);
+ kfree(rose_neigh);
return;
}
@@ -229,8 +229,8 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
s->next = rose_neigh->next;
restore_flags(flags);
if (rose_neigh->digipeat != NULL)
- kfree_s(rose_neigh->digipeat, sizeof(ax25_digi));
- kfree_s(rose_neigh, sizeof(struct rose_neigh));
+ kfree(rose_neigh->digipeat);
+ kfree(rose_neigh);
return;
}
@@ -251,7 +251,7 @@ static void rose_remove_route(struct rose_route *rose_route)
if ((s = rose_route_list) == rose_route) {
rose_route_list = rose_route->next;
restore_flags(flags);
- kfree_s(rose_route, sizeof(struct rose_route));
+ kfree(rose_route);
return;
}
@@ -259,7 +259,7 @@ static void rose_remove_route(struct rose_route *rose_route)
if (s->next == rose_route) {
s->next = rose_route->next;
restore_flags(flags);
- kfree_s(rose_route, sizeof(struct rose_route));
+ kfree(rose_route);
return;
}
@@ -372,7 +372,7 @@ void rose_route_device_down(struct device *dev)
struct rose_route *s, *rose_route = rose_route_list;
while (rose_route != NULL) {
- s = rose_route;
+ s = rose_route;
rose_route = rose_route->next;
if (s->neigh1->dev == dev || s->neigh2->dev == dev)
@@ -397,7 +397,7 @@ struct device *rose_ax25_dev_get(char *devname)
}
/*
- * Find the first active Rose device, usually "rose0".
+ * Find the first active ROSE device, usually "rose0".
*/
struct device *rose_dev_first(void)
{
@@ -412,7 +412,7 @@ struct device *rose_dev_first(void)
}
/*
- * Find the Rose device for the given address.
+ * Find the ROSE device for the given address.
*/
struct device *rose_dev_get(rose_address *addr)
{
@@ -425,23 +425,34 @@ struct device *rose_dev_get(rose_address *addr)
return NULL;
}
+struct rose_route *rose_route_free_lci(unsigned int lci, struct rose_neigh *neigh)
+{
+ struct rose_route *rose_route;
+
+ for (rose_route = rose_route_list; rose_route != NULL; rose_route = rose_route->next)
+ if ((rose_route->neigh1 == neigh && rose_route->lci1 == lci) ||
+ (rose_route->neigh2 == neigh && rose_route->lci2 == lci))
+ return rose_route;
+
+ return NULL;
+}
+
/*
- * Find a neighbour given a Rose address.
+ * Find a neighbour given a ROSE address.
*/
struct rose_neigh *rose_get_neigh(rose_address *addr)
{
struct rose_node *node;
int i;
- for (node = rose_node_list; node != NULL; node = node->next)
- if (rosecmpm(addr, &node->address, node->mask) == 0)
- break;
-
- if (node == NULL) return NULL;
-
- for (i = 0; i < node->count; i++)
- if (node->neighbour[i]->ftimer == 0)
- return node->neighbour[i];
+ for (node = rose_node_list; node != NULL; node = node->next) {
+ if (rosecmpm(addr, &node->address, node->mask) == 0) {
+ for (i = 0; i < node->count; i++) {
+ if (node->neighbour[i]->ftimer == 0)
+ return node->neighbour[i];
+ }
+ }
+ }
return NULL;
}
@@ -485,14 +496,54 @@ int rose_rt_ioctl(unsigned int cmd, void *arg)
return 0;
}
+static void rose_del_route_by_neigh(struct rose_neigh *rose_neigh)
+{
+ struct rose_route *rose_route, *s;
+ struct sk_buff *skb;
+
+ rose_neigh->restarted = 0;
+ rose_neigh->t0timer = 0;
+ rose_neigh->ftimer = sysctl_rose_link_fail_timeout;
+
+ rose_link_set_timer(rose_neigh);
+
+ while ((skb = skb_dequeue(&rose_neigh->queue)) != NULL)
+ kfree_skb(skb, FREE_WRITE);
+
+ rose_route = rose_route_list;
+
+ while (rose_route != NULL) {
+ if ((rose_route->neigh1 == rose_neigh && rose_route->neigh2 == rose_neigh) ||
+ (rose_route->neigh1 == rose_neigh && rose_route->neigh2 == NULL) ||
+ (rose_route->neigh2 == rose_neigh && rose_route->neigh1 == NULL)) {
+ s = rose_route->next;
+ rose_remove_route(rose_route);
+ rose_route = s;
+ continue;
+ }
+
+ if (rose_route->neigh1 == rose_neigh) {
+ rose_route->neigh1 = NULL;
+ rose_transmit_clear_request(rose_route->neigh2, rose_route->lci2, 0x0D);
+ }
+
+ if (rose_route->neigh2 == rose_neigh) {
+ rose_route->neigh2 = NULL;
+ rose_transmit_clear_request(rose_route->neigh1, rose_route->lci1, 0x0D);
+ }
+
+ rose_route = rose_route->next;
+ }
+}
+
/*
* A level 2 link has timed out, therefore it appears to be a poor link,
- * then don't use that neighbour until it is reset. XXX others.
+ * then don't use that neighbour until it is reset. Blow away all through
+ * routes and connections using this route.
*/
void rose_link_failed(ax25_address *callsign, struct device *dev)
{
struct rose_neigh *rose_neigh;
- struct sk_buff *skb;
for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next)
if (ax25cmp(&rose_neigh->callsign, callsign) == 0 && rose_neigh->dev == dev)
@@ -500,33 +551,22 @@ void rose_link_failed(ax25_address *callsign, struct device *dev)
if (rose_neigh == NULL) return;
- rose_neigh->restarted = 0;
- rose_neigh->t0timer = 0;
- rose_neigh->ftimer = sysctl_rose_link_fail_timeout;
-
- rose_link_set_timer(rose_neigh);
-
- while ((skb = skb_dequeue(&rose_neigh->queue)) != NULL)
- kfree_skb(skb, FREE_WRITE);
+ rose_del_route_by_neigh(rose_neigh);
+ rose_kill_by_neigh(rose_neigh);
}
/*
- * A device has been "downed" remove its link status. XXX others.
+ * A device has been "downed" remove its link status. Blow away all
+ * through routes and connections that use this device.
*/
void rose_link_device_down(struct device *dev)
{
struct rose_neigh *rose_neigh;
- struct sk_buff *skb;
for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next) {
if (rose_neigh->dev == dev) {
- rose_neigh->restarted = 0;
- rose_neigh->t0timer = 0;
- rose_neigh->ftimer = 0;
- del_timer(&rose_neigh->timer);
-
- while ((skb = skb_dequeue(&rose_neigh->queue)) != NULL)
- kfree_skb(skb, FREE_WRITE);
+ rose_del_route_by_neigh(rose_neigh);
+ rose_kill_by_neigh(rose_neigh);
}
}
}
@@ -538,10 +578,11 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
{
struct rose_neigh *rose_neigh, *new_neigh;
struct rose_route *rose_route;
+ struct rose_facilities facilities;
rose_address *src_addr, *dest_addr;
struct sock *sk;
unsigned short frametype;
- unsigned int lci;
+ unsigned int lci, new_lci;
struct device *dev;
unsigned long flags;
@@ -577,7 +618,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
/*
* Find an existing socket.
*/
- if ((sk = rose_find_socket(lci, rose_neigh->dev)) != NULL) {
+ if ((sk = rose_find_socket(lci, rose_neigh)) != NULL) {
skb->h.raw = skb->data;
return rose_process_rx_frame(sk, skb);
}
@@ -597,29 +638,36 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
/*
* Route it to the next in line if we have an entry for it.
*/
-
- /*
- * We should check for the random number in the facilities
- * here. XXX.
- */
for (rose_route = rose_route_list; rose_route != NULL; rose_route = rose_route->next) {
if (rose_route->lci1 == lci && rose_route->neigh1 == rose_neigh) {
- skb->data[0] &= 0xF0;
- skb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;
- skb->data[1] = (rose_route->lci2 >> 0) & 0xFF;
- rose_transmit_link(skb, rose_route->neigh2);
- if (frametype == ROSE_CLEAR_CONFIRMATION)
- rose_remove_route(rose_route);
- return 1;
+ if (rose_route->neigh2 != NULL) {
+ skb->data[0] &= 0xF0;
+ skb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;
+ skb->data[1] = (rose_route->lci2 >> 0) & 0xFF;
+ rose_transmit_link(skb, rose_route->neigh2);
+ if (frametype == ROSE_CLEAR_CONFIRMATION)
+ rose_remove_route(rose_route);
+ return 1;
+ } else {
+ if (frametype == ROSE_CLEAR_CONFIRMATION)
+ rose_remove_route(rose_route);
+ return 0;
+ }
}
if (rose_route->lci2 == lci && rose_route->neigh2 == rose_neigh) {
- skb->data[0] &= 0xF0;
- skb->data[0] |= (rose_route->lci1 >> 8) & 0x0F;
- skb->data[1] = (rose_route->lci1 >> 0) & 0xFF;
- rose_transmit_link(skb, rose_route->neigh1);
- if (frametype == ROSE_CLEAR_CONFIRMATION)
- rose_remove_route(rose_route);
- return 1;
+ if (rose_route->neigh1 != NULL) {
+ skb->data[0] &= 0xF0;
+ skb->data[0] |= (rose_route->lci1 >> 8) & 0x0F;
+ skb->data[1] = (rose_route->lci1 >> 0) & 0xFF;
+ rose_transmit_link(skb, rose_route->neigh1);
+ if (frametype == ROSE_CLEAR_CONFIRMATION)
+ rose_remove_route(rose_route);
+ return 1;
+ } else {
+ if (frametype == ROSE_CLEAR_CONFIRMATION)
+ rose_remove_route(rose_route);
+ return 0;
+ }
}
}
@@ -631,20 +679,49 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
if (frametype != ROSE_CALL_REQUEST) /* XXX */
return 0;
+ rose_parse_facilities(skb, &facilities);
+
+ /*
+ * Check for routing loops.
+ */
+ for (rose_route = rose_route_list; rose_route != NULL; rose_route = rose_route->next) {
+ if (rose_route->rand == facilities.rand &&
+ rosecmp(src_addr, &rose_route->src_addr) == 0 &&
+ ax25cmp(&facilities.dest_call, &rose_route->src_call) == 0 &&
+ ax25cmp(&facilities.source_call, &rose_route->dest_call) == 0) {
+ printk(KERN_DEBUG "ROSE: routing loop from %s\n", rose2asc(src_addr));
+ printk(KERN_DEBUG "ROSE: to %s\n", rose2asc(dest_addr));
+ rose_transmit_clear_request(rose_neigh, lci, 0x0D);
+ return 0;
+ }
+ }
+
if ((new_neigh = rose_get_neigh(dest_addr)) == NULL) {
+ printk(KERN_DEBUG "ROSE: no route to %s\n", rose2asc(dest_addr));
rose_transmit_clear_request(rose_neigh, lci, 0x0D);
return 0;
}
- if ((rose_route = (struct rose_route *)kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {
+ if ((new_lci = rose_new_lci(new_neigh)) == 0) {
+ printk(KERN_DEBUG "ROSE: no spare VCs to %s\n", rose2asc(dest_addr));
rose_transmit_clear_request(rose_neigh, lci, 0x0D);
return 0;
}
- rose_route->lci1 = lci;
- rose_route->neigh1 = rose_neigh;
- rose_route->lci2 = rose_new_lci(new_neigh->dev);
- rose_route->neigh2 = new_neigh;
+ if ((rose_route = kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {
+ rose_transmit_clear_request(rose_neigh, lci, 0x0D);
+ return 0;
+ }
+
+ rose_route->lci1 = lci;
+ rose_route->src_addr = *src_addr;
+ rose_route->dest_addr = *dest_addr;
+ rose_route->src_call = facilities.dest_call;
+ rose_route->dest_call = facilities.source_call;
+ rose_route->rand = facilities.rand;
+ rose_route->neigh1 = rose_neigh;
+ rose_route->lci2 = new_lci;
+ rose_route->neigh2 = new_neigh;
save_flags(flags); cli();
rose_route->next = rose_route_list;
@@ -716,14 +793,15 @@ int rose_neigh_get_info(char *buffer, char **start, off_t offset,
cli();
- len += sprintf(buffer, "addr callsign dev count restart t0 tf\n");
+ len += sprintf(buffer, "addr callsign dev count mode restart t0 tf\n");
for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next) {
- len += sprintf(buffer + len, "%05d %-9s %-4s %3d %3s %3d %3d\n",
+ len += sprintf(buffer + len, "%05d %-9s %-4s %3d %3s %3s %3d %3d\n",
rose_neigh->number,
ax2asc(&rose_neigh->callsign),
rose_neigh->dev ? rose_neigh->dev->name : "???",
rose_neigh->count,
+ (rose_neigh->dce_mode) ? "DCE" : "DTE",
(rose_neigh->restarted) ? "yes" : "no",
rose_neigh->t0timer / ROSE_SLOWHZ,
rose_neigh->ftimer / ROSE_SLOWHZ);
@@ -759,17 +837,28 @@ int rose_routes_get_info(char *buffer, char **start, off_t offset,
cli();
- len += sprintf(buffer, "lci callsign dev <-> lci callsign dev\n");
+ len += sprintf(buffer, "lci address callsign neigh <-> lci address callsign neigh\n");
for (rose_route = rose_route_list; rose_route != NULL; rose_route = rose_route->next) {
- len += sprintf(buffer + len, "%3.3X %-9s %-4s ",
- rose_route->lci1,
- ax2asc(&rose_route->neigh1->callsign),
- rose_route->neigh1->dev ? rose_route->neigh1->dev->name : "???");
- len += sprintf(buffer + len, "%3.3X %-9s %-4s\n",
- rose_route->lci2,
- ax2asc(&rose_route->neigh2->callsign),
- rose_route->neigh2->dev ? rose_route->neigh2->dev->name : "???");
+ if (rose_route->neigh1 != NULL) {
+ len += sprintf(buffer + len, "%3.3X %-10s %-9s %05d ",
+ rose_route->lci1,
+ rose2asc(&rose_route->src_addr),
+ ax2asc(&rose_route->src_call),
+ rose_route->neigh1->number);
+ } else {
+ len += sprintf(buffer + len, "000 * * 00000 ");
+ }
+
+ if (rose_route->neigh2 != NULL) {
+ len += sprintf(buffer + len, "%3.3X %-10s %-9s %05d\n",
+ rose_route->lci2,
+ rose2asc(&rose_route->dest_addr),
+ ax2asc(&rose_route->dest_call),
+ rose_route->neigh2->number);
+ } else {
+ len += sprintf(buffer + len, "000 * * 00000\n");
+ }
pos = begin + len;
@@ -795,7 +884,7 @@ int rose_routes_get_info(char *buffer, char **start, off_t offset,
#ifdef MODULE
/*
- * Release all memory associated with Rose routing structures.
+ * Release all memory associated with ROSE routing structures.
*/
void rose_rt_free(void)
{
@@ -811,7 +900,7 @@ void rose_rt_free(void)
}
while (rose_node != NULL) {
- t = rose_node;
+ t = rose_node;
rose_node = rose_node->next;
rose_remove_node(t);
diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c
index 5befcbb60..4e0530cb4 100644
--- a/net/rose/rose_subr.c
+++ b/net/rose/rose_subr.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from nr_subr.c
+ * ROSE 001 Jonathan(G4KLX) Cloned from nr_subr.c
*/
#include <linux/config.h>
@@ -173,7 +170,7 @@ void rose_write_internal(struct sock *sk, int frametype)
break;
default:
- printk(KERN_ERR "rose_write_internal: invalid frametype %02X\n", frametype);
+ printk(KERN_ERR "ROSE: rose_write_internal - invalid frametype %02X\n", frametype);
kfree_skb(skb, FREE_WRITE);
return;
}
@@ -227,7 +224,7 @@ int rose_decode(struct sk_buff *skb, int *ns, int *nr, int *q, int *d, int *m)
return ROSE_ILLEGAL;
}
-static int rose_parse_national(unsigned char *p, rose_cb *rose, int len)
+static int rose_parse_national(unsigned char *p, struct rose_facilities *facilities, int len)
{
unsigned char l, n = 0;
@@ -241,7 +238,7 @@ static int rose_parse_national(unsigned char *p, rose_cb *rose, int len)
case 0x40:
if (*p == FAC_NATIONAL_RAND)
- rose->rand = ((p[1] << 8) & 0xFF00) + ((p[2] << 0) & 0x00FF);
+ facilities->rand = ((p[1] << 8) & 0xFF00) + ((p[2] << 0) & 0x00FF);
p += 3;
n += 3;
len -= 3;
@@ -256,12 +253,12 @@ static int rose_parse_national(unsigned char *p, rose_cb *rose, int len)
case 0xC0:
l = p[1];
if (*p == FAC_NATIONAL_DEST_DIGI) {
- memcpy(&rose->source_digi, p + 2, AX25_ADDR_LEN);
- rose->source_ndigis = 1;
+ memcpy(&facilities->source_digi, p + 2, AX25_ADDR_LEN);
+ facilities->source_ndigis = 1;
}
if (*p == FAC_NATIONAL_SRC_DIGI) {
- memcpy(&rose->dest_digi, p + 2, AX25_ADDR_LEN);
- rose->dest_ndigis = 1;
+ memcpy(&facilities->dest_digi, p + 2, AX25_ADDR_LEN);
+ facilities->dest_ndigis = 1;
}
p += l + 2;
n += l + 2;
@@ -273,7 +270,7 @@ static int rose_parse_national(unsigned char *p, rose_cb *rose, int len)
return n;
}
-static int rose_parse_ccitt(unsigned char *p, rose_cb *rose, int len)
+static int rose_parse_ccitt(unsigned char *p, struct rose_facilities *facilities, int len)
{
unsigned char l, n = 0;
char callsign[11];
@@ -301,16 +298,16 @@ static int rose_parse_ccitt(unsigned char *p, rose_cb *rose, int len)
case 0xC0:
l = p[1];
if (*p == FAC_CCITT_DEST_NSAP) {
- memcpy(&rose->source_addr, p + 7, ROSE_ADDR_LEN);
+ memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN);
memcpy(callsign, p + 12, l - 10);
callsign[l - 10] = '\0';
- rose->source_call = *asc2ax(callsign);
+ facilities->source_call = *asc2ax(callsign);
}
if (*p == FAC_CCITT_SRC_NSAP) {
- memcpy(&rose->dest_addr, p + 7, ROSE_ADDR_LEN);
+ memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN);
memcpy(callsign, p + 12, l - 10);
callsign[l - 10] = '\0';
- rose->dest_call = *asc2ax(callsign);
+ facilities->dest_call = *asc2ax(callsign);
}
p += l + 2;
n += l + 2;
@@ -322,12 +319,12 @@ static int rose_parse_ccitt(unsigned char *p, rose_cb *rose, int len)
return n;
}
-int rose_parse_facilities(struct sk_buff *skb, rose_cb *rose)
+int rose_parse_facilities(struct sk_buff *skb, struct rose_facilities *facilities)
{
int facilities_len, len;
unsigned char *p;
- memset(rose, 0x00, sizeof(rose_cb));
+ memset(facilities, 0x00, sizeof(struct rose_facilities));
len = (((skb->data[3] >> 4) & 0x0F) + 1) / 2;
len += (((skb->data[3] >> 0) & 0x0F) + 1) / 2;
@@ -346,19 +343,19 @@ int rose_parse_facilities(struct sk_buff *skb, rose_cb *rose)
switch (*p) {
case FAC_NATIONAL: /* National */
- len = rose_parse_national(p + 1, rose, facilities_len - 1);
+ len = rose_parse_national(p + 1, facilities, facilities_len - 1);
facilities_len -= len + 1;
p += len + 1;
break;
case FAC_CCITT: /* CCITT */
- len = rose_parse_ccitt(p + 1, rose, facilities_len - 1);
+ len = rose_parse_ccitt(p + 1, facilities, facilities_len - 1);
facilities_len -= len + 1;
p += len + 1;
break;
default:
- printk(KERN_DEBUG "rose_parse_facilities: unknown facilities family %02X\n", *p);
+ printk(KERN_DEBUG "ROSE: rose_parse_facilities - unknown facilities family %02X\n", *p);
facilities_len--;
p++;
break;
diff --git a/net/rose/rose_timer.c b/net/rose/rose_timer.c
index 869f312f5..572975e5d 100644
--- a/net/rose/rose_timer.c
+++ b/net/rose/rose_timer.c
@@ -1,8 +1,5 @@
/*
- * Rose release 001
- *
- * This is ALPHA test software. This code may break your machine, randomly fail to work with new
- * releases, misbehave and/or generally screw up. It might even work.
+ * ROSE release 002
*
* This code REQUIRES 2.1.15 or higher/ NET3.038
*
@@ -13,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* History
- * Rose 001 Jonathan(G4KLX) Cloned from nr_timer.c
+ * ROSE 001 Jonathan(G4KLX) Cloned from nr_timer.c
*/
#include <linux/config.h>
@@ -61,7 +58,7 @@ void rose_set_timer(struct sock *sk)
}
/*
- * Rose Timer
+ * ROSE Timer
*
* This routine is called every 100ms. Decrement timer by this
* amount - if expired then process the event.
diff --git a/net/rose/sysctl_net_rose.c b/net/rose/sysctl_net_rose.c
index 8cd49695f..409f79b52 100644
--- a/net/rose/sysctl_net_rose.c
+++ b/net/rose/sysctl_net_rose.c
@@ -1,5 +1,5 @@
/* -*- linux-c -*-
- * sysctl_net_rose.c: sysctl interface to net Rose subsystem.
+ * sysctl_net_rose.c: sysctl interface to net ROSE subsystem.
*
* Begun April 1, 1996, Mike Shaver.
* Added /proc/sys/net/rose directory entry (empty =) ). [MS]
@@ -18,6 +18,8 @@ static int max_idle[] = {65535 * ROSE_SLOWHZ};
static int min_route[] = {0}, max_route[] = {1};
static int min_ftimer[] = {60 * ROSE_SLOWHZ};
static int max_ftimer[] = {600 * ROSE_SLOWHZ};
+static int min_maxvcs[] = {1}, max_maxvcs[] = {254};
+static int min_window[] = {1}, max_window[] = {7};
static struct ctl_table_header *rose_table_header;
@@ -46,6 +48,12 @@ static ctl_table rose_table[] = {
{NET_ROSE_LINK_FAIL_TIMEOUT, "link_fail_timeout",
&sysctl_rose_link_fail_timeout, sizeof(int), 0644, NULL,
&proc_dointvec_minmax, &sysctl_intvec, NULL, &min_ftimer, &max_ftimer},
+ {NET_ROSE_MAX_VCS, "maximum_virtual_circuits",
+ &sysctl_rose_maximum_vcs, sizeof(int), 0644, NULL,
+ &proc_dointvec_minmax, &sysctl_intvec, NULL, &min_maxvcs, &max_maxvcs},
+ {NET_ROSE_WINDOW_SIZE, "window_size",
+ &sysctl_rose_window_size, sizeof(int), 0644, NULL,
+ &proc_dointvec_minmax, &sysctl_intvec, NULL, &min_window, &max_window},
{0}
};