diff options
Diffstat (limited to 'net/x25')
-rw-r--r-- | net/x25/af_x25.c | 110 | ||||
-rw-r--r-- | net/x25/x25_facilities.c | 34 | ||||
-rw-r--r-- | net/x25/x25_subr.c | 41 |
3 files changed, 128 insertions, 57 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 2a24b243b8..04bec047fa 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -29,6 +29,10 @@ | |||
29 | * 2000-11-14 Henner Eisen Closing datalink from NETDEV_GOING_DOWN | 29 | * 2000-11-14 Henner Eisen Closing datalink from NETDEV_GOING_DOWN |
30 | * 2002-10-06 Arnaldo C. Melo Get rid of cli/sti, move proc stuff to | 30 | * 2002-10-06 Arnaldo C. Melo Get rid of cli/sti, move proc stuff to |
31 | * x25_proc.c, using seq_file | 31 | * x25_proc.c, using seq_file |
32 | * 2005-04-02 Shaun Pereira Selective sub address matching | ||
33 | * with call user data | ||
34 | * 2005-04-15 Shaun Pereira Fast select with no restriction on | ||
35 | * response | ||
32 | */ | 36 | */ |
33 | 37 | ||
34 | #include <linux/config.h> | 38 | #include <linux/config.h> |
@@ -219,7 +223,8 @@ static void x25_insert_socket(struct sock *sk) | |||
219 | * Note: if a listening socket has cud set it must only get calls | 223 | * Note: if a listening socket has cud set it must only get calls |
220 | * with matching cud. | 224 | * with matching cud. |
221 | */ | 225 | */ |
222 | static struct sock *x25_find_listener(struct x25_address *addr, struct x25_calluserdata *calluserdata) | 226 | static struct sock *x25_find_listener(struct x25_address *addr, |
227 | struct sk_buff *skb) | ||
223 | { | 228 | { |
224 | struct sock *s; | 229 | struct sock *s; |
225 | struct sock *next_best; | 230 | struct sock *next_best; |
@@ -230,22 +235,23 @@ static struct sock *x25_find_listener(struct x25_address *addr, struct x25_callu | |||
230 | 235 | ||
231 | sk_for_each(s, node, &x25_list) | 236 | sk_for_each(s, node, &x25_list) |
232 | if ((!strcmp(addr->x25_addr, | 237 | if ((!strcmp(addr->x25_addr, |
233 | x25_sk(s)->source_addr.x25_addr) || | 238 | x25_sk(s)->source_addr.x25_addr) || |
234 | !strcmp(addr->x25_addr, | 239 | !strcmp(addr->x25_addr, |
235 | null_x25_address.x25_addr)) && | 240 | null_x25_address.x25_addr)) && |
236 | s->sk_state == TCP_LISTEN) { | 241 | s->sk_state == TCP_LISTEN) { |
237 | |||
238 | /* | 242 | /* |
239 | * Found a listening socket, now check the incoming | 243 | * Found a listening socket, now check the incoming |
240 | * call user data vs this sockets call user data | 244 | * call user data vs this sockets call user data |
241 | */ | 245 | */ |
242 | if (x25_check_calluserdata(&x25_sk(s)->calluserdata, calluserdata)) { | 246 | if(skb->len > 0 && x25_sk(s)->cudmatchlength > 0) { |
243 | sock_hold(s); | 247 | if((memcmp(x25_sk(s)->calluserdata.cuddata, |
244 | goto found; | 248 | skb->data, |
245 | } | 249 | x25_sk(s)->cudmatchlength)) == 0) { |
246 | if (x25_sk(s)->calluserdata.cudlength == 0) { | 250 | sock_hold(s); |
251 | goto found; | ||
252 | } | ||
253 | } else | ||
247 | next_best = s; | 254 | next_best = s; |
248 | } | ||
249 | } | 255 | } |
250 | if (next_best) { | 256 | if (next_best) { |
251 | s = next_best; | 257 | s = next_best; |
@@ -497,6 +503,9 @@ static int x25_create(struct socket *sock, int protocol) | |||
497 | x25->t23 = sysctl_x25_clear_request_timeout; | 503 | x25->t23 = sysctl_x25_clear_request_timeout; |
498 | x25->t2 = sysctl_x25_ack_holdback_timeout; | 504 | x25->t2 = sysctl_x25_ack_holdback_timeout; |
499 | x25->state = X25_STATE_0; | 505 | x25->state = X25_STATE_0; |
506 | x25->cudmatchlength = 0; | ||
507 | x25->accptapprv = X25_DENY_ACCPT_APPRV; /* normally no cud */ | ||
508 | /* on call accept */ | ||
500 | 509 | ||
501 | x25->facilities.winsize_in = X25_DEFAULT_WINDOW_SIZE; | 510 | x25->facilities.winsize_in = X25_DEFAULT_WINDOW_SIZE; |
502 | x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; | 511 | x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; |
@@ -545,6 +554,8 @@ static struct sock *x25_make_new(struct sock *osk) | |||
545 | x25->t2 = ox25->t2; | 554 | x25->t2 = ox25->t2; |
546 | x25->facilities = ox25->facilities; | 555 | x25->facilities = ox25->facilities; |
547 | x25->qbitincl = ox25->qbitincl; | 556 | x25->qbitincl = ox25->qbitincl; |
557 | x25->cudmatchlength = ox25->cudmatchlength; | ||
558 | x25->accptapprv = ox25->accptapprv; | ||
548 | 559 | ||
549 | x25_init_timers(sk); | 560 | x25_init_timers(sk); |
550 | out: | 561 | out: |
@@ -822,7 +833,6 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb, | |||
822 | struct x25_sock *makex25; | 833 | struct x25_sock *makex25; |
823 | struct x25_address source_addr, dest_addr; | 834 | struct x25_address source_addr, dest_addr; |
824 | struct x25_facilities facilities; | 835 | struct x25_facilities facilities; |
825 | struct x25_calluserdata calluserdata; | ||
826 | int len, rc; | 836 | int len, rc; |
827 | 837 | ||
828 | /* | 838 | /* |
@@ -845,19 +855,10 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb, | |||
845 | skb_pull(skb,len); | 855 | skb_pull(skb,len); |
846 | 856 | ||
847 | /* | 857 | /* |
848 | * Incoming Call User Data. | ||
849 | */ | ||
850 | if (skb->len >= 0) { | ||
851 | memcpy(calluserdata.cuddata, skb->data, skb->len); | ||
852 | calluserdata.cudlength = skb->len; | ||
853 | } | ||
854 | |||
855 | skb_push(skb,len); | ||
856 | |||
857 | /* | ||
858 | * Find a listener for the particular address/cud pair. | 858 | * Find a listener for the particular address/cud pair. |
859 | */ | 859 | */ |
860 | sk = x25_find_listener(&source_addr,&calluserdata); | 860 | sk = x25_find_listener(&source_addr,skb); |
861 | skb_push(skb,len); | ||
861 | 862 | ||
862 | /* | 863 | /* |
863 | * We can't accept the Call Request. | 864 | * We can't accept the Call Request. |
@@ -900,11 +901,23 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb, | |||
900 | makex25->neighbour = nb; | 901 | makex25->neighbour = nb; |
901 | makex25->facilities = facilities; | 902 | makex25->facilities = facilities; |
902 | makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask; | 903 | makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask; |
903 | makex25->calluserdata = calluserdata; | 904 | /* ensure no reverse facil on accept */ |
904 | 905 | makex25->vc_facil_mask &= ~X25_MASK_REVERSE; | |
905 | x25_write_internal(make, X25_CALL_ACCEPTED); | 906 | makex25->cudmatchlength = x25_sk(sk)->cudmatchlength; |
907 | |||
908 | /* Normally all calls are accepted immediatly */ | ||
909 | if(makex25->accptapprv & X25_DENY_ACCPT_APPRV) { | ||
910 | x25_write_internal(make, X25_CALL_ACCEPTED); | ||
911 | makex25->state = X25_STATE_3; | ||
912 | } | ||
906 | 913 | ||
907 | makex25->state = X25_STATE_3; | 914 | /* |
915 | * Incoming Call User Data. | ||
916 | */ | ||
917 | if (skb->len >= 0) { | ||
918 | memcpy(makex25->calluserdata.cuddata, skb->data, skb->len); | ||
919 | makex25->calluserdata.cudlength = skb->len; | ||
920 | } | ||
908 | 921 | ||
909 | sk->sk_ack_backlog++; | 922 | sk->sk_ack_backlog++; |
910 | 923 | ||
@@ -1288,7 +1301,8 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1288 | if (facilities.throughput < 0x03 || | 1301 | if (facilities.throughput < 0x03 || |
1289 | facilities.throughput > 0xDD) | 1302 | facilities.throughput > 0xDD) |
1290 | break; | 1303 | break; |
1291 | if (facilities.reverse && facilities.reverse != 1) | 1304 | if (facilities.reverse && |
1305 | (facilities.reverse | 0x81)!= 0x81) | ||
1292 | break; | 1306 | break; |
1293 | x25->facilities = facilities; | 1307 | x25->facilities = facilities; |
1294 | rc = 0; | 1308 | rc = 0; |
@@ -1325,6 +1339,44 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1325 | break; | 1339 | break; |
1326 | } | 1340 | } |
1327 | 1341 | ||
1342 | case SIOCX25SCUDMATCHLEN: { | ||
1343 | struct x25_subaddr sub_addr; | ||
1344 | rc = -EINVAL; | ||
1345 | if(sk->sk_state != TCP_CLOSE) | ||
1346 | break; | ||
1347 | rc = -EFAULT; | ||
1348 | if (copy_from_user(&sub_addr, argp, | ||
1349 | sizeof(sub_addr))) | ||
1350 | break; | ||
1351 | rc = -EINVAL; | ||
1352 | if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN) | ||
1353 | break; | ||
1354 | x25->cudmatchlength = sub_addr.cudmatchlength; | ||
1355 | rc = 0; | ||
1356 | break; | ||
1357 | } | ||
1358 | |||
1359 | case SIOCX25CALLACCPTAPPRV: { | ||
1360 | rc = -EINVAL; | ||
1361 | if (sk->sk_state != TCP_CLOSE) | ||
1362 | break; | ||
1363 | x25->accptapprv = X25_ALLOW_ACCPT_APPRV; | ||
1364 | rc = 0; | ||
1365 | break; | ||
1366 | } | ||
1367 | |||
1368 | case SIOCX25SENDCALLACCPT: { | ||
1369 | rc = -EINVAL; | ||
1370 | if (sk->sk_state != TCP_ESTABLISHED) | ||
1371 | break; | ||
1372 | if (x25->accptapprv) /* must call accptapprv above */ | ||
1373 | break; | ||
1374 | x25_write_internal(sk, X25_CALL_ACCEPTED); | ||
1375 | x25->state = X25_STATE_3; | ||
1376 | rc = 0; | ||
1377 | break; | ||
1378 | } | ||
1379 | |||
1328 | default: | 1380 | default: |
1329 | rc = dev_ioctl(cmd, argp); | 1381 | rc = dev_ioctl(cmd, argp); |
1330 | break; | 1382 | break; |
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c index a21bdb95f9..54278b962f 100644 --- a/net/x25/x25_facilities.c +++ b/net/x25/x25_facilities.c | |||
@@ -17,6 +17,8 @@ | |||
17 | * X.25 001 Split from x25_subr.c | 17 | * X.25 001 Split from x25_subr.c |
18 | * mar/20/00 Daniela Squassoni Disabling/enabling of facilities | 18 | * mar/20/00 Daniela Squassoni Disabling/enabling of facilities |
19 | * negotiation. | 19 | * negotiation. |
20 | * apr/14/05 Shaun Pereira - Allow fast select with no restriction | ||
21 | * on response. | ||
20 | */ | 22 | */ |
21 | 23 | ||
22 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
@@ -43,9 +45,31 @@ int x25_parse_facilities(struct sk_buff *skb, | |||
43 | case X25_FAC_CLASS_A: | 45 | case X25_FAC_CLASS_A: |
44 | switch (*p) { | 46 | switch (*p) { |
45 | case X25_FAC_REVERSE: | 47 | case X25_FAC_REVERSE: |
46 | facilities->reverse = p[1] & 0x01; | 48 | if((p[1] & 0x81) == 0x81) { |
47 | *vc_fac_mask |= X25_MASK_REVERSE; | 49 | facilities->reverse = p[1] & 0x81; |
48 | break; | 50 | *vc_fac_mask |= X25_MASK_REVERSE; |
51 | break; | ||
52 | } | ||
53 | |||
54 | if((p[1] & 0x01) == 0x01) { | ||
55 | facilities->reverse = p[1] & 0x01; | ||
56 | *vc_fac_mask |= X25_MASK_REVERSE; | ||
57 | break; | ||
58 | } | ||
59 | |||
60 | if((p[1] & 0x80) == 0x80) { | ||
61 | facilities->reverse = p[1] & 0x80; | ||
62 | *vc_fac_mask |= X25_MASK_REVERSE; | ||
63 | break; | ||
64 | } | ||
65 | |||
66 | if(p[1] == 0x00) { | ||
67 | facilities->reverse | ||
68 | = X25_DEFAULT_REVERSE; | ||
69 | *vc_fac_mask |= X25_MASK_REVERSE; | ||
70 | break; | ||
71 | } | ||
72 | |||
49 | case X25_FAC_THROUGHPUT: | 73 | case X25_FAC_THROUGHPUT: |
50 | facilities->throughput = p[1]; | 74 | facilities->throughput = p[1]; |
51 | *vc_fac_mask |= X25_MASK_THROUGHPUT; | 75 | *vc_fac_mask |= X25_MASK_THROUGHPUT; |
@@ -122,7 +146,7 @@ int x25_create_facilities(unsigned char *buffer, | |||
122 | 146 | ||
123 | if (facilities->reverse && (facil_mask & X25_MASK_REVERSE)) { | 147 | if (facilities->reverse && (facil_mask & X25_MASK_REVERSE)) { |
124 | *p++ = X25_FAC_REVERSE; | 148 | *p++ = X25_FAC_REVERSE; |
125 | *p++ = !!facilities->reverse; | 149 | *p++ = facilities->reverse; |
126 | } | 150 | } |
127 | 151 | ||
128 | if (facilities->throughput && (facil_mask & X25_MASK_THROUGHPUT)) { | 152 | if (facilities->throughput && (facil_mask & X25_MASK_THROUGHPUT)) { |
@@ -171,7 +195,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, | |||
171 | /* | 195 | /* |
172 | * They want reverse charging, we won't accept it. | 196 | * They want reverse charging, we won't accept it. |
173 | */ | 197 | */ |
174 | if (theirs.reverse && ours->reverse) { | 198 | if ((theirs.reverse & 0x01 ) && (ours->reverse & 0x01)) { |
175 | SOCK_DEBUG(sk, "X.25: rejecting reverse charging request"); | 199 | SOCK_DEBUG(sk, "X.25: rejecting reverse charging request"); |
176 | return -1; | 200 | return -1; |
177 | } | 201 | } |
diff --git a/net/x25/x25_subr.c b/net/x25/x25_subr.c index 183fea3bba..7fd872ad0c 100644 --- a/net/x25/x25_subr.c +++ b/net/x25/x25_subr.c | |||
@@ -19,6 +19,8 @@ | |||
19 | * mar/20/00 Daniela Squassoni Disabling/enabling of facilities | 19 | * mar/20/00 Daniela Squassoni Disabling/enabling of facilities |
20 | * negotiation. | 20 | * negotiation. |
21 | * jun/24/01 Arnaldo C. Melo use skb_queue_purge, cleanups | 21 | * jun/24/01 Arnaldo C. Melo use skb_queue_purge, cleanups |
22 | * apr/04/15 Shaun Pereira Fast select with no | ||
23 | * restriction on response. | ||
22 | */ | 24 | */ |
23 | 25 | ||
24 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
@@ -127,8 +129,12 @@ void x25_write_internal(struct sock *sk, int frametype) | |||
127 | len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + | 129 | len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + |
128 | X25_MAX_CUD_LEN; | 130 | X25_MAX_CUD_LEN; |
129 | break; | 131 | break; |
130 | case X25_CALL_ACCEPTED: | 132 | case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */ |
131 | len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; | 133 | if(x25->facilities.reverse & 0x80) { |
134 | len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; | ||
135 | } else { | ||
136 | len += 1 + X25_MAX_FAC_LEN; | ||
137 | } | ||
132 | break; | 138 | break; |
133 | case X25_CLEAR_REQUEST: | 139 | case X25_CLEAR_REQUEST: |
134 | case X25_RESET_REQUEST: | 140 | case X25_RESET_REQUEST: |
@@ -203,9 +209,16 @@ void x25_write_internal(struct sock *sk, int frametype) | |||
203 | x25->vc_facil_mask); | 209 | x25->vc_facil_mask); |
204 | dptr = skb_put(skb, len); | 210 | dptr = skb_put(skb, len); |
205 | memcpy(dptr, facilities, len); | 211 | memcpy(dptr, facilities, len); |
206 | dptr = skb_put(skb, x25->calluserdata.cudlength); | 212 | |
207 | memcpy(dptr, x25->calluserdata.cuddata, | 213 | /* fast select with no restriction on response |
208 | x25->calluserdata.cudlength); | 214 | allows call user data. Userland must |
215 | ensure it is ours and not theirs */ | ||
216 | if(x25->facilities.reverse & 0x80) { | ||
217 | dptr = skb_put(skb, | ||
218 | x25->calluserdata.cudlength); | ||
219 | memcpy(dptr, x25->calluserdata.cuddata, | ||
220 | x25->calluserdata.cudlength); | ||
221 | } | ||
209 | x25->calluserdata.cudlength = 0; | 222 | x25->calluserdata.cudlength = 0; |
210 | break; | 223 | break; |
211 | 224 | ||
@@ -354,21 +367,3 @@ void x25_check_rbuf(struct sock *sk) | |||
354 | } | 367 | } |
355 | } | 368 | } |
356 | 369 | ||
357 | /* | ||
358 | * Compare 2 calluserdata structures, used to find correct listening sockets | ||
359 | * when call user data is used. | ||
360 | */ | ||
361 | int x25_check_calluserdata(struct x25_calluserdata *ours, struct x25_calluserdata *theirs) | ||
362 | { | ||
363 | int i; | ||
364 | if (ours->cudlength != theirs->cudlength) | ||
365 | return 0; | ||
366 | |||
367 | for (i=0;i<ours->cudlength;i++) { | ||
368 | if (ours->cuddata[i] != theirs->cuddata[i]) { | ||
369 | return 0; | ||
370 | } | ||
371 | } | ||
372 | return 1; | ||
373 | } | ||
374 | |||