~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/802/fddi.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/802/fddi.c (Version linux-6.11.5) and /net/802/fddi.c (Version linux-5.0.21)


  1 // SPDX-License-Identifier: GPL-2.0-or-later   << 
  2 /*                                                  1 /*
  3  * INET         An implementation of the TCP/I      2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
  4  *              operating system.  INET is imp      3  *              operating system.  INET is implemented using the BSD Socket
  5  *              interface as the means of comm      4  *              interface as the means of communication with the user level.
  6  *                                                  5  *
  7  *              FDDI-type device handling.          6  *              FDDI-type device handling.
  8  *                                                  7  *
  9  * Version:     @(#)fddi.c      1.0.0   08/12/      8  * Version:     @(#)fddi.c      1.0.0   08/12/96
 10  *                                                  9  *
 11  * Authors:     Lawrence V. Stefani, <stefani@     10  * Authors:     Lawrence V. Stefani, <stefani@lkg.dec.com>
 12  *                                                 11  *
 13  *              fddi.c is based on previous et     12  *              fddi.c is based on previous eth.c and tr.c work by
 14  *                      Ross Biro                  13  *                      Ross Biro
 15  *                      Fred N. van Kempen, <w     14  *                      Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 16  *                      Mark Evans, <evansmp@u     15  *                      Mark Evans, <evansmp@uhura.aston.ac.uk>
 17  *                      Florian La Roche, <rzs     16  *                      Florian La Roche, <rzsfl@rz.uni-sb.de>
 18  *                      Alan Cox, <gw4pts@gw4p     17  *                      Alan Cox, <gw4pts@gw4pts.ampr.org>
 19  *                                                 18  *
                                                   >>  19  *              This program is free software; you can redistribute it and/or
                                                   >>  20  *              modify it under the terms of the GNU General Public License
                                                   >>  21  *              as published by the Free Software Foundation; either version
                                                   >>  22  *              2 of the License, or (at your option) any later version.
                                                   >>  23  *
 20  *      Changes                                    24  *      Changes
 21  *              Alan Cox                :          25  *              Alan Cox                :       New arp/rebuild header
 22  *              Maciej W. Rozycki       :          26  *              Maciej W. Rozycki       :       IPv6 support
 23  */                                                27  */
 24                                                    28 
 25 #include <linux/module.h>                          29 #include <linux/module.h>
 26 #include <linux/types.h>                           30 #include <linux/types.h>
 27 #include <linux/kernel.h>                          31 #include <linux/kernel.h>
 28 #include <linux/string.h>                          32 #include <linux/string.h>
 29 #include <linux/mm.h>                              33 #include <linux/mm.h>
 30 #include <linux/socket.h>                          34 #include <linux/socket.h>
 31 #include <linux/in.h>                              35 #include <linux/in.h>
 32 #include <linux/inet.h>                            36 #include <linux/inet.h>
 33 #include <linux/netdevice.h>                       37 #include <linux/netdevice.h>
 34 #include <linux/fddidevice.h>                      38 #include <linux/fddidevice.h>
 35 #include <linux/if_ether.h>                        39 #include <linux/if_ether.h>
 36 #include <linux/skbuff.h>                          40 #include <linux/skbuff.h>
 37 #include <linux/errno.h>                           41 #include <linux/errno.h>
 38 #include <net/arp.h>                               42 #include <net/arp.h>
 39 #include <net/sock.h>                              43 #include <net/sock.h>
 40                                                    44 
 41 /*                                                 45 /*
 42  * Create the FDDI MAC header for an arbitrary     46  * Create the FDDI MAC header for an arbitrary protocol layer
 43  *                                                 47  *
 44  * saddr=NULL   means use device source addres     48  * saddr=NULL   means use device source address
 45  * daddr=NULL   means leave destination addres     49  * daddr=NULL   means leave destination address (eg unresolved arp)
 46  */                                                50  */
 47                                                    51 
 48 static int fddi_header(struct sk_buff *skb, st     52 static int fddi_header(struct sk_buff *skb, struct net_device *dev,
 49                        unsigned short type,        53                        unsigned short type,
 50                        const void *daddr, cons     54                        const void *daddr, const void *saddr, unsigned int len)
 51 {                                                  55 {
 52         int hl = FDDI_K_SNAP_HLEN;                 56         int hl = FDDI_K_SNAP_HLEN;
 53         struct fddihdr *fddi;                      57         struct fddihdr *fddi;
 54                                                    58 
 55         if(type != ETH_P_IP && type != ETH_P_I     59         if(type != ETH_P_IP && type != ETH_P_IPV6 && type != ETH_P_ARP)
 56                 hl=FDDI_K_8022_HLEN-3;             60                 hl=FDDI_K_8022_HLEN-3;
 57         fddi = skb_push(skb, hl);                  61         fddi = skb_push(skb, hl);
 58         fddi->fc                         = FDD     62         fddi->fc                         = FDDI_FC_K_ASYNC_LLC_DEF;
 59         if(type == ETH_P_IP || type == ETH_P_I     63         if(type == ETH_P_IP || type == ETH_P_IPV6 || type == ETH_P_ARP)
 60         {                                          64         {
 61                 fddi->hdr.llc_snap.dsap            65                 fddi->hdr.llc_snap.dsap          = FDDI_EXTENDED_SAP;
 62                 fddi->hdr.llc_snap.ssap            66                 fddi->hdr.llc_snap.ssap          = FDDI_EXTENDED_SAP;
 63                 fddi->hdr.llc_snap.ctrl            67                 fddi->hdr.llc_snap.ctrl          = FDDI_UI_CMD;
 64                 fddi->hdr.llc_snap.oui[0]          68                 fddi->hdr.llc_snap.oui[0]        = 0x00;
 65                 fddi->hdr.llc_snap.oui[1]          69                 fddi->hdr.llc_snap.oui[1]        = 0x00;
 66                 fddi->hdr.llc_snap.oui[2]          70                 fddi->hdr.llc_snap.oui[2]        = 0x00;
 67                 fddi->hdr.llc_snap.ethertype       71                 fddi->hdr.llc_snap.ethertype     = htons(type);
 68         }                                          72         }
 69                                                    73 
 70         /* Set the source and destination hard     74         /* Set the source and destination hardware addresses */
 71                                                    75 
 72         if (saddr != NULL)                         76         if (saddr != NULL)
 73                 memcpy(fddi->saddr, saddr, dev     77                 memcpy(fddi->saddr, saddr, dev->addr_len);
 74         else                                       78         else
 75                 memcpy(fddi->saddr, dev->dev_a     79                 memcpy(fddi->saddr, dev->dev_addr, dev->addr_len);
 76                                                    80 
 77         if (daddr != NULL)                         81         if (daddr != NULL)
 78         {                                          82         {
 79                 memcpy(fddi->daddr, daddr, dev     83                 memcpy(fddi->daddr, daddr, dev->addr_len);
 80                 return hl;                         84                 return hl;
 81         }                                          85         }
 82                                                    86 
 83         return -hl;                                87         return -hl;
 84 }                                                  88 }
 85                                                    89 
 86 /*                                                 90 /*
 87  * Determine the packet's protocol ID and fill     91  * Determine the packet's protocol ID and fill in skb fields.
 88  * This routine is called before an incoming p     92  * This routine is called before an incoming packet is passed
 89  * up.  It's used to fill in specific skb fiel     93  * up.  It's used to fill in specific skb fields and to set
 90  * the proper pointer to the start of packet d     94  * the proper pointer to the start of packet data (skb->data).
 91  */                                                95  */
 92                                                    96 
 93 __be16 fddi_type_trans(struct sk_buff *skb, st     97 __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
 94 {                                                  98 {
 95         struct fddihdr *fddi = (struct fddihdr     99         struct fddihdr *fddi = (struct fddihdr *)skb->data;
 96         __be16 type;                              100         __be16 type;
 97                                                   101 
 98         /*                                        102         /*
 99          * Set mac.raw field to point to FC by    103          * Set mac.raw field to point to FC byte, set data field to point
100          * to start of packet data.  Assume 80    104          * to start of packet data.  Assume 802.2 SNAP frames for now.
101          */                                       105          */
102                                                   106 
103         skb->dev = dev;                           107         skb->dev = dev;
104         skb_reset_mac_header(skb);      /* poi    108         skb_reset_mac_header(skb);      /* point to frame control (FC) */
105                                                   109 
106         if(fddi->hdr.llc_8022_1.dsap==0xe0)       110         if(fddi->hdr.llc_8022_1.dsap==0xe0)
107         {                                         111         {
108                 skb_pull(skb, FDDI_K_8022_HLEN    112                 skb_pull(skb, FDDI_K_8022_HLEN-3);
109                 type = htons(ETH_P_802_2);        113                 type = htons(ETH_P_802_2);
110         }                                         114         }
111         else                                      115         else
112         {                                         116         {
113                 skb_pull(skb, FDDI_K_SNAP_HLEN    117                 skb_pull(skb, FDDI_K_SNAP_HLEN);                /* adjust for 21 byte header */
114                 type=fddi->hdr.llc_snap.ethert    118                 type=fddi->hdr.llc_snap.ethertype;
115         }                                         119         }
116                                                   120 
117         /* Set packet type based on destinatio    121         /* Set packet type based on destination address and flag settings */
118                                                   122 
119         if (*fddi->daddr & 0x01)                  123         if (*fddi->daddr & 0x01)
120         {                                         124         {
121                 if (memcmp(fddi->daddr, dev->b    125                 if (memcmp(fddi->daddr, dev->broadcast, FDDI_K_ALEN) == 0)
122                         skb->pkt_type = PACKET    126                         skb->pkt_type = PACKET_BROADCAST;
123                 else                              127                 else
124                         skb->pkt_type = PACKET    128                         skb->pkt_type = PACKET_MULTICAST;
125         }                                         129         }
126                                                   130 
127         else if (dev->flags & IFF_PROMISC)        131         else if (dev->flags & IFF_PROMISC)
128         {                                         132         {
129                 if (memcmp(fddi->daddr, dev->d    133                 if (memcmp(fddi->daddr, dev->dev_addr, FDDI_K_ALEN))
130                         skb->pkt_type = PACKET    134                         skb->pkt_type = PACKET_OTHERHOST;
131         }                                         135         }
132                                                   136 
133         /* Assume 802.2 SNAP frames, for now *    137         /* Assume 802.2 SNAP frames, for now */
134                                                   138 
135         return type;                              139         return type;
136 }                                                 140 }
137                                                   141 
138 EXPORT_SYMBOL(fddi_type_trans);                   142 EXPORT_SYMBOL(fddi_type_trans);
139                                                   143 
140 static const struct header_ops fddi_header_ops    144 static const struct header_ops fddi_header_ops = {
141         .create         = fddi_header,            145         .create         = fddi_header,
142 };                                                146 };
143                                                   147 
144                                                   148 
145 static void fddi_setup(struct net_device *dev)    149 static void fddi_setup(struct net_device *dev)
146 {                                                 150 {
147         dev->header_ops         = &fddi_header    151         dev->header_ops         = &fddi_header_ops;
148         dev->type               = ARPHRD_FDDI;    152         dev->type               = ARPHRD_FDDI;
149         dev->hard_header_len    = FDDI_K_SNAP_    153         dev->hard_header_len    = FDDI_K_SNAP_HLEN+3;   /* Assume 802.2 SNAP hdr len + 3 pad bytes */
150         dev->mtu                = FDDI_K_SNAP_    154         dev->mtu                = FDDI_K_SNAP_DLEN;     /* Assume max payload of 802.2 SNAP frame */
151         dev->min_mtu            = FDDI_K_SNAP_    155         dev->min_mtu            = FDDI_K_SNAP_HLEN;
152         dev->max_mtu            = FDDI_K_SNAP_    156         dev->max_mtu            = FDDI_K_SNAP_DLEN;
153         dev->addr_len           = FDDI_K_ALEN;    157         dev->addr_len           = FDDI_K_ALEN;
154         dev->tx_queue_len       = 100;            158         dev->tx_queue_len       = 100;                  /* Long queues on FDDI */
155         dev->flags              = IFF_BROADCAS    159         dev->flags              = IFF_BROADCAST | IFF_MULTICAST;
156                                                   160 
157         memset(dev->broadcast, 0xFF, FDDI_K_AL    161         memset(dev->broadcast, 0xFF, FDDI_K_ALEN);
158 }                                                 162 }
159                                                   163 
160 /**                                               164 /**
161  * alloc_fddidev - Register FDDI device           165  * alloc_fddidev - Register FDDI device
162  * @sizeof_priv: Size of additional driver-pri    166  * @sizeof_priv: Size of additional driver-private structure to be allocated
163  *      for this FDDI device                      167  *      for this FDDI device
164  *                                                168  *
165  * Fill in the fields of the device structure     169  * Fill in the fields of the device structure with FDDI-generic values.
166  *                                                170  *
167  * Constructs a new net device, complete with     171  * Constructs a new net device, complete with a private data area of
168  * size @sizeof_priv.  A 32-byte (not bit) ali    172  * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
169  * this private data area.                        173  * this private data area.
170  */                                               174  */
171 struct net_device *alloc_fddidev(int sizeof_pr    175 struct net_device *alloc_fddidev(int sizeof_priv)
172 {                                                 176 {
173         return alloc_netdev(sizeof_priv, "fddi    177         return alloc_netdev(sizeof_priv, "fddi%d", NET_NAME_UNKNOWN,
174                             fddi_setup);          178                             fddi_setup);
175 }                                                 179 }
176 EXPORT_SYMBOL(alloc_fddidev);                     180 EXPORT_SYMBOL(alloc_fddidev);
177                                                   181 
178 MODULE_DESCRIPTION("Core routines for FDDI net << 
179 MODULE_LICENSE("GPL");                            182 MODULE_LICENSE("GPL");
180                                                   183 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php