aboutsummaryrefslogtreecommitdiffstats
path: root/net/appletalk/ddp.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-07-01 05:43:02 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-01 19:11:15 -0400
commit4a9e4b09326baa6db30ae35e3521bf5259b238f5 (patch)
tree4f7bf882d15ccc515de67c83e4fcae561e1ca80b /net/appletalk/ddp.c
parent4e985adaa504c1c1a05c8e013777ea0791a17b4d (diff)
appletalk: Reduce switch/case indent
Make the case labels the same indent as the switch. (git diff -w net/appletalk shows no difference) Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/appletalk/ddp.c')
-rw-r--r--net/appletalk/ddp.c380
1 files changed, 190 insertions, 190 deletions
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 956a5302002a..b1fe7c35e8d1 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -684,192 +684,192 @@ static int atif_ioctl(int cmd, void __user *arg)
684 atif = atalk_find_dev(dev); 684 atif = atalk_find_dev(dev);
685 685
686 switch (cmd) { 686 switch (cmd) {
687 case SIOCSIFADDR: 687 case SIOCSIFADDR:
688 if (!capable(CAP_NET_ADMIN)) 688 if (!capable(CAP_NET_ADMIN))
689 return -EPERM; 689 return -EPERM;
690 if (sa->sat_family != AF_APPLETALK) 690 if (sa->sat_family != AF_APPLETALK)
691 return -EINVAL; 691 return -EINVAL;
692 if (dev->type != ARPHRD_ETHER && 692 if (dev->type != ARPHRD_ETHER &&
693 dev->type != ARPHRD_LOOPBACK && 693 dev->type != ARPHRD_LOOPBACK &&
694 dev->type != ARPHRD_LOCALTLK && 694 dev->type != ARPHRD_LOCALTLK &&
695 dev->type != ARPHRD_PPP) 695 dev->type != ARPHRD_PPP)
696 return -EPROTONOSUPPORT; 696 return -EPROTONOSUPPORT;
697 697
698 nr = (struct atalk_netrange *)&sa->sat_zero[0]; 698 nr = (struct atalk_netrange *)&sa->sat_zero[0];
699 add_route = 1; 699 add_route = 1;
700
701 /*
702 * if this is a point-to-point iface, and we already
703 * have an iface for this AppleTalk address, then we
704 * should not add a route
705 */
706 if ((dev->flags & IFF_POINTOPOINT) &&
707 atalk_find_interface(sa->sat_addr.s_net,
708 sa->sat_addr.s_node)) {
709 printk(KERN_DEBUG "AppleTalk: point-to-point "
710 "interface added with "
711 "existing address\n");
712 add_route = 0;
713 }
714 700
715 /* 701 /*
716 * Phase 1 is fine on LocalTalk but we don't do 702 * if this is a point-to-point iface, and we already
717 * EtherTalk phase 1. Anyone wanting to add it go ahead. 703 * have an iface for this AppleTalk address, then we
718 */ 704 * should not add a route
719 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) 705 */
720 return -EPROTONOSUPPORT; 706 if ((dev->flags & IFF_POINTOPOINT) &&
721 if (sa->sat_addr.s_node == ATADDR_BCAST || 707 atalk_find_interface(sa->sat_addr.s_net,
722 sa->sat_addr.s_node == 254) 708 sa->sat_addr.s_node)) {
723 return -EINVAL; 709 printk(KERN_DEBUG "AppleTalk: point-to-point "
724 if (atif) { 710 "interface added with "
725 /* Already setting address */ 711 "existing address\n");
726 if (atif->status & ATIF_PROBE) 712 add_route = 0;
727 return -EBUSY; 713 }
728
729 atif->address.s_net = sa->sat_addr.s_net;
730 atif->address.s_node = sa->sat_addr.s_node;
731 atrtr_device_down(dev); /* Flush old routes */
732 } else {
733 atif = atif_add_device(dev, &sa->sat_addr);
734 if (!atif)
735 return -ENOMEM;
736 }
737 atif->nets = *nr;
738
739 /*
740 * Check if the chosen address is used. If so we
741 * error and atalkd will try another.
742 */
743
744 if (!(dev->flags & IFF_LOOPBACK) &&
745 !(dev->flags & IFF_POINTOPOINT) &&
746 atif_probe_device(atif) < 0) {
747 atif_drop_device(dev);
748 return -EADDRINUSE;
749 }
750
751 /* Hey it worked - add the direct routes */
752 sa = (struct sockaddr_at *)&rtdef.rt_gateway;
753 sa->sat_family = AF_APPLETALK;
754 sa->sat_addr.s_net = atif->address.s_net;
755 sa->sat_addr.s_node = atif->address.s_node;
756 sa = (struct sockaddr_at *)&rtdef.rt_dst;
757 rtdef.rt_flags = RTF_UP;
758 sa->sat_family = AF_APPLETALK;
759 sa->sat_addr.s_node = ATADDR_ANYNODE;
760 if (dev->flags & IFF_LOOPBACK ||
761 dev->flags & IFF_POINTOPOINT)
762 rtdef.rt_flags |= RTF_HOST;
763
764 /* Routerless initial state */
765 if (nr->nr_firstnet == htons(0) &&
766 nr->nr_lastnet == htons(0xFFFE)) {
767 sa->sat_addr.s_net = atif->address.s_net;
768 atrtr_create(&rtdef, dev);
769 atrtr_set_default(dev);
770 } else {
771 limit = ntohs(nr->nr_lastnet);
772 if (limit - ntohs(nr->nr_firstnet) > 4096) {
773 printk(KERN_WARNING "Too many routes/"
774 "iface.\n");
775 return -EINVAL;
776 }
777 if (add_route)
778 for (ct = ntohs(nr->nr_firstnet);
779 ct <= limit; ct++) {
780 sa->sat_addr.s_net = htons(ct);
781 atrtr_create(&rtdef, dev);
782 }
783 }
784 dev_mc_add_global(dev, aarp_mcast);
785 return 0;
786 714
787 case SIOCGIFADDR: 715 /*
716 * Phase 1 is fine on LocalTalk but we don't do
717 * EtherTalk phase 1. Anyone wanting to add it go ahead.
718 */
719 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2)
720 return -EPROTONOSUPPORT;
721 if (sa->sat_addr.s_node == ATADDR_BCAST ||
722 sa->sat_addr.s_node == 254)
723 return -EINVAL;
724 if (atif) {
725 /* Already setting address */
726 if (atif->status & ATIF_PROBE)
727 return -EBUSY;
728
729 atif->address.s_net = sa->sat_addr.s_net;
730 atif->address.s_node = sa->sat_addr.s_node;
731 atrtr_device_down(dev); /* Flush old routes */
732 } else {
733 atif = atif_add_device(dev, &sa->sat_addr);
788 if (!atif) 734 if (!atif)
789 return -EADDRNOTAVAIL; 735 return -ENOMEM;
736 }
737 atif->nets = *nr;
790 738
791 sa->sat_family = AF_APPLETALK; 739 /*
792 sa->sat_addr = atif->address; 740 * Check if the chosen address is used. If so we
793 break; 741 * error and atalkd will try another.
742 */
794 743
795 case SIOCGIFBRDADDR: 744 if (!(dev->flags & IFF_LOOPBACK) &&
796 if (!atif) 745 !(dev->flags & IFF_POINTOPOINT) &&
797 return -EADDRNOTAVAIL; 746 atif_probe_device(atif) < 0) {
747 atif_drop_device(dev);
748 return -EADDRINUSE;
749 }
798 750
799 sa->sat_family = AF_APPLETALK; 751 /* Hey it worked - add the direct routes */
752 sa = (struct sockaddr_at *)&rtdef.rt_gateway;
753 sa->sat_family = AF_APPLETALK;
754 sa->sat_addr.s_net = atif->address.s_net;
755 sa->sat_addr.s_node = atif->address.s_node;
756 sa = (struct sockaddr_at *)&rtdef.rt_dst;
757 rtdef.rt_flags = RTF_UP;
758 sa->sat_family = AF_APPLETALK;
759 sa->sat_addr.s_node = ATADDR_ANYNODE;
760 if (dev->flags & IFF_LOOPBACK ||
761 dev->flags & IFF_POINTOPOINT)
762 rtdef.rt_flags |= RTF_HOST;
763
764 /* Routerless initial state */
765 if (nr->nr_firstnet == htons(0) &&
766 nr->nr_lastnet == htons(0xFFFE)) {
800 sa->sat_addr.s_net = atif->address.s_net; 767 sa->sat_addr.s_net = atif->address.s_net;
801 sa->sat_addr.s_node = ATADDR_BCAST; 768 atrtr_create(&rtdef, dev);
802 break; 769 atrtr_set_default(dev);
803 770 } else {
804 case SIOCATALKDIFADDR: 771 limit = ntohs(nr->nr_lastnet);
805 case SIOCDIFADDR: 772 if (limit - ntohs(nr->nr_firstnet) > 4096) {
806 if (!capable(CAP_NET_ADMIN)) 773 printk(KERN_WARNING "Too many routes/"
807 return -EPERM; 774 "iface.\n");
808 if (sa->sat_family != AF_APPLETALK)
809 return -EINVAL; 775 return -EINVAL;
810 atalk_dev_down(dev); 776 }
811 break; 777 if (add_route)
812 778 for (ct = ntohs(nr->nr_firstnet);
813 case SIOCSARP: 779 ct <= limit; ct++) {
814 if (!capable(CAP_NET_ADMIN)) 780 sa->sat_addr.s_net = htons(ct);
815 return -EPERM; 781 atrtr_create(&rtdef, dev);
816 if (sa->sat_family != AF_APPLETALK) 782 }
817 return -EINVAL; 783 }
818 /* 784 dev_mc_add_global(dev, aarp_mcast);
819 * for now, we only support proxy AARP on ELAP; 785 return 0;
820 * we should be able to do it for LocalTalk, too. 786
821 */ 787 case SIOCGIFADDR:
822 if (dev->type != ARPHRD_ETHER) 788 if (!atif)
823 return -EPROTONOSUPPORT; 789 return -EADDRNOTAVAIL;
824 790
825 /* 791 sa->sat_family = AF_APPLETALK;
826 * atif points to the current interface on this network; 792 sa->sat_addr = atif->address;
827 * we aren't concerned about its current status (at 793 break;
828 * least for now), but it has all the settings about 794
829 * the network we're going to probe. Consequently, it 795 case SIOCGIFBRDADDR:
830 * must exist. 796 if (!atif)
831 */ 797 return -EADDRNOTAVAIL;
832 if (!atif) 798
833 return -EADDRNOTAVAIL; 799 sa->sat_family = AF_APPLETALK;
800 sa->sat_addr.s_net = atif->address.s_net;
801 sa->sat_addr.s_node = ATADDR_BCAST;
802 break;
803
804 case SIOCATALKDIFADDR:
805 case SIOCDIFADDR:
806 if (!capable(CAP_NET_ADMIN))
807 return -EPERM;
808 if (sa->sat_family != AF_APPLETALK)
809 return -EINVAL;
810 atalk_dev_down(dev);
811 break;
834 812
835 nr = (struct atalk_netrange *)&(atif->nets); 813 case SIOCSARP:
836 /* 814 if (!capable(CAP_NET_ADMIN))
837 * Phase 1 is fine on Localtalk but we don't do 815 return -EPERM;
838 * Ethertalk phase 1. Anyone wanting to add it go ahead. 816 if (sa->sat_family != AF_APPLETALK)
839 */ 817 return -EINVAL;
840 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) 818 /*
841 return -EPROTONOSUPPORT; 819 * for now, we only support proxy AARP on ELAP;
820 * we should be able to do it for LocalTalk, too.
821 */
822 if (dev->type != ARPHRD_ETHER)
823 return -EPROTONOSUPPORT;
842 824
843 if (sa->sat_addr.s_node == ATADDR_BCAST || 825 /*
844 sa->sat_addr.s_node == 254) 826 * atif points to the current interface on this network;
845 return -EINVAL; 827 * we aren't concerned about its current status (at
828 * least for now), but it has all the settings about
829 * the network we're going to probe. Consequently, it
830 * must exist.
831 */
832 if (!atif)
833 return -EADDRNOTAVAIL;
846 834
847 /* 835 nr = (struct atalk_netrange *)&(atif->nets);
848 * Check if the chosen address is used. If so we 836 /*
849 * error and ATCP will try another. 837 * Phase 1 is fine on Localtalk but we don't do
850 */ 838 * Ethertalk phase 1. Anyone wanting to add it go ahead.
851 if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0) 839 */
852 return -EADDRINUSE; 840 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2)
841 return -EPROTONOSUPPORT;
853 842
854 /* 843 if (sa->sat_addr.s_node == ATADDR_BCAST ||
855 * We now have an address on the local network, and 844 sa->sat_addr.s_node == 254)
856 * the AARP code will defend it for us until we take it 845 return -EINVAL;
857 * down. We don't set up any routes right now, because
858 * ATCP will install them manually via SIOCADDRT.
859 */
860 break;
861 846
862 case SIOCDARP: 847 /*
863 if (!capable(CAP_NET_ADMIN)) 848 * Check if the chosen address is used. If so we
864 return -EPERM; 849 * error and ATCP will try another.
865 if (sa->sat_family != AF_APPLETALK) 850 */
866 return -EINVAL; 851 if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0)
867 if (!atif) 852 return -EADDRINUSE;
868 return -EADDRNOTAVAIL;
869 853
870 /* give to aarp module to remove proxy entry */ 854 /*
871 aarp_proxy_remove(atif->dev, &(sa->sat_addr)); 855 * We now have an address on the local network, and
872 return 0; 856 * the AARP code will defend it for us until we take it
857 * down. We don't set up any routes right now, because
858 * ATCP will install them manually via SIOCADDRT.
859 */
860 break;
861
862 case SIOCDARP:
863 if (!capable(CAP_NET_ADMIN))
864 return -EPERM;
865 if (sa->sat_family != AF_APPLETALK)
866 return -EINVAL;
867 if (!atif)
868 return -EADDRNOTAVAIL;
869
870 /* give to aarp module to remove proxy entry */
871 aarp_proxy_remove(atif->dev, &(sa->sat_addr));
872 return 0;
873 } 873 }
874 874
875 return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0; 875 return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0;
@@ -884,25 +884,25 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
884 return -EFAULT; 884 return -EFAULT;
885 885
886 switch (cmd) { 886 switch (cmd) {
887 case SIOCDELRT: 887 case SIOCDELRT:
888 if (rt.rt_dst.sa_family != AF_APPLETALK) 888 if (rt.rt_dst.sa_family != AF_APPLETALK)
889 return -EINVAL; 889 return -EINVAL;
890 return atrtr_delete(&((struct sockaddr_at *) 890 return atrtr_delete(&((struct sockaddr_at *)
891 &rt.rt_dst)->sat_addr); 891 &rt.rt_dst)->sat_addr);
892 892
893 case SIOCADDRT: { 893 case SIOCADDRT: {
894 struct net_device *dev = NULL; 894 struct net_device *dev = NULL;
895 if (rt.rt_dev) { 895 if (rt.rt_dev) {
896 char name[IFNAMSIZ]; 896 char name[IFNAMSIZ];
897 if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) 897 if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1))
898 return -EFAULT; 898 return -EFAULT;
899 name[IFNAMSIZ-1] = '\0'; 899 name[IFNAMSIZ-1] = '\0';
900 dev = __dev_get_by_name(&init_net, name); 900 dev = __dev_get_by_name(&init_net, name);
901 if (!dev) 901 if (!dev)
902 return -ENODEV; 902 return -ENODEV;
903 }
904 return atrtr_create(&rt, dev);
905 } 903 }
904 return atrtr_create(&rt, dev);
905 }
906 } 906 }
907 return -EINVAL; 907 return -EINVAL;
908} 908}