1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 3 * INET An implementation of the TCP/I 4 * operating system. INET is imp 5 * interface as the means of comm 6 * 7 * FDDI-type device handling. 8 * 9 * Version: @(#)fddi.c 1.0.0 08/12/ 10 * 11 * Authors: Lawrence V. Stefani, <stefani@ 12 * 13 * fddi.c is based on previous et 14 * Ross Biro 15 * Fred N. van Kempen, <w 16 * Mark Evans, <evansmp@u 17 * Florian La Roche, <rzs 18 * Alan Cox, <gw4pts@gw4p 19 * 20 * Changes 21 * Alan Cox : 22 * Maciej W. Rozycki : 23 */ 24 25 #include <linux/module.h> 26 #include <linux/types.h> 27 #include <linux/kernel.h> 28 #include <linux/string.h> 29 #include <linux/mm.h> 30 #include <linux/socket.h> 31 #include <linux/in.h> 32 #include <linux/inet.h> 33 #include <linux/netdevice.h> 34 #include <linux/fddidevice.h> 35 #include <linux/if_ether.h> 36 #include <linux/skbuff.h> 37 #include <linux/errno.h> 38 #include <net/arp.h> 39 #include <net/sock.h> 40 41 /* 42 * Create the FDDI MAC header for an arbitrary 43 * 44 * saddr=NULL means use device source addres 45 * daddr=NULL means leave destination addres 46 */ 47 48 static int fddi_header(struct sk_buff *skb, st 49 unsigned short type, 50 const void *daddr, cons 51 { 52 int hl = FDDI_K_SNAP_HLEN; 53 struct fddihdr *fddi; 54 55 if(type != ETH_P_IP && type != ETH_P_I 56 hl=FDDI_K_8022_HLEN-3; 57 fddi = skb_push(skb, hl); 58 fddi->fc = FDD 59 if(type == ETH_P_IP || type == ETH_P_I 60 { 61 fddi->hdr.llc_snap.dsap 62 fddi->hdr.llc_snap.ssap 63 fddi->hdr.llc_snap.ctrl 64 fddi->hdr.llc_snap.oui[0] 65 fddi->hdr.llc_snap.oui[1] 66 fddi->hdr.llc_snap.oui[2] 67 fddi->hdr.llc_snap.ethertype 68 } 69 70 /* Set the source and destination hard 71 72 if (saddr != NULL) 73 memcpy(fddi->saddr, saddr, dev 74 else 75 memcpy(fddi->saddr, dev->dev_a 76 77 if (daddr != NULL) 78 { 79 memcpy(fddi->daddr, daddr, dev 80 return hl; 81 } 82 83 return -hl; 84 } 85 86 /* 87 * Determine the packet's protocol ID and fill 88 * This routine is called before an incoming p 89 * up. It's used to fill in specific skb fiel 90 * the proper pointer to the start of packet d 91 */ 92 93 __be16 fddi_type_trans(struct sk_buff *skb, st 94 { 95 struct fddihdr *fddi = (struct fddihdr 96 __be16 type; 97 98 /* 99 * Set mac.raw field to point to FC by 100 * to start of packet data. Assume 80 101 */ 102 103 skb->dev = dev; 104 skb_reset_mac_header(skb); /* poi 105 106 if(fddi->hdr.llc_8022_1.dsap==0xe0) 107 { 108 skb_pull(skb, FDDI_K_8022_HLEN 109 type = htons(ETH_P_802_2); 110 } 111 else 112 { 113 skb_pull(skb, FDDI_K_SNAP_HLEN 114 type=fddi->hdr.llc_snap.ethert 115 } 116 117 /* Set packet type based on destinatio 118 119 if (*fddi->daddr & 0x01) 120 { 121 if (memcmp(fddi->daddr, dev->b 122 skb->pkt_type = PACKET 123 else 124 skb->pkt_type = PACKET 125 } 126 127 else if (dev->flags & IFF_PROMISC) 128 { 129 if (memcmp(fddi->daddr, dev->d 130 skb->pkt_type = PACKET 131 } 132 133 /* Assume 802.2 SNAP frames, for now * 134 135 return type; 136 } 137 138 EXPORT_SYMBOL(fddi_type_trans); 139 140 static const struct header_ops fddi_header_ops 141 .create = fddi_header, 142 }; 143 144 145 static void fddi_setup(struct net_device *dev) 146 { 147 dev->header_ops = &fddi_header 148 dev->type = ARPHRD_FDDI; 149 dev->hard_header_len = FDDI_K_SNAP_ 150 dev->mtu = FDDI_K_SNAP_ 151 dev->min_mtu = FDDI_K_SNAP_ 152 dev->max_mtu = FDDI_K_SNAP_ 153 dev->addr_len = FDDI_K_ALEN; 154 dev->tx_queue_len = 100; 155 dev->flags = IFF_BROADCAS 156 157 memset(dev->broadcast, 0xFF, FDDI_K_AL 158 } 159 160 /** 161 * alloc_fddidev - Register FDDI device 162 * @sizeof_priv: Size of additional driver-pri 163 * for this FDDI device 164 * 165 * Fill in the fields of the device structure 166 * 167 * Constructs a new net device, complete with 168 * size @sizeof_priv. A 32-byte (not bit) ali 169 * this private data area. 170 */ 171 struct net_device *alloc_fddidev(int sizeof_pr 172 { 173 return alloc_netdev(sizeof_priv, "fddi 174 fddi_setup); 175 } 176 EXPORT_SYMBOL(alloc_fddidev); 177 178 MODULE_DESCRIPTION("Core routines for FDDI net 179 MODULE_LICENSE("GPL"); 180
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.