9 #include <linux/errno.h>
10 #include <linux/types.h>
11 #include <linux/socket.h>
13 #include <linux/kernel.h>
15 #include <linux/string.h>
17 #include <linux/net.h>
18 #include <linux/slab.h>
21 #include <linux/netdevice.h>
25 #include <linux/fcntl.h>
30 static int rose_create_facilities(
unsigned char *
buffer,
struct rose_sock *rose);
88 unsigned short vc = rose->
va;
90 while (vc != rose->
vs) {
91 if (nr == vc)
return 1;
95 return nr == rose->
vs;
107 unsigned char lci1, lci2;
116 faclen = rose_create_facilities(buffer, rose);
134 dptr =
skb_put(skb, skb_tailroom(skb));
136 lci1 = (rose->
lci >> 8) & 0x0F;
137 lci2 = (rose->
lci >> 0) & 0xFF;
149 memcpy(dptr, buffer, faclen);
165 *dptr++ = rose->
cause;
182 *dptr++ |= (rose->
vr << 5) & 0xE0;
193 printk(
KERN_ERR "ROSE: rose_write_internal - invalid frametype %02X\n", frametype);
203 unsigned char *
frame;
207 *ns = *nr = *q = *d = *m = 0;
221 if ((frame[2] & 0x1F) ==
ROSE_RR ||
223 *nr = (frame[2] >> 5) & 0x07;
224 return frame[2] & 0x1F;
231 *nr = (frame[2] >> 5) & 0x07;
232 *ns = (frame[2] >> 1) & 0x07;
242 unsigned char l, lg,
n = 0;
243 int fac_national_digis_received = 0;
259 facilities->
rand = ((p[1] << 8) & 0xFF00) + ((p[2] << 0) & 0x00FF);
280 if (!fac_national_digis_received) {
288 if (!fac_national_digis_received) {
308 fac_national_digis_received = 1;
328 }
while (*p != 0x00 && len > 0);
335 unsigned char l, n = 0;
370 if (l < 10 || l > 20)
375 memcpy(callsign, p + 12, l - 10);
376 callsign[l - 10] =
'\0';
381 memcpy(callsign, p + 12, l - 10);
382 callsign[l - 10] =
'\0';
390 }
while (*p != 0x00 && len > 0);
398 int facilities_len,
len;
400 facilities_len = *p++;
402 if (facilities_len == 0 || (
unsigned int)facilities_len > packet_len)
405 while (facilities_len >= 3 && *p == 0x00) {
411 len = rose_parse_national(p + 1, facilities, facilities_len - 1);
415 len = rose_parse_ccitt(p + 1, facilities, facilities_len - 1);
419 printk(
KERN_DEBUG "ROSE: rose_parse_facilities - unknown facilities family %02X\n", *p);
426 if (
WARN_ON(len >= facilities_len))
428 facilities_len -= len + 1;
432 return facilities_len == 0;
435 static int rose_create_facilities(
unsigned char *
buffer,
struct rose_sock *rose)
437 unsigned char *p = buffer + 1;
447 if (rose->
rand != 0) {
449 *p++ = (rose->
rand >> 8) & 0xFF;
450 *p++ = (rose->
rand >> 0) & 0xFF;
498 *p++ =
strlen(callsign) + 10;
499 *p++ = (
strlen(callsign) + 9) * 2;
501 *p++ = 0x47; *p++ = 0x00; *p++ = 0x11;
513 *p++ =
strlen(callsign) + 10;
514 *p++ = (
strlen(callsign) + 9) * 2;
516 *p++ = 0x47; *p++ = 0x00; *p++ = 0x11;
545 if (diagnostic != -1)