Changeset 32eceb4f in mainline for uspace/srv/net/nil/eth/eth.c


Ignore:
Timestamp:
2010-11-20T22:30:36Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cb59f787
Parents:
1b22bd4 (diff), 7e1f9b7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r1b22bd4 r32eceb4f  
    156156typedef enum eth_addr_type eth_addr_type_t;
    157157
    158 /** Type definition of the ethernet address type pointer.
    159  * @see eth_addr_type
    160  */
    161 typedef eth_addr_type_t *eth_addr_type_ref;
    162 
    163158/** Ethernet address type. */
    164159enum eth_addr_type {
     
    178173{
    179174        int index;
    180         eth_proto_ref proto;
     175        eth_proto_t *proto;
    181176
    182177        fibril_rwlock_read_lock(&eth_globals.protos_lock);
     
    239234static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall)
    240235{
    241         packet_t packet;
     236        packet_t *packet;
    242237        int rc;
    243238
     
    273268 * @param[in] service   The device driver service.
    274269 * @param[in] mtu       The device maximum transmission unit.
    275  * @returns             EOK on success.
    276  * @returns             EEXIST if the device with the different service exists.
    277  * @returns             ENOMEM if there is not enough memory left.
    278  * @returns             Other error codes as defined for the
     270 * @return              EOK on success.
     271 * @return              EEXIST if the device with the different service exists.
     272 * @return              ENOMEM if there is not enough memory left.
     273 * @return              Other error codes as defined for the
    279274 *                      net_get_device_conf_req() function.
    280  * @returns             Other error codes as defined for the
     275 * @return              Other error codes as defined for the
    281276 *                      netif_bind_service() function.
    282  * @returns             Other error codes as defined for the
     277 * @return              Other error codes as defined for the
    283278 *                      netif_get_addr_req() function.
    284279 */
     
    286281    size_t mtu)
    287282{
    288         eth_device_ref device;
     283        eth_device_t *device;
    289284        int index;
    290285        measured_string_t names[2] = {
     
    298293                }
    299294        };
    300         measured_string_ref configuration;
     295        measured_string_t *configuration;
    301296        size_t count = sizeof(names) / sizeof(measured_string_t);
    302297        char *data;
    303         eth_proto_ref proto;
     298        eth_proto_t *proto;
    304299        int rc;
    305300
     
    342337       
    343338        /* Create a new device */
    344         device = (eth_device_ref) malloc(sizeof(eth_device_t));
     339        device = (eth_device_t *) malloc(sizeof(eth_device_t));
    345340        if (!device)
    346341                return ENOMEM;
     
    427422 * @param[in] flags     The device flags.
    428423 * @param[in] packet    The packet.
    429  * @returns             The target registered module.
    430  * @returns             NULL if the packet is not long enough.
    431  * @returns             NULL if the packet is too long.
    432  * @returns             NULL if the raw ethernet protocol is used.
    433  * @returns             NULL if the dummy device FCS checksum is invalid.
    434  * @returns             NULL if the packet address length is not big enough.
    435  */
    436 static eth_proto_ref eth_process_packet(int flags, packet_t packet)
    437 {
    438         eth_header_snap_ref header;
     424 * @return              The target registered module.
     425 * @return              NULL if the packet is not long enough.
     426 * @return              NULL if the packet is too long.
     427 * @return              NULL if the raw ethernet protocol is used.
     428 * @return              NULL if the dummy device FCS checksum is invalid.
     429 * @return              NULL if the packet address length is not big enough.
     430 */
     431static eth_proto_t *eth_process_packet(int flags, packet_t *packet)
     432{
     433        eth_header_snap_t *header;
    439434        size_t length;
    440435        eth_type_t type;
    441436        size_t prefix;
    442437        size_t suffix;
    443         eth_fcs_ref fcs;
     438        eth_fcs_t *fcs;
    444439        uint8_t *data;
    445440        int rc;
     
    454449       
    455450        data = packet_get_data(packet);
    456         header = (eth_header_snap_ref) data;
     451        header = (eth_header_snap_t *) data;
    457452        type = ntohs(header->header.ethertype);
    458453       
     
    461456                prefix = sizeof(eth_header_t);
    462457                suffix = 0;
    463                 fcs = (eth_fcs_ref) data + length - sizeof(eth_fcs_t);
     458                fcs = (eth_fcs_t *) data + length - sizeof(eth_fcs_t);
    464459                length -= sizeof(eth_fcs_t);
    465460        } else if(type <= ETH_MAX_CONTENT) {
     
    487482
    488483                suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U;
    489                 fcs = (eth_fcs_ref) data + prefix + type + suffix;
     484                fcs = (eth_fcs_t *) data + prefix + type + suffix;
    490485                suffix += length - prefix - type;
    491486                length = prefix + type + suffix;
     
    514509
    515510int nil_received_msg_local(int nil_phone, device_id_t device_id,
    516     packet_t packet, services_t target)
    517 {
    518         eth_proto_ref proto;
    519         packet_t next;
    520         eth_device_ref device;
     511    packet_t *packet, services_t target)
     512{
     513        eth_proto_t *proto;
     514        packet_t *next;
     515        eth_device_t *device;
    521516        int flags;
    522517
     
    557552 * @param[out] content  The maximum content size.
    558553 * @param[out] suffix   The minimum reserved suffix size.
    559  * @returns             EOK on success.
    560  * @returns             EBADMEM if either one of the parameters is NULL.
    561  * @returns             ENOENT if there is no such device.
     554 * @return              EOK on success.
     555 * @return              EBADMEM if either one of the parameters is NULL.
     556 * @return              ENOENT if there is no such device.
    562557 */
    563558static int eth_packet_space_message(device_id_t device_id, size_t *addr_len,
    564559    size_t *prefix, size_t *content, size_t *suffix)
    565560{
    566         eth_device_ref device;
     561        eth_device_t *device;
    567562
    568563        if (!addr_len || !prefix || !content || !suffix)
     
    591586 * @param[in] type      Type of the desired address.
    592587 * @param[out] address  The device hardware address.
    593  * @returns             EOK on success.
    594  * @returns             EBADMEM if the address parameter is NULL.
    595  * @returns             ENOENT if there no such device.
     588 * @return              EOK on success.
     589 * @return              EBADMEM if the address parameter is NULL.
     590 * @return              ENOENT if there no such device.
    596591 */
    597592static int eth_addr_message(device_id_t device_id, eth_addr_type_t type,
    598     measured_string_ref *address)
    599 {
    600         eth_device_ref device;
     593    measured_string_t **address)
     594{
     595        eth_device_t *device;
    601596
    602597        if (!address)
     
    625620 * @param[in] service   The module service.
    626621 * @param[in] phone     The service phone.
    627  * @returns             EOK on success.
    628  * @returns             ENOENT if the service is not known.
    629  * @returns             ENOMEM if there is not enough memory left.
     622 * @return              EOK on success.
     623 * @return              ENOENT if the service is not known.
     624 * @return              ENOMEM if there is not enough memory left.
    630625 */
    631626static int eth_register_message(services_t service, int phone)
    632627{
    633         eth_proto_ref proto;
     628        eth_proto_t *proto;
    634629        int protocol;
    635630        int index;
     
    646641                return EOK;
    647642        } else {
    648                 proto = (eth_proto_ref) malloc(sizeof(eth_proto_t));
     643                proto = (eth_proto_t *) malloc(sizeof(eth_proto_t));
    649644                if (!proto) {
    650645                        fibril_rwlock_write_unlock(&eth_globals.protos_lock);
     
    678673 * @param[in] ethertype The ethernet protocol type.
    679674 * @param[in] mtu       The device maximum transmission unit.
    680  * @returns             EOK on success.
    681  * @returns             EINVAL if the packet addresses length is not long
     675 * @return              EOK on success.
     676 * @return              EINVAL if the packet addresses length is not long
    682677 *                      enough.
    683  * @returns             EINVAL if the packet is bigger than the device MTU.
    684  * @returns             ENOMEM if there is not enough memory in the packet.
     678 * @return              EINVAL if the packet is bigger than the device MTU.
     679 * @return              ENOMEM if there is not enough memory in the packet.
    685680 */
    686681static int
    687 eth_prepare_packet(int flags, packet_t packet, uint8_t *src_addr, int ethertype,
     682eth_prepare_packet(int flags, packet_t *packet, uint8_t *src_addr, int ethertype,
    688683    size_t mtu)
    689684{
    690         eth_header_snap_ref header;
    691         eth_header_lsap_ref header_lsap;
    692         eth_header_ref header_dix;
    693         eth_fcs_ref fcs;
     685        eth_header_snap_t *header;
     686        eth_header_lsap_t *header_lsap;
     687        eth_header_t *header_dix;
     688        eth_fcs_t *fcs;
    694689        uint8_t *src;
    695690        uint8_t *dest;
     
    697692        int i;
    698693        void *padding;
    699         eth_preamble_ref preamble;
     694        eth_preamble_t *preamble;
    700695
    701696        i = packet_get_addr(packet, &src, &dest);
     
    788783 * @param[in] packet    The packet queue.
    789784 * @param[in] sender    The sending module service.
    790  * @returns             EOK on success.
    791  * @returns             ENOENT if there no such device.
    792  * @returns             EINVAL if the service parameter is not known.
    793  */
    794 static int eth_send_message(device_id_t device_id, packet_t packet,
     785 * @return              EOK on success.
     786 * @return              ENOENT if there no such device.
     787 * @return              EINVAL if the service parameter is not known.
     788 */
     789static int eth_send_message(device_id_t device_id, packet_t *packet,
    795790    services_t sender)
    796791{
    797         eth_device_ref device;
    798         packet_t next;
    799         packet_t tmp;
     792        eth_device_t *device;
     793        packet_t *next;
     794        packet_t *tmp;
    800795        int ethertype;
    801796        int rc;
     
    845840    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
    846841{
    847         measured_string_ref address;
    848         packet_t packet;
     842        measured_string_t *address;
     843        packet_t *packet;
    849844        size_t addrlen;
    850845        size_t prefix;
Note: See TracChangeset for help on using the changeset viewer.