| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *	X.25 Packet Layer release 002 | 
|  | 3 | * | 
|  | 4 | *	This is ALPHA test software. This code may break your machine, | 
|  | 5 | *	randomly fail to work with new releases, misbehave and/or generally | 
| YOSHIFUJI Hideaki | f8e1d201 | 2007-02-09 23:25:27 +0900 | [diff] [blame] | 6 | *	screw up. It might even work. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * | 
|  | 8 | *	This code REQUIRES 2.1.15 or higher | 
|  | 9 | * | 
|  | 10 | *	This module: | 
|  | 11 | *		This module is free software; you can redistribute it and/or | 
|  | 12 | *		modify it under the terms of the GNU General Public License | 
|  | 13 | *		as published by the Free Software Foundation; either version | 
|  | 14 | *		2 of the License, or (at your option) any later version. | 
|  | 15 | * | 
|  | 16 | *	History | 
|  | 17 | *	X.25 001	Split from x25_subr.c | 
| YOSHIFUJI Hideaki | f8e1d201 | 2007-02-09 23:25:27 +0900 | [diff] [blame] | 18 | *	mar/20/00	Daniela Squassoni Disabling/enabling of facilities | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | *					  negotiation. | 
| Shaun Pereira | ebc3f64 | 2005-06-22 22:16:17 -0700 | [diff] [blame] | 20 | *	apr/14/05	Shaun Pereira - Allow fast select with no restriction | 
|  | 21 | *					on response. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | */ | 
|  | 23 |  | 
|  | 24 | #include <linux/kernel.h> | 
|  | 25 | #include <linux/string.h> | 
|  | 26 | #include <linux/skbuff.h> | 
|  | 27 | #include <net/sock.h> | 
|  | 28 | #include <net/x25.h> | 
|  | 29 |  | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 30 | /** | 
|  | 31 | * x25_parse_facilities - Parse facilities from skb into the facilities structs | 
|  | 32 | * | 
|  | 33 | * @skb: sk_buff to parse | 
| Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 34 | * @facilities: Regular facilities, updated as facilities are found | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 35 | * @dte_facs: ITU DTE facilities, updated as DTE facilities are found | 
|  | 36 | * @vc_fac_mask: mask is updated with all facilities found | 
|  | 37 | * | 
|  | 38 | * Return codes: | 
|  | 39 | *  -1 - Parsing error, caller should drop call and clean up | 
|  | 40 | *   0 - Parse OK, this skb has no facilities | 
|  | 41 | *  >0 - Parse OK, returns the length of the facilities header | 
|  | 42 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | */ | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 44 | int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, | 
|  | 45 | struct x25_dte_facilities *dte_facs, unsigned long *vc_fac_mask) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { | 
|  | 47 | unsigned char *p = skb->data; | 
| John Hughes | f5eb917 | 2010-04-07 21:29:25 -0700 | [diff] [blame] | 48 | unsigned int len; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 |  | 
|  | 50 | *vc_fac_mask = 0; | 
|  | 51 |  | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 52 | /* | 
|  | 53 | * The kernel knows which facilities were set on an incoming call but | 
|  | 54 | * currently this information is not available to userspace.  Here we | 
|  | 55 | * give userspace who read incoming call facilities 0 length to indicate | 
|  | 56 | * it wasn't set. | 
|  | 57 | */ | 
|  | 58 | dte_facs->calling_len = 0; | 
|  | 59 | dte_facs->called_len = 0; | 
|  | 60 | memset(dte_facs->called_ae, '\0', sizeof(dte_facs->called_ae)); | 
|  | 61 | memset(dte_facs->calling_ae, '\0', sizeof(dte_facs->calling_ae)); | 
|  | 62 |  | 
| John Hughes | f5eb917 | 2010-04-07 21:29:25 -0700 | [diff] [blame] | 63 | if (skb->len < 1) | 
|  | 64 | return 0; | 
|  | 65 |  | 
|  | 66 | len = *p++; | 
|  | 67 |  | 
|  | 68 | if (len >= skb->len) | 
|  | 69 | return -1; | 
|  | 70 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | while (len > 0) { | 
|  | 72 | switch (*p & X25_FAC_CLASS_MASK) { | 
|  | 73 | case X25_FAC_CLASS_A: | 
| Dan Rosenberg | 5ef4130 | 2010-11-12 12:44:42 -0800 | [diff] [blame] | 74 | if (len < 2) | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 75 | return -1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | switch (*p) { | 
|  | 77 | case X25_FAC_REVERSE: | 
| Shaun Pereira | ebc3f64 | 2005-06-22 22:16:17 -0700 | [diff] [blame] | 78 | if((p[1] & 0x81) == 0x81) { | 
|  | 79 | facilities->reverse = p[1] & 0x81; | 
|  | 80 | *vc_fac_mask |= X25_MASK_REVERSE; | 
|  | 81 | break; | 
|  | 82 | } | 
|  | 83 |  | 
|  | 84 | if((p[1] & 0x01) == 0x01) { | 
|  | 85 | facilities->reverse = p[1] & 0x01; | 
|  | 86 | *vc_fac_mask |= X25_MASK_REVERSE; | 
|  | 87 | break; | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | if((p[1] & 0x80) == 0x80) { | 
|  | 91 | facilities->reverse = p[1] & 0x80; | 
|  | 92 | *vc_fac_mask |= X25_MASK_REVERSE; | 
|  | 93 | break; | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | if(p[1] == 0x00) { | 
|  | 97 | facilities->reverse | 
|  | 98 | = X25_DEFAULT_REVERSE; | 
|  | 99 | *vc_fac_mask |= X25_MASK_REVERSE; | 
|  | 100 | break; | 
|  | 101 | } | 
|  | 102 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | case X25_FAC_THROUGHPUT: | 
|  | 104 | facilities->throughput = p[1]; | 
|  | 105 | *vc_fac_mask |= X25_MASK_THROUGHPUT; | 
|  | 106 | break; | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 107 | case X25_MARKER: | 
|  | 108 | break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | default: | 
|  | 110 | printk(KERN_DEBUG "X.25: unknown facility " | 
|  | 111 | "%02X, value %02X\n", | 
|  | 112 | p[0], p[1]); | 
|  | 113 | break; | 
|  | 114 | } | 
|  | 115 | p   += 2; | 
|  | 116 | len -= 2; | 
|  | 117 | break; | 
|  | 118 | case X25_FAC_CLASS_B: | 
| Dan Rosenberg | 5ef4130 | 2010-11-12 12:44:42 -0800 | [diff] [blame] | 119 | if (len < 3) | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 120 | return -1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | switch (*p) { | 
|  | 122 | case X25_FAC_PACKET_SIZE: | 
|  | 123 | facilities->pacsize_in  = p[1]; | 
|  | 124 | facilities->pacsize_out = p[2]; | 
|  | 125 | *vc_fac_mask |= X25_MASK_PACKET_SIZE; | 
|  | 126 | break; | 
|  | 127 | case X25_FAC_WINDOW_SIZE: | 
|  | 128 | facilities->winsize_in  = p[1]; | 
|  | 129 | facilities->winsize_out = p[2]; | 
|  | 130 | *vc_fac_mask |= X25_MASK_WINDOW_SIZE; | 
|  | 131 | break; | 
|  | 132 | default: | 
|  | 133 | printk(KERN_DEBUG "X.25: unknown facility " | 
|  | 134 | "%02X, values %02X, %02X\n", | 
|  | 135 | p[0], p[1], p[2]); | 
|  | 136 | break; | 
|  | 137 | } | 
|  | 138 | p   += 3; | 
|  | 139 | len -= 3; | 
|  | 140 | break; | 
|  | 141 | case X25_FAC_CLASS_C: | 
| Dan Rosenberg | 5ef4130 | 2010-11-12 12:44:42 -0800 | [diff] [blame] | 142 | if (len < 4) | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 143 | return -1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | printk(KERN_DEBUG "X.25: unknown facility %02X, " | 
|  | 145 | "values %02X, %02X, %02X\n", | 
|  | 146 | p[0], p[1], p[2], p[3]); | 
|  | 147 | p   += 4; | 
|  | 148 | len -= 4; | 
|  | 149 | break; | 
|  | 150 | case X25_FAC_CLASS_D: | 
| Dan Rosenberg | 5ef4130 | 2010-11-12 12:44:42 -0800 | [diff] [blame] | 151 | if (len < p[1] + 2) | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 152 | return -1; | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 153 | switch (*p) { | 
| YOSHIFUJI Hideaki | f8e1d201 | 2007-02-09 23:25:27 +0900 | [diff] [blame] | 154 | case X25_FAC_CALLING_AE: | 
| andrew hendry | a6331d6 | 2010-11-03 12:54:53 +0000 | [diff] [blame] | 155 | if (p[1] > X25_MAX_DTE_FACIL_LEN || p[1] <= 1) | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 156 | return -1; | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 157 | dte_facs->calling_len = p[2]; | 
|  | 158 | memcpy(dte_facs->calling_ae, &p[3], p[1] - 1); | 
|  | 159 | *vc_fac_mask |= X25_MASK_CALLING_AE; | 
|  | 160 | break; | 
|  | 161 | case X25_FAC_CALLED_AE: | 
| andrew hendry | a6331d6 | 2010-11-03 12:54:53 +0000 | [diff] [blame] | 162 | if (p[1] > X25_MAX_DTE_FACIL_LEN || p[1] <= 1) | 
| andrew hendry | 95c3043 | 2011-02-07 00:08:15 +0000 | [diff] [blame] | 163 | return -1; | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 164 | dte_facs->called_len = p[2]; | 
|  | 165 | memcpy(dte_facs->called_ae, &p[3], p[1] - 1); | 
|  | 166 | *vc_fac_mask |= X25_MASK_CALLED_AE; | 
|  | 167 | break; | 
|  | 168 | default: | 
|  | 169 | printk(KERN_DEBUG "X.25: unknown facility %02X," | 
| Dan Rosenberg | 5ef4130 | 2010-11-12 12:44:42 -0800 | [diff] [blame] | 170 | "length %d\n", p[0], p[1]); | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 171 | break; | 
|  | 172 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | len -= p[1] + 2; | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 174 | p += p[1] + 2; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | break; | 
|  | 176 | } | 
|  | 177 | } | 
|  | 178 |  | 
|  | 179 | return p - skb->data; | 
|  | 180 | } | 
|  | 181 |  | 
|  | 182 | /* | 
|  | 183 | *	Create a set of facilities. | 
|  | 184 | */ | 
|  | 185 | int x25_create_facilities(unsigned char *buffer, | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 186 | struct x25_facilities *facilities, | 
|  | 187 | struct x25_dte_facilities *dte_facs, unsigned long facil_mask) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { | 
|  | 189 | unsigned char *p = buffer + 1; | 
|  | 190 | int len; | 
|  | 191 |  | 
|  | 192 | if (!facil_mask) { | 
|  | 193 | /* | 
|  | 194 | * Length of the facilities field in call_req or | 
|  | 195 | * call_accept packets | 
|  | 196 | */ | 
|  | 197 | buffer[0] = 0; | 
|  | 198 | len = 1; /* 1 byte for the length field */ | 
|  | 199 | return len; | 
|  | 200 | } | 
|  | 201 |  | 
|  | 202 | if (facilities->reverse && (facil_mask & X25_MASK_REVERSE)) { | 
|  | 203 | *p++ = X25_FAC_REVERSE; | 
| Shaun Pereira | ebc3f64 | 2005-06-22 22:16:17 -0700 | [diff] [blame] | 204 | *p++ = facilities->reverse; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | } | 
|  | 206 |  | 
|  | 207 | if (facilities->throughput && (facil_mask & X25_MASK_THROUGHPUT)) { | 
|  | 208 | *p++ = X25_FAC_THROUGHPUT; | 
|  | 209 | *p++ = facilities->throughput; | 
|  | 210 | } | 
|  | 211 |  | 
|  | 212 | if ((facilities->pacsize_in || facilities->pacsize_out) && | 
|  | 213 | (facil_mask & X25_MASK_PACKET_SIZE)) { | 
|  | 214 | *p++ = X25_FAC_PACKET_SIZE; | 
|  | 215 | *p++ = facilities->pacsize_in ? : facilities->pacsize_out; | 
|  | 216 | *p++ = facilities->pacsize_out ? : facilities->pacsize_in; | 
|  | 217 | } | 
|  | 218 |  | 
|  | 219 | if ((facilities->winsize_in || facilities->winsize_out) && | 
|  | 220 | (facil_mask & X25_MASK_WINDOW_SIZE)) { | 
|  | 221 | *p++ = X25_FAC_WINDOW_SIZE; | 
|  | 222 | *p++ = facilities->winsize_in ? : facilities->winsize_out; | 
|  | 223 | *p++ = facilities->winsize_out ? : facilities->winsize_in; | 
|  | 224 | } | 
|  | 225 |  | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 226 | if (facil_mask & (X25_MASK_CALLING_AE|X25_MASK_CALLED_AE)) { | 
|  | 227 | *p++ = X25_MARKER; | 
|  | 228 | *p++ = X25_DTE_SERVICES; | 
|  | 229 | } | 
|  | 230 |  | 
|  | 231 | if (dte_facs->calling_len && (facil_mask & X25_MASK_CALLING_AE)) { | 
| Eric Dumazet | 6bf1574 | 2008-01-13 22:27:52 -0800 | [diff] [blame] | 232 | unsigned bytecount = (dte_facs->calling_len + 1) >> 1; | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 233 | *p++ = X25_FAC_CALLING_AE; | 
|  | 234 | *p++ = 1 + bytecount; | 
|  | 235 | *p++ = dte_facs->calling_len; | 
|  | 236 | memcpy(p, dte_facs->calling_ae, bytecount); | 
|  | 237 | p += bytecount; | 
|  | 238 | } | 
|  | 239 |  | 
|  | 240 | if (dte_facs->called_len && (facil_mask & X25_MASK_CALLED_AE)) { | 
|  | 241 | unsigned bytecount = (dte_facs->called_len % 2) ? | 
|  | 242 | dte_facs->called_len / 2 + 1 : | 
|  | 243 | dte_facs->called_len / 2; | 
|  | 244 | *p++ = X25_FAC_CALLED_AE; | 
|  | 245 | *p++ = 1 + bytecount; | 
|  | 246 | *p++ = dte_facs->called_len; | 
|  | 247 | memcpy(p, dte_facs->called_ae, bytecount); | 
|  | 248 | p+=bytecount; | 
|  | 249 | } | 
|  | 250 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | len       = p - buffer; | 
|  | 252 | buffer[0] = len - 1; | 
|  | 253 |  | 
|  | 254 | return len; | 
|  | 255 | } | 
|  | 256 |  | 
|  | 257 | /* | 
|  | 258 | *	Try to reach a compromise on a set of facilities. | 
|  | 259 | * | 
|  | 260 | *	The only real problem is with reverse charging. | 
|  | 261 | */ | 
|  | 262 | int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 263 | struct x25_facilities *new, struct x25_dte_facilities *dte) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | { | 
|  | 265 | struct x25_sock *x25 = x25_sk(sk); | 
|  | 266 | struct x25_facilities *ours = &x25->facilities; | 
|  | 267 | struct x25_facilities theirs; | 
|  | 268 | int len; | 
|  | 269 |  | 
|  | 270 | memset(&theirs, 0, sizeof(theirs)); | 
|  | 271 | memcpy(new, ours, sizeof(*new)); | 
|  | 272 |  | 
| Shaun Pereira | a64b7b9 | 2006-03-22 00:01:31 -0800 | [diff] [blame] | 273 | len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask); | 
| John Hughes | f5eb917 | 2010-04-07 21:29:25 -0700 | [diff] [blame] | 274 | if (len < 0) | 
|  | 275 | return len; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 |  | 
|  | 277 | /* | 
|  | 278 | *	They want reverse charging, we won't accept it. | 
|  | 279 | */ | 
| Shaun Pereira | ebc3f64 | 2005-06-22 22:16:17 -0700 | [diff] [blame] | 280 | if ((theirs.reverse & 0x01 ) && (ours->reverse & 0x01)) { | 
| Andrew Hendry | d2e7543 | 2007-01-04 17:00:56 -0800 | [diff] [blame] | 281 | SOCK_DEBUG(sk, "X.25: rejecting reverse charging request\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | return -1; | 
|  | 283 | } | 
|  | 284 |  | 
|  | 285 | new->reverse = theirs.reverse; | 
|  | 286 |  | 
|  | 287 | if (theirs.throughput) { | 
| John Hughes | ddd0451 | 2010-04-04 06:48:10 +0000 | [diff] [blame] | 288 | int theirs_in =  theirs.throughput & 0x0f; | 
|  | 289 | int theirs_out = theirs.throughput & 0xf0; | 
|  | 290 | int ours_in  = ours->throughput & 0x0f; | 
|  | 291 | int ours_out = ours->throughput & 0xf0; | 
|  | 292 | if (!ours_in || theirs_in < ours_in) { | 
|  | 293 | SOCK_DEBUG(sk, "X.25: inbound throughput negotiated\n"); | 
|  | 294 | new->throughput = (new->throughput & 0xf0) | theirs_in; | 
|  | 295 | } | 
|  | 296 | if (!ours_out || theirs_out < ours_out) { | 
|  | 297 | SOCK_DEBUG(sk, | 
|  | 298 | "X.25: outbound throughput negotiated\n"); | 
|  | 299 | new->throughput = (new->throughput & 0x0f) | theirs_out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | } | 
|  | 301 | } | 
|  | 302 |  | 
|  | 303 | if (theirs.pacsize_in && theirs.pacsize_out) { | 
|  | 304 | if (theirs.pacsize_in < ours->pacsize_in) { | 
| Andrew Hendry | d2e7543 | 2007-01-04 17:00:56 -0800 | [diff] [blame] | 305 | SOCK_DEBUG(sk, "X.25: packet size inwards negotiated down\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | new->pacsize_in = theirs.pacsize_in; | 
|  | 307 | } | 
|  | 308 | if (theirs.pacsize_out < ours->pacsize_out) { | 
| Andrew Hendry | d2e7543 | 2007-01-04 17:00:56 -0800 | [diff] [blame] | 309 | SOCK_DEBUG(sk, "X.25: packet size outwards negotiated down\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | new->pacsize_out = theirs.pacsize_out; | 
|  | 311 | } | 
|  | 312 | } | 
|  | 313 |  | 
|  | 314 | if (theirs.winsize_in && theirs.winsize_out) { | 
|  | 315 | if (theirs.winsize_in < ours->winsize_in) { | 
| Andrew Hendry | d2e7543 | 2007-01-04 17:00:56 -0800 | [diff] [blame] | 316 | SOCK_DEBUG(sk, "X.25: window size inwards negotiated down\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | new->winsize_in = theirs.winsize_in; | 
|  | 318 | } | 
|  | 319 | if (theirs.winsize_out < ours->winsize_out) { | 
| Andrew Hendry | d2e7543 | 2007-01-04 17:00:56 -0800 | [diff] [blame] | 320 | SOCK_DEBUG(sk, "X.25: window size outwards negotiated down\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | new->winsize_out = theirs.winsize_out; | 
|  | 322 | } | 
|  | 323 | } | 
|  | 324 |  | 
|  | 325 | return len; | 
|  | 326 | } | 
|  | 327 |  | 
|  | 328 | /* | 
| YOSHIFUJI Hideaki | f8e1d201 | 2007-02-09 23:25:27 +0900 | [diff] [blame] | 329 | *	Limit values of certain facilities according to the capability of the | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | *      currently attached x25 link. | 
|  | 331 | */ | 
|  | 332 | void x25_limit_facilities(struct x25_facilities *facilities, | 
|  | 333 | struct x25_neigh *nb) | 
|  | 334 | { | 
|  | 335 |  | 
|  | 336 | if (!nb->extended) { | 
|  | 337 | if (facilities->winsize_in  > 7) { | 
|  | 338 | printk(KERN_DEBUG "X.25: incoming winsize limited to 7\n"); | 
|  | 339 | facilities->winsize_in = 7; | 
|  | 340 | } | 
|  | 341 | if (facilities->winsize_out > 7) { | 
|  | 342 | facilities->winsize_out = 7; | 
|  | 343 | printk( KERN_DEBUG "X.25: outgoing winsize limited to 7\n"); | 
|  | 344 | } | 
|  | 345 | } | 
|  | 346 | } |