Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/nil/eth/eth.c

    rfb04cba8 r4ef32e0c  
    204204        fibril_rwlock_write_lock(&eth_globals.protos_lock);
    205205        eth_globals.net_phone = net_phone;
    206 
    207206        eth_globals.broadcast_addr =
    208207            measured_string_create_bulk("\xFF\xFF\xFF\xFF\xFF\xFF",
     
    212211                goto out;
    213212        }
    214 
    215213        rc = eth_devices_initialize(&eth_globals.devices);
    216214        if (rc != EOK) {
     
    218216                goto out;
    219217        }
    220 
    221218        rc = eth_protos_initialize(&eth_globals.protos);
    222219        if (rc != EOK) {
     
    283280 *                      netif_get_addr_req() function.
    284281 */
    285 static int eth_device_message(device_id_t device_id, services_t service,
    286     size_t mtu)
     282static int
     283eth_device_message(device_id_t device_id, services_t service, size_t mtu)
    287284{
    288285        eth_device_ref device;
     
    305302
    306303        fibril_rwlock_write_lock(&eth_globals.devices_lock);
    307         /* An existing device? */
     304        // an existing device?
    308305        device = eth_devices_find(&eth_globals.devices, device_id);
    309306        if (device) {
     
    314311                }
    315312               
    316                 /* Update mtu */
     313                // update mtu
    317314                if ((mtu > 0) && (mtu <= ETH_MAX_TAGGED_CONTENT(device->flags)))
    318315                        device->mtu = mtu;
     
    324321                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    325322               
    326                 /* Notify all upper layer modules */
     323                // notify all upper layer modules
    327324                fibril_rwlock_read_lock(&eth_globals.protos_lock);
    328325                for (index = 0; index < eth_protos_count(&eth_globals.protos);
     
    336333                        }
    337334                }
    338 
    339335                fibril_rwlock_read_unlock(&eth_globals.protos_lock);
    340336                return EOK;
    341337        }
    342338       
    343         /* Create a new device */
     339        // create a new device
    344340        device = (eth_device_ref) malloc(sizeof(eth_device_t));
    345341        if (!device)
     
    362358                return rc;
    363359        }
    364 
    365360        if (configuration) {
    366361                if (!str_lcmp(configuration[0].value, "DIX",
     
    383378        }
    384379       
    385         /* Bind the device driver */
     380        // bind the device driver
    386381        device->phone = netif_bind_service(device->service, device->device_id,
    387382            SERVICE_ETHERNET, eth_receiver);
     
    392387        }
    393388       
    394         /* Get hardware address */
     389        // get hardware address
    395390        rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
    396391            &device->addr_data);
     
    401396        }
    402397       
    403         /* Add to the cache */
     398        // add to the cache
    404399        index = eth_devices_add(&eth_globals.devices, device->device_id,
    405400            device);
     
    458453       
    459454        if (type >= ETH_MIN_PROTO) {
    460                 /* DIX Ethernet */
     455                // DIX Ethernet
    461456                prefix = sizeof(eth_header_t);
    462457                suffix = 0;
     
    464459                length -= sizeof(eth_fcs_t);
    465460        } else if(type <= ETH_MAX_CONTENT) {
    466                 /* Translate "LSAP" values */
     461                // translate "LSAP" values
    467462                if ((header->lsap.dsap == ETH_LSAP_GLSAP) &&
    468463                    (header->lsap.ssap == ETH_LSAP_GLSAP)) {
    469                         /* Raw packet -- discard */
     464                        // raw packet
     465                        // discard
    470466                        return NULL;
    471467                } else if((header->lsap.dsap == ETH_LSAP_SNAP) &&
    472468                    (header->lsap.ssap == ETH_LSAP_SNAP)) {
    473                         /*
    474                          * IEEE 802.3 + 802.2 + LSAP + SNAP
    475                          * organization code not supported
    476                          */
     469                        // IEEE 802.3 + 802.2 + LSAP + SNAP
     470                        // organization code not supported
    477471                        type = ntohs(header->snap.ethertype);
    478472                        prefix = sizeof(eth_header_t) +
     
    480474                            sizeof(eth_header_snap_t);
    481475                } else {
    482                         /* IEEE 802.3 + 802.2 LSAP */
     476                        // IEEE 802.3 + 802.2 LSAP
    483477                        type = lsap_map(header->lsap.dsap);
    484478                        prefix = sizeof(eth_header_t) +
    485479                            sizeof(eth_header_lsap_t);
    486480                }
    487 
    488481                suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U;
    489482                fcs = (eth_fcs_ref) data + prefix + type + suffix;
     
    491484                length = prefix + type + suffix;
    492485        } else {
    493                 /* Invalid length/type, should not occur */
     486                // invalid length/type, should not occurr
    494487                return NULL;
    495488        }
     
    513506}
    514507
    515 int nil_received_msg_local(int nil_phone, device_id_t device_id,
    516     packet_t packet, services_t target)
     508int
     509nil_received_msg_local(int nil_phone, device_id_t device_id, packet_t packet,
     510    services_t target)
    517511{
    518512        eth_proto_ref proto;
     
    527521                return ENOENT;
    528522        }
    529 
    530523        flags = device->flags;
    531524        fibril_rwlock_read_unlock(&eth_globals.devices_lock);
     
    545538                packet = next;
    546539        } while(packet);
    547 
    548540        fibril_rwlock_read_unlock(&eth_globals.protos_lock);
     541       
    549542        return EOK;
    550543}
     
    561554 * @returns             ENOENT if there is no such device.
    562555 */
    563 static int eth_packet_space_message(device_id_t device_id, size_t *addr_len,
     556static int
     557eth_packet_space_message(device_id_t device_id, size_t *addr_len,
    564558    size_t *prefix, size_t *content, size_t *suffix)
    565559{
     
    575569                return ENOENT;
    576570        }
    577 
    578571        *content = device->mtu;
    579572        fibril_rwlock_read_unlock(&eth_globals.devices_lock);
     
    582575        *prefix = ETH_PREFIX;
    583576        *suffix = ETH_MIN_CONTENT + ETH_SUFFIX;
    584 
    585577        return EOK;
    586578}
     
    595587 * @returns             ENOENT if there no such device.
    596588 */
    597 static int eth_addr_message(device_id_t device_id, eth_addr_type_t type,
     589static int
     590eth_addr_message(device_id_t device_id, eth_addr_type_t type,
    598591    measured_string_ref *address)
    599592{
     
    651644                        return ENOMEM;
    652645                }
    653 
    654646                proto->service = service;
    655647                proto->protocol = protocol;
    656648                proto->phone = phone;
    657 
    658649                index = eth_protos_add(&eth_globals.protos, protocol, proto);
    659650                if (index < 0) {
     
    714705                if (!padding)
    715706                        return ENOMEM;
    716 
    717707                bzero(padding, ETH_MIN_TAGGED_CONTENT(flags) - length);
    718708        }
     
    792782 * @returns             EINVAL if the service parameter is not known.
    793783 */
    794 static int eth_send_message(device_id_t device_id, packet_t packet,
    795     services_t sender)
     784static int
     785eth_send_message(device_id_t device_id, packet_t packet, services_t sender)
    796786{
    797787        eth_device_ref device;
     
    814804        }
    815805       
    816         /* Process packet queue */
     806        // process packet queue
    817807        next = packet;
    818808        do {
     
    820810                    (uint8_t *) device->addr->value, ethertype, device->mtu);
    821811                if (rc != EOK) {
    822                         /* Release invalid packet */
     812                        // release invalid packet
    823813                        tmp = pq_detach(next);
    824814                        if (next == packet)
     
    832822        } while(next);
    833823       
    834         /* Send packet queue */
     824        // send packet queue
    835825        if (packet) {
    836826                netif_send_msg(device->phone, device_id, packet,
    837827                    SERVICE_ETHERNET);
    838828        }
    839 
    840829        fibril_rwlock_read_unlock(&eth_globals.devices_lock);
     830       
    841831        return EOK;
    842832}
    843833
    844 int nil_message_standalone(const char *name, ipc_callid_t callid,
    845     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     834int
     835nil_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call,
     836    ipc_call_t *answer, int *answer_count)
    846837{
    847838        measured_string_ref address;
     
    903894 * @param[in] iid       The initial message identifier.
    904895 * @param[in] icall     The initial message call structure.
     896 *
    905897 */
    906898static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall)
Note: See TracChangeset for help on using the changeset viewer.