diff options
Diffstat (limited to 'net/decnet/af_decnet.c')
-rw-r--r-- | net/decnet/af_decnet.c | 697 |
1 files changed, 348 insertions, 349 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index ea3b6ee21fc9..19acd00a6382 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -291,23 +291,23 @@ int dn_sockaddr2username(struct sockaddr_dn *sdn, unsigned char *buf, unsigned c | |||
291 | 291 | ||
292 | *buf++ = type; | 292 | *buf++ = type; |
293 | 293 | ||
294 | switch(type) { | 294 | switch (type) { |
295 | case 0: | 295 | case 0: |
296 | *buf++ = sdn->sdn_objnum; | 296 | *buf++ = sdn->sdn_objnum; |
297 | break; | 297 | break; |
298 | case 1: | 298 | case 1: |
299 | *buf++ = 0; | 299 | *buf++ = 0; |
300 | *buf++ = le16_to_cpu(sdn->sdn_objnamel); | 300 | *buf++ = le16_to_cpu(sdn->sdn_objnamel); |
301 | memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); | 301 | memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); |
302 | len = 3 + le16_to_cpu(sdn->sdn_objnamel); | 302 | len = 3 + le16_to_cpu(sdn->sdn_objnamel); |
303 | break; | 303 | break; |
304 | case 2: | 304 | case 2: |
305 | memset(buf, 0, 5); | 305 | memset(buf, 0, 5); |
306 | buf += 5; | 306 | buf += 5; |
307 | *buf++ = le16_to_cpu(sdn->sdn_objnamel); | 307 | *buf++ = le16_to_cpu(sdn->sdn_objnamel); |
308 | memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); | 308 | memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); |
309 | len = 7 + le16_to_cpu(sdn->sdn_objnamel); | 309 | len = 7 + le16_to_cpu(sdn->sdn_objnamel); |
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | 312 | ||
313 | return len; | 313 | return len; |
@@ -337,23 +337,23 @@ int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn *sdn, | |||
337 | *fmt = *data++; | 337 | *fmt = *data++; |
338 | type = *data++; | 338 | type = *data++; |
339 | 339 | ||
340 | switch(*fmt) { | 340 | switch (*fmt) { |
341 | case 0: | 341 | case 0: |
342 | sdn->sdn_objnum = type; | 342 | sdn->sdn_objnum = type; |
343 | return 2; | 343 | return 2; |
344 | case 1: | 344 | case 1: |
345 | namel = 16; | 345 | namel = 16; |
346 | break; | 346 | break; |
347 | case 2: | 347 | case 2: |
348 | len -= 4; | 348 | len -= 4; |
349 | data += 4; | 349 | data += 4; |
350 | break; | 350 | break; |
351 | case 4: | 351 | case 4: |
352 | len -= 8; | 352 | len -= 8; |
353 | data += 8; | 353 | data += 8; |
354 | break; | 354 | break; |
355 | default: | 355 | default: |
356 | return -1; | 356 | return -1; |
357 | } | 357 | } |
358 | 358 | ||
359 | len -= 1; | 359 | len -= 1; |
@@ -575,25 +575,26 @@ int dn_destroy_timer(struct sock *sk) | |||
575 | 575 | ||
576 | scp->persist = dn_nsp_persist(sk); | 576 | scp->persist = dn_nsp_persist(sk); |
577 | 577 | ||
578 | switch(scp->state) { | 578 | switch (scp->state) { |
579 | case DN_DI: | 579 | case DN_DI: |
580 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); | 580 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); |
581 | if (scp->nsp_rxtshift >= decnet_di_count) | 581 | if (scp->nsp_rxtshift >= decnet_di_count) |
582 | scp->state = DN_CN; | 582 | scp->state = DN_CN; |
583 | return 0; | 583 | return 0; |
584 | 584 | ||
585 | case DN_DR: | 585 | case DN_DR: |
586 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); | 586 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); |
587 | if (scp->nsp_rxtshift >= decnet_dr_count) | 587 | if (scp->nsp_rxtshift >= decnet_dr_count) |
588 | scp->state = DN_DRC; | 588 | scp->state = DN_DRC; |
589 | return 0; | 589 | return 0; |
590 | 590 | ||
591 | case DN_DN: | 591 | case DN_DN: |
592 | if (scp->nsp_rxtshift < decnet_dn_count) { | 592 | if (scp->nsp_rxtshift < decnet_dn_count) { |
593 | /* printk(KERN_DEBUG "dn_destroy_timer: DN\n"); */ | 593 | /* printk(KERN_DEBUG "dn_destroy_timer: DN\n"); */ |
594 | dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, GFP_ATOMIC); | 594 | dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, |
595 | return 0; | 595 | GFP_ATOMIC); |
596 | } | 596 | return 0; |
597 | } | ||
597 | } | 598 | } |
598 | 599 | ||
599 | scp->persist = (HZ * decnet_time_wait); | 600 | scp->persist = (HZ * decnet_time_wait); |
@@ -623,42 +624,42 @@ static void dn_destroy_sock(struct sock *sk) | |||
623 | 624 | ||
624 | sk->sk_state = TCP_CLOSE; | 625 | sk->sk_state = TCP_CLOSE; |
625 | 626 | ||
626 | switch(scp->state) { | 627 | switch (scp->state) { |
627 | case DN_DN: | 628 | case DN_DN: |
628 | dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, | 629 | dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, |
629 | sk->sk_allocation); | 630 | sk->sk_allocation); |
630 | scp->persist_fxn = dn_destroy_timer; | 631 | scp->persist_fxn = dn_destroy_timer; |
631 | scp->persist = dn_nsp_persist(sk); | 632 | scp->persist = dn_nsp_persist(sk); |
632 | break; | 633 | break; |
633 | case DN_CR: | 634 | case DN_CR: |
634 | scp->state = DN_DR; | 635 | scp->state = DN_DR; |
635 | goto disc_reject; | 636 | goto disc_reject; |
636 | case DN_RUN: | 637 | case DN_RUN: |
637 | scp->state = DN_DI; | 638 | scp->state = DN_DI; |
638 | case DN_DI: | 639 | case DN_DI: |
639 | case DN_DR: | 640 | case DN_DR: |
640 | disc_reject: | 641 | disc_reject: |
641 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, sk->sk_allocation); | 642 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, sk->sk_allocation); |
642 | case DN_NC: | 643 | case DN_NC: |
643 | case DN_NR: | 644 | case DN_NR: |
644 | case DN_RJ: | 645 | case DN_RJ: |
645 | case DN_DIC: | 646 | case DN_DIC: |
646 | case DN_CN: | 647 | case DN_CN: |
647 | case DN_DRC: | 648 | case DN_DRC: |
648 | case DN_CI: | 649 | case DN_CI: |
649 | case DN_CD: | 650 | case DN_CD: |
650 | scp->persist_fxn = dn_destroy_timer; | 651 | scp->persist_fxn = dn_destroy_timer; |
651 | scp->persist = dn_nsp_persist(sk); | 652 | scp->persist = dn_nsp_persist(sk); |
652 | break; | 653 | break; |
653 | default: | 654 | default: |
654 | printk(KERN_DEBUG "DECnet: dn_destroy_sock passed socket in invalid state\n"); | 655 | printk(KERN_DEBUG "DECnet: dn_destroy_sock passed socket in invalid state\n"); |
655 | case DN_O: | 656 | case DN_O: |
656 | dn_stop_slow_timer(sk); | 657 | dn_stop_slow_timer(sk); |
657 | 658 | ||
658 | dn_unhash_sock_bh(sk); | 659 | dn_unhash_sock_bh(sk); |
659 | sock_put(sk); | 660 | sock_put(sk); |
660 | 661 | ||
661 | break; | 662 | break; |
662 | } | 663 | } |
663 | } | 664 | } |
664 | 665 | ||
@@ -683,15 +684,15 @@ static int dn_create(struct net *net, struct socket *sock, int protocol, | |||
683 | if (!net_eq(net, &init_net)) | 684 | if (!net_eq(net, &init_net)) |
684 | return -EAFNOSUPPORT; | 685 | return -EAFNOSUPPORT; |
685 | 686 | ||
686 | switch(sock->type) { | 687 | switch (sock->type) { |
687 | case SOCK_SEQPACKET: | 688 | case SOCK_SEQPACKET: |
688 | if (protocol != DNPROTO_NSP) | 689 | if (protocol != DNPROTO_NSP) |
689 | return -EPROTONOSUPPORT; | 690 | return -EPROTONOSUPPORT; |
690 | break; | 691 | break; |
691 | case SOCK_STREAM: | 692 | case SOCK_STREAM: |
692 | break; | 693 | break; |
693 | default: | 694 | default: |
694 | return -ESOCKTNOSUPPORT; | 695 | return -ESOCKTNOSUPPORT; |
695 | } | 696 | } |
696 | 697 | ||
697 | 698 | ||
@@ -987,16 +988,16 @@ static inline int dn_check_state(struct sock *sk, struct sockaddr_dn *addr, int | |||
987 | { | 988 | { |
988 | struct dn_scp *scp = DN_SK(sk); | 989 | struct dn_scp *scp = DN_SK(sk); |
989 | 990 | ||
990 | switch(scp->state) { | 991 | switch (scp->state) { |
991 | case DN_RUN: | 992 | case DN_RUN: |
992 | return 0; | 993 | return 0; |
993 | case DN_CR: | 994 | case DN_CR: |
994 | return dn_confirm_accept(sk, timeo, sk->sk_allocation); | 995 | return dn_confirm_accept(sk, timeo, sk->sk_allocation); |
995 | case DN_CI: | 996 | case DN_CI: |
996 | case DN_CC: | 997 | case DN_CC: |
997 | return dn_wait_run(sk, timeo); | 998 | return dn_wait_run(sk, timeo); |
998 | case DN_O: | 999 | case DN_O: |
999 | return __dn_connect(sk, addr, addrlen, timeo, flags); | 1000 | return __dn_connect(sk, addr, addrlen, timeo, flags); |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | return -EINVAL; | 1003 | return -EINVAL; |
@@ -1363,141 +1364,140 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us | |||
1363 | if (copy_from_user(&u, optval, optlen)) | 1364 | if (copy_from_user(&u, optval, optlen)) |
1364 | return -EFAULT; | 1365 | return -EFAULT; |
1365 | 1366 | ||
1366 | switch(optname) { | 1367 | switch (optname) { |
1367 | case DSO_CONDATA: | 1368 | case DSO_CONDATA: |
1368 | if (sock->state == SS_CONNECTED) | 1369 | if (sock->state == SS_CONNECTED) |
1369 | return -EISCONN; | 1370 | return -EISCONN; |
1370 | if ((scp->state != DN_O) && (scp->state != DN_CR)) | 1371 | if ((scp->state != DN_O) && (scp->state != DN_CR)) |
1371 | return -EINVAL; | 1372 | return -EINVAL; |
1372 | 1373 | ||
1373 | if (optlen != sizeof(struct optdata_dn)) | 1374 | if (optlen != sizeof(struct optdata_dn)) |
1374 | return -EINVAL; | 1375 | return -EINVAL; |
1375 | 1376 | ||
1376 | if (le16_to_cpu(u.opt.opt_optl) > 16) | 1377 | if (le16_to_cpu(u.opt.opt_optl) > 16) |
1377 | return -EINVAL; | 1378 | return -EINVAL; |
1378 | 1379 | ||
1379 | memcpy(&scp->conndata_out, &u.opt, optlen); | 1380 | memcpy(&scp->conndata_out, &u.opt, optlen); |
1380 | break; | 1381 | break; |
1381 | |||
1382 | case DSO_DISDATA: | ||
1383 | if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED) | ||
1384 | return -ENOTCONN; | ||
1385 | |||
1386 | if (optlen != sizeof(struct optdata_dn)) | ||
1387 | return -EINVAL; | ||
1388 | 1382 | ||
1389 | if (le16_to_cpu(u.opt.opt_optl) > 16) | 1383 | case DSO_DISDATA: |
1390 | return -EINVAL; | 1384 | if (sock->state != SS_CONNECTED && |
1385 | scp->accept_mode == ACC_IMMED) | ||
1386 | return -ENOTCONN; | ||
1391 | 1387 | ||
1392 | memcpy(&scp->discdata_out, &u.opt, optlen); | 1388 | if (optlen != sizeof(struct optdata_dn)) |
1393 | break; | 1389 | return -EINVAL; |
1394 | 1390 | ||
1395 | case DSO_CONACCESS: | 1391 | if (le16_to_cpu(u.opt.opt_optl) > 16) |
1396 | if (sock->state == SS_CONNECTED) | 1392 | return -EINVAL; |
1397 | return -EISCONN; | ||
1398 | if (scp->state != DN_O) | ||
1399 | return -EINVAL; | ||
1400 | 1393 | ||
1401 | if (optlen != sizeof(struct accessdata_dn)) | 1394 | memcpy(&scp->discdata_out, &u.opt, optlen); |
1402 | return -EINVAL; | 1395 | break; |
1403 | 1396 | ||
1404 | if ((u.acc.acc_accl > DN_MAXACCL) || | 1397 | case DSO_CONACCESS: |
1405 | (u.acc.acc_passl > DN_MAXACCL) || | 1398 | if (sock->state == SS_CONNECTED) |
1406 | (u.acc.acc_userl > DN_MAXACCL)) | 1399 | return -EISCONN; |
1407 | return -EINVAL; | 1400 | if (scp->state != DN_O) |
1401 | return -EINVAL; | ||
1408 | 1402 | ||
1409 | memcpy(&scp->accessdata, &u.acc, optlen); | 1403 | if (optlen != sizeof(struct accessdata_dn)) |
1410 | break; | 1404 | return -EINVAL; |
1411 | 1405 | ||
1412 | case DSO_ACCEPTMODE: | 1406 | if ((u.acc.acc_accl > DN_MAXACCL) || |
1413 | if (sock->state == SS_CONNECTED) | 1407 | (u.acc.acc_passl > DN_MAXACCL) || |
1414 | return -EISCONN; | 1408 | (u.acc.acc_userl > DN_MAXACCL)) |
1415 | if (scp->state != DN_O) | 1409 | return -EINVAL; |
1416 | return -EINVAL; | ||
1417 | 1410 | ||
1418 | if (optlen != sizeof(int)) | 1411 | memcpy(&scp->accessdata, &u.acc, optlen); |
1419 | return -EINVAL; | 1412 | break; |
1420 | 1413 | ||
1421 | if ((u.mode != ACC_IMMED) && (u.mode != ACC_DEFER)) | 1414 | case DSO_ACCEPTMODE: |
1422 | return -EINVAL; | 1415 | if (sock->state == SS_CONNECTED) |
1416 | return -EISCONN; | ||
1417 | if (scp->state != DN_O) | ||
1418 | return -EINVAL; | ||
1423 | 1419 | ||
1424 | scp->accept_mode = (unsigned char)u.mode; | 1420 | if (optlen != sizeof(int)) |
1425 | break; | 1421 | return -EINVAL; |
1426 | 1422 | ||
1427 | case DSO_CONACCEPT: | 1423 | if ((u.mode != ACC_IMMED) && (u.mode != ACC_DEFER)) |
1424 | return -EINVAL; | ||
1428 | 1425 | ||
1429 | if (scp->state != DN_CR) | 1426 | scp->accept_mode = (unsigned char)u.mode; |
1430 | return -EINVAL; | 1427 | break; |
1431 | timeo = sock_rcvtimeo(sk, 0); | ||
1432 | err = dn_confirm_accept(sk, &timeo, sk->sk_allocation); | ||
1433 | return err; | ||
1434 | 1428 | ||
1435 | case DSO_CONREJECT: | 1429 | case DSO_CONACCEPT: |
1430 | if (scp->state != DN_CR) | ||
1431 | return -EINVAL; | ||
1432 | timeo = sock_rcvtimeo(sk, 0); | ||
1433 | err = dn_confirm_accept(sk, &timeo, sk->sk_allocation); | ||
1434 | return err; | ||
1436 | 1435 | ||
1437 | if (scp->state != DN_CR) | 1436 | case DSO_CONREJECT: |
1438 | return -EINVAL; | 1437 | if (scp->state != DN_CR) |
1438 | return -EINVAL; | ||
1439 | 1439 | ||
1440 | scp->state = DN_DR; | 1440 | scp->state = DN_DR; |
1441 | sk->sk_shutdown = SHUTDOWN_MASK; | 1441 | sk->sk_shutdown = SHUTDOWN_MASK; |
1442 | dn_nsp_send_disc(sk, 0x38, 0, sk->sk_allocation); | 1442 | dn_nsp_send_disc(sk, 0x38, 0, sk->sk_allocation); |
1443 | break; | 1443 | break; |
1444 | 1444 | ||
1445 | default: | 1445 | default: |
1446 | #ifdef CONFIG_NETFILTER | 1446 | #ifdef CONFIG_NETFILTER |
1447 | return nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); | 1447 | return nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); |
1448 | #endif | 1448 | #endif |
1449 | case DSO_LINKINFO: | 1449 | case DSO_LINKINFO: |
1450 | case DSO_STREAM: | 1450 | case DSO_STREAM: |
1451 | case DSO_SEQPACKET: | 1451 | case DSO_SEQPACKET: |
1452 | return -ENOPROTOOPT; | 1452 | return -ENOPROTOOPT; |
1453 | 1453 | ||
1454 | case DSO_MAXWINDOW: | 1454 | case DSO_MAXWINDOW: |
1455 | if (optlen != sizeof(unsigned long)) | 1455 | if (optlen != sizeof(unsigned long)) |
1456 | return -EINVAL; | 1456 | return -EINVAL; |
1457 | if (u.win > NSP_MAX_WINDOW) | 1457 | if (u.win > NSP_MAX_WINDOW) |
1458 | u.win = NSP_MAX_WINDOW; | 1458 | u.win = NSP_MAX_WINDOW; |
1459 | if (u.win == 0) | 1459 | if (u.win == 0) |
1460 | return -EINVAL; | 1460 | return -EINVAL; |
1461 | scp->max_window = u.win; | 1461 | scp->max_window = u.win; |
1462 | if (scp->snd_window > u.win) | 1462 | if (scp->snd_window > u.win) |
1463 | scp->snd_window = u.win; | 1463 | scp->snd_window = u.win; |
1464 | break; | 1464 | break; |
1465 | 1465 | ||
1466 | case DSO_NODELAY: | 1466 | case DSO_NODELAY: |
1467 | if (optlen != sizeof(int)) | 1467 | if (optlen != sizeof(int)) |
1468 | return -EINVAL; | 1468 | return -EINVAL; |
1469 | if (scp->nonagle == 2) | 1469 | if (scp->nonagle == 2) |
1470 | return -EINVAL; | 1470 | return -EINVAL; |
1471 | scp->nonagle = (u.val == 0) ? 0 : 1; | 1471 | scp->nonagle = (u.val == 0) ? 0 : 1; |
1472 | /* if (scp->nonagle == 1) { Push pending frames } */ | 1472 | /* if (scp->nonagle == 1) { Push pending frames } */ |
1473 | break; | 1473 | break; |
1474 | 1474 | ||
1475 | case DSO_CORK: | 1475 | case DSO_CORK: |
1476 | if (optlen != sizeof(int)) | 1476 | if (optlen != sizeof(int)) |
1477 | return -EINVAL; | 1477 | return -EINVAL; |
1478 | if (scp->nonagle == 1) | 1478 | if (scp->nonagle == 1) |
1479 | return -EINVAL; | 1479 | return -EINVAL; |
1480 | scp->nonagle = (u.val == 0) ? 0 : 2; | 1480 | scp->nonagle = (u.val == 0) ? 0 : 2; |
1481 | /* if (scp->nonagle == 0) { Push pending frames } */ | 1481 | /* if (scp->nonagle == 0) { Push pending frames } */ |
1482 | break; | 1482 | break; |
1483 | 1483 | ||
1484 | case DSO_SERVICES: | 1484 | case DSO_SERVICES: |
1485 | if (optlen != sizeof(unsigned char)) | 1485 | if (optlen != sizeof(unsigned char)) |
1486 | return -EINVAL; | 1486 | return -EINVAL; |
1487 | if ((u.services & ~NSP_FC_MASK) != 0x01) | 1487 | if ((u.services & ~NSP_FC_MASK) != 0x01) |
1488 | return -EINVAL; | 1488 | return -EINVAL; |
1489 | if ((u.services & NSP_FC_MASK) == NSP_FC_MASK) | 1489 | if ((u.services & NSP_FC_MASK) == NSP_FC_MASK) |
1490 | return -EINVAL; | 1490 | return -EINVAL; |
1491 | scp->services_loc = u.services; | 1491 | scp->services_loc = u.services; |
1492 | break; | 1492 | break; |
1493 | 1493 | ||
1494 | case DSO_INFO: | 1494 | case DSO_INFO: |
1495 | if (optlen != sizeof(unsigned char)) | 1495 | if (optlen != sizeof(unsigned char)) |
1496 | return -EINVAL; | 1496 | return -EINVAL; |
1497 | if (u.info & 0xfc) | 1497 | if (u.info & 0xfc) |
1498 | return -EINVAL; | 1498 | return -EINVAL; |
1499 | scp->info_loc = u.info; | 1499 | scp->info_loc = u.info; |
1500 | break; | 1500 | break; |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | return 0; | 1503 | return 0; |
@@ -1527,107 +1527,106 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us | |||
1527 | if(get_user(r_len , optlen)) | 1527 | if(get_user(r_len , optlen)) |
1528 | return -EFAULT; | 1528 | return -EFAULT; |
1529 | 1529 | ||
1530 | switch(optname) { | 1530 | switch (optname) { |
1531 | case DSO_CONDATA: | 1531 | case DSO_CONDATA: |
1532 | if (r_len > sizeof(struct optdata_dn)) | 1532 | if (r_len > sizeof(struct optdata_dn)) |
1533 | r_len = sizeof(struct optdata_dn); | 1533 | r_len = sizeof(struct optdata_dn); |
1534 | r_data = &scp->conndata_in; | 1534 | r_data = &scp->conndata_in; |
1535 | break; | 1535 | break; |
1536 | |||
1537 | case DSO_DISDATA: | ||
1538 | if (r_len > sizeof(struct optdata_dn)) | ||
1539 | r_len = sizeof(struct optdata_dn); | ||
1540 | r_data = &scp->discdata_in; | ||
1541 | break; | ||
1542 | 1536 | ||
1543 | case DSO_CONACCESS: | 1537 | case DSO_DISDATA: |
1544 | if (r_len > sizeof(struct accessdata_dn)) | 1538 | if (r_len > sizeof(struct optdata_dn)) |
1545 | r_len = sizeof(struct accessdata_dn); | 1539 | r_len = sizeof(struct optdata_dn); |
1546 | r_data = &scp->accessdata; | 1540 | r_data = &scp->discdata_in; |
1547 | break; | 1541 | break; |
1548 | 1542 | ||
1549 | case DSO_ACCEPTMODE: | 1543 | case DSO_CONACCESS: |
1550 | if (r_len > sizeof(unsigned char)) | 1544 | if (r_len > sizeof(struct accessdata_dn)) |
1551 | r_len = sizeof(unsigned char); | 1545 | r_len = sizeof(struct accessdata_dn); |
1552 | r_data = &scp->accept_mode; | 1546 | r_data = &scp->accessdata; |
1553 | break; | 1547 | break; |
1554 | 1548 | ||
1555 | case DSO_LINKINFO: | 1549 | case DSO_ACCEPTMODE: |
1556 | if (r_len > sizeof(struct linkinfo_dn)) | 1550 | if (r_len > sizeof(unsigned char)) |
1557 | r_len = sizeof(struct linkinfo_dn); | 1551 | r_len = sizeof(unsigned char); |
1552 | r_data = &scp->accept_mode; | ||
1553 | break; | ||
1558 | 1554 | ||
1559 | memset(&link, 0, sizeof(link)); | 1555 | case DSO_LINKINFO: |
1556 | if (r_len > sizeof(struct linkinfo_dn)) | ||
1557 | r_len = sizeof(struct linkinfo_dn); | ||
1560 | 1558 | ||
1561 | switch(sock->state) { | 1559 | memset(&link, 0, sizeof(link)); |
1562 | case SS_CONNECTING: | ||
1563 | link.idn_linkstate = LL_CONNECTING; | ||
1564 | break; | ||
1565 | case SS_DISCONNECTING: | ||
1566 | link.idn_linkstate = LL_DISCONNECTING; | ||
1567 | break; | ||
1568 | case SS_CONNECTED: | ||
1569 | link.idn_linkstate = LL_RUNNING; | ||
1570 | break; | ||
1571 | default: | ||
1572 | link.idn_linkstate = LL_INACTIVE; | ||
1573 | } | ||
1574 | 1560 | ||
1575 | link.idn_segsize = scp->segsize_rem; | 1561 | switch (sock->state) { |
1576 | r_data = &link; | 1562 | case SS_CONNECTING: |
1563 | link.idn_linkstate = LL_CONNECTING; | ||
1564 | break; | ||
1565 | case SS_DISCONNECTING: | ||
1566 | link.idn_linkstate = LL_DISCONNECTING; | ||
1567 | break; | ||
1568 | case SS_CONNECTED: | ||
1569 | link.idn_linkstate = LL_RUNNING; | ||
1577 | break; | 1570 | break; |
1578 | |||
1579 | default: | 1571 | default: |
1572 | link.idn_linkstate = LL_INACTIVE; | ||
1573 | } | ||
1574 | |||
1575 | link.idn_segsize = scp->segsize_rem; | ||
1576 | r_data = &link; | ||
1577 | break; | ||
1578 | |||
1579 | default: | ||
1580 | #ifdef CONFIG_NETFILTER | 1580 | #ifdef CONFIG_NETFILTER |
1581 | { | 1581 | { |
1582 | int ret, len; | 1582 | int ret, len; |
1583 | 1583 | ||
1584 | if(get_user(len, optlen)) | 1584 | if (get_user(len, optlen)) |
1585 | return -EFAULT; | 1585 | return -EFAULT; |
1586 | 1586 | ||
1587 | ret = nf_getsockopt(sk, PF_DECnet, optname, | 1587 | ret = nf_getsockopt(sk, PF_DECnet, optname, optval, &len); |
1588 | optval, &len); | 1588 | if (ret >= 0) |
1589 | if (ret >= 0) | 1589 | ret = put_user(len, optlen); |
1590 | ret = put_user(len, optlen); | 1590 | return ret; |
1591 | return ret; | 1591 | } |
1592 | } | ||
1593 | #endif | 1592 | #endif |
1594 | case DSO_STREAM: | 1593 | case DSO_STREAM: |
1595 | case DSO_SEQPACKET: | 1594 | case DSO_SEQPACKET: |
1596 | case DSO_CONACCEPT: | 1595 | case DSO_CONACCEPT: |
1597 | case DSO_CONREJECT: | 1596 | case DSO_CONREJECT: |
1598 | return -ENOPROTOOPT; | 1597 | return -ENOPROTOOPT; |
1599 | 1598 | ||
1600 | case DSO_MAXWINDOW: | 1599 | case DSO_MAXWINDOW: |
1601 | if (r_len > sizeof(unsigned long)) | 1600 | if (r_len > sizeof(unsigned long)) |
1602 | r_len = sizeof(unsigned long); | 1601 | r_len = sizeof(unsigned long); |
1603 | r_data = &scp->max_window; | 1602 | r_data = &scp->max_window; |
1604 | break; | 1603 | break; |
1605 | 1604 | ||
1606 | case DSO_NODELAY: | 1605 | case DSO_NODELAY: |
1607 | if (r_len > sizeof(int)) | 1606 | if (r_len > sizeof(int)) |
1608 | r_len = sizeof(int); | 1607 | r_len = sizeof(int); |
1609 | val = (scp->nonagle == 1); | 1608 | val = (scp->nonagle == 1); |
1610 | r_data = &val; | 1609 | r_data = &val; |
1611 | break; | 1610 | break; |
1612 | 1611 | ||
1613 | case DSO_CORK: | 1612 | case DSO_CORK: |
1614 | if (r_len > sizeof(int)) | 1613 | if (r_len > sizeof(int)) |
1615 | r_len = sizeof(int); | 1614 | r_len = sizeof(int); |
1616 | val = (scp->nonagle == 2); | 1615 | val = (scp->nonagle == 2); |
1617 | r_data = &val; | 1616 | r_data = &val; |
1618 | break; | 1617 | break; |
1619 | 1618 | ||
1620 | case DSO_SERVICES: | 1619 | case DSO_SERVICES: |
1621 | if (r_len > sizeof(unsigned char)) | 1620 | if (r_len > sizeof(unsigned char)) |
1622 | r_len = sizeof(unsigned char); | 1621 | r_len = sizeof(unsigned char); |
1623 | r_data = &scp->services_rem; | 1622 | r_data = &scp->services_rem; |
1624 | break; | 1623 | break; |
1625 | 1624 | ||
1626 | case DSO_INFO: | 1625 | case DSO_INFO: |
1627 | if (r_len > sizeof(unsigned char)) | 1626 | if (r_len > sizeof(unsigned char)) |
1628 | r_len = sizeof(unsigned char); | 1627 | r_len = sizeof(unsigned char); |
1629 | r_data = &scp->info_rem; | 1628 | r_data = &scp->info_rem; |
1630 | break; | 1629 | break; |
1631 | } | 1630 | } |
1632 | 1631 | ||
1633 | if (r_data) { | 1632 | if (r_data) { |
@@ -2088,15 +2087,15 @@ static int dn_device_event(struct notifier_block *this, unsigned long event, | |||
2088 | if (!net_eq(dev_net(dev), &init_net)) | 2087 | if (!net_eq(dev_net(dev), &init_net)) |
2089 | return NOTIFY_DONE; | 2088 | return NOTIFY_DONE; |
2090 | 2089 | ||
2091 | switch(event) { | 2090 | switch (event) { |
2092 | case NETDEV_UP: | 2091 | case NETDEV_UP: |
2093 | dn_dev_up(dev); | 2092 | dn_dev_up(dev); |
2094 | break; | 2093 | break; |
2095 | case NETDEV_DOWN: | 2094 | case NETDEV_DOWN: |
2096 | dn_dev_down(dev); | 2095 | dn_dev_down(dev); |
2097 | break; | 2096 | break; |
2098 | default: | 2097 | default: |
2099 | break; | 2098 | break; |
2100 | } | 2099 | } |
2101 | 2100 | ||
2102 | return NOTIFY_DONE; | 2101 | return NOTIFY_DONE; |
@@ -2209,54 +2208,54 @@ static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf) | |||
2209 | int i; | 2208 | int i; |
2210 | 2209 | ||
2211 | switch (le16_to_cpu(dn->sdn_objnamel)) { | 2210 | switch (le16_to_cpu(dn->sdn_objnamel)) { |
2212 | case 0: | 2211 | case 0: |
2213 | sprintf(buf, "%d", dn->sdn_objnum); | 2212 | sprintf(buf, "%d", dn->sdn_objnum); |
2214 | break; | 2213 | break; |
2215 | default: | 2214 | default: |
2216 | for (i = 0; i < le16_to_cpu(dn->sdn_objnamel); i++) { | 2215 | for (i = 0; i < le16_to_cpu(dn->sdn_objnamel); i++) { |
2217 | buf[i] = dn->sdn_objname[i]; | 2216 | buf[i] = dn->sdn_objname[i]; |
2218 | if (IS_NOT_PRINTABLE(buf[i])) | 2217 | if (IS_NOT_PRINTABLE(buf[i])) |
2219 | buf[i] = '.'; | 2218 | buf[i] = '.'; |
2220 | } | 2219 | } |
2221 | buf[i] = 0; | 2220 | buf[i] = 0; |
2222 | } | 2221 | } |
2223 | } | 2222 | } |
2224 | 2223 | ||
2225 | static char *dn_state2asc(unsigned char state) | 2224 | static char *dn_state2asc(unsigned char state) |
2226 | { | 2225 | { |
2227 | switch(state) { | 2226 | switch (state) { |
2228 | case DN_O: | 2227 | case DN_O: |
2229 | return "OPEN"; | 2228 | return "OPEN"; |
2230 | case DN_CR: | 2229 | case DN_CR: |
2231 | return " CR"; | 2230 | return " CR"; |
2232 | case DN_DR: | 2231 | case DN_DR: |
2233 | return " DR"; | 2232 | return " DR"; |
2234 | case DN_DRC: | 2233 | case DN_DRC: |
2235 | return " DRC"; | 2234 | return " DRC"; |
2236 | case DN_CC: | 2235 | case DN_CC: |
2237 | return " CC"; | 2236 | return " CC"; |
2238 | case DN_CI: | 2237 | case DN_CI: |
2239 | return " CI"; | 2238 | return " CI"; |
2240 | case DN_NR: | 2239 | case DN_NR: |
2241 | return " NR"; | 2240 | return " NR"; |
2242 | case DN_NC: | 2241 | case DN_NC: |
2243 | return " NC"; | 2242 | return " NC"; |
2244 | case DN_CD: | 2243 | case DN_CD: |
2245 | return " CD"; | 2244 | return " CD"; |
2246 | case DN_RJ: | 2245 | case DN_RJ: |
2247 | return " RJ"; | 2246 | return " RJ"; |
2248 | case DN_RUN: | 2247 | case DN_RUN: |
2249 | return " RUN"; | 2248 | return " RUN"; |
2250 | case DN_DI: | 2249 | case DN_DI: |
2251 | return " DI"; | 2250 | return " DI"; |
2252 | case DN_DIC: | 2251 | case DN_DIC: |
2253 | return " DIC"; | 2252 | return " DIC"; |
2254 | case DN_DN: | 2253 | case DN_DN: |
2255 | return " DN"; | 2254 | return " DN"; |
2256 | case DN_CL: | 2255 | case DN_CL: |
2257 | return " CL"; | 2256 | return " CL"; |
2258 | case DN_CN: | 2257 | case DN_CN: |
2259 | return " CN"; | 2258 | return " CN"; |
2260 | } | 2259 | } |
2261 | 2260 | ||
2262 | return "????"; | 2261 | return "????"; |