Ignore:
File:
1 edited

Legend:

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

    r46d4d9f rfb04cba8  
    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 */
     161typedef eth_addr_type_t *eth_addr_type_ref;
     162
    158163/** Ethernet address type. */
    159164enum eth_addr_type {
     
    173178{
    174179        int index;
    175         eth_proto_t *proto;
     180        eth_proto_ref proto;
    176181
    177182        fibril_rwlock_read_lock(&eth_globals.protos_lock);
     
    234239static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall)
    235240{
    236         packet_t *packet;
     241        packet_t packet;
    237242        int rc;
    238243
     
    268273 * @param[in] service   The device driver service.
    269274 * @param[in] mtu       The device maximum transmission unit.
    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
     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
    274279 *                      net_get_device_conf_req() function.
    275  * @return              Other error codes as defined for the
     280 * @returns             Other error codes as defined for the
    276281 *                      netif_bind_service() function.
    277  * @return              Other error codes as defined for the
     282 * @returns             Other error codes as defined for the
    278283 *                      netif_get_addr_req() function.
    279284 */
     
    281286    size_t mtu)
    282287{
    283         eth_device_t *device;
     288        eth_device_ref device;
    284289        int index;
    285290        measured_string_t names[2] = {
     
    293298                }
    294299        };
    295         measured_string_t *configuration;
     300        measured_string_ref configuration;
    296301        size_t count = sizeof(names) / sizeof(measured_string_t);
    297302        char *data;
    298         eth_proto_t *proto;
     303        eth_proto_ref proto;
    299304        int rc;
    300305
     
    337342       
    338343        /* Create a new device */
    339         device = (eth_device_t *) malloc(sizeof(eth_device_t));
     344        device = (eth_device_ref) malloc(sizeof(eth_device_t));
    340345        if (!device)
    341346                return ENOMEM;
     
    422427 * @param[in] flags     The device flags.
    423428 * @param[in] packet    The packet.
    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  */
    431 static eth_proto_t *eth_process_packet(int flags, packet_t *packet)
    432 {
    433         eth_header_snap_t *header;
     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 */
     436static eth_proto_ref eth_process_packet(int flags, packet_t packet)
     437{
     438        eth_header_snap_ref header;
    434439        size_t length;
    435440        eth_type_t type;
    436441        size_t prefix;
    437442        size_t suffix;
    438         eth_fcs_t *fcs;
     443        eth_fcs_ref fcs;
    439444        uint8_t *data;
    440445        int rc;
     
    449454       
    450455        data = packet_get_data(packet);
    451         header = (eth_header_snap_t *) data;
     456        header = (eth_header_snap_ref) data;
    452457        type = ntohs(header->header.ethertype);
    453458       
     
    456461                prefix = sizeof(eth_header_t);
    457462                suffix = 0;
    458                 fcs = (eth_fcs_t *) data + length - sizeof(eth_fcs_t);
     463                fcs = (eth_fcs_ref) data + length - sizeof(eth_fcs_t);
    459464                length -= sizeof(eth_fcs_t);
    460465        } else if(type <= ETH_MAX_CONTENT) {
     
    482487
    483488                suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U;
    484                 fcs = (eth_fcs_t *) data + prefix + type + suffix;
     489                fcs = (eth_fcs_ref) data + prefix + type + suffix;
    485490                suffix += length - prefix - type;
    486491                length = prefix + type + suffix;
     
    509514
    510515int nil_received_msg_local(int nil_phone, device_id_t device_id,
    511     packet_t *packet, services_t target)
    512 {
    513         eth_proto_t *proto;
    514         packet_t *next;
    515         eth_device_t *device;
     516    packet_t packet, services_t target)
     517{
     518        eth_proto_ref proto;
     519        packet_t next;
     520        eth_device_ref device;
    516521        int flags;
    517522
     
    552557 * @param[out] content  The maximum content size.
    553558 * @param[out] suffix   The minimum reserved suffix size.
    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.
     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.
    557562 */
    558563static int eth_packet_space_message(device_id_t device_id, size_t *addr_len,
    559564    size_t *prefix, size_t *content, size_t *suffix)
    560565{
    561         eth_device_t *device;
     566        eth_device_ref device;
    562567
    563568        if (!addr_len || !prefix || !content || !suffix)
     
    586591 * @param[in] type      Type of the desired address.
    587592 * @param[out] address  The device hardware address.
    588  * @return              EOK on success.
    589  * @return              EBADMEM if the address parameter is NULL.
    590  * @return              ENOENT if there no such device.
     593 * @returns             EOK on success.
     594 * @returns             EBADMEM if the address parameter is NULL.
     595 * @returns             ENOENT if there no such device.
    591596 */
    592597static int eth_addr_message(device_id_t device_id, eth_addr_type_t type,
    593     measured_string_t **address)
    594 {
    595         eth_device_t *device;
     598    measured_string_ref *address)
     599{
     600        eth_device_ref device;
    596601
    597602        if (!address)
     
    620625 * @param[in] service   The module service.
    621626 * @param[in] phone     The service phone.
    622  * @return              EOK on success.
    623  * @return              ENOENT if the service is not known.
    624  * @return              ENOMEM if there is not enough memory left.
     627 * @returns             EOK on success.
     628 * @returns             ENOENT if the service is not known.
     629 * @returns             ENOMEM if there is not enough memory left.
    625630 */
    626631static int eth_register_message(services_t service, int phone)
    627632{
    628         eth_proto_t *proto;
     633        eth_proto_ref proto;
    629634        int protocol;
    630635        int index;
     
    641646                return EOK;
    642647        } else {
    643                 proto = (eth_proto_t *) malloc(sizeof(eth_proto_t));
     648                proto = (eth_proto_ref) malloc(sizeof(eth_proto_t));
    644649                if (!proto) {
    645650                        fibril_rwlock_write_unlock(&eth_globals.protos_lock);
     
    673678 * @param[in] ethertype The ethernet protocol type.
    674679 * @param[in] mtu       The device maximum transmission unit.
    675  * @return              EOK on success.
    676  * @return              EINVAL if the packet addresses length is not long
     680 * @returns             EOK on success.
     681 * @returns             EINVAL if the packet addresses length is not long
    677682 *                      enough.
    678  * @return              EINVAL if the packet is bigger than the device MTU.
    679  * @return              ENOMEM if there is not enough memory in the packet.
     683 * @returns             EINVAL if the packet is bigger than the device MTU.
     684 * @returns             ENOMEM if there is not enough memory in the packet.
    680685 */
    681686static int
    682 eth_prepare_packet(int flags, packet_t *packet, uint8_t *src_addr, int ethertype,
     687eth_prepare_packet(int flags, packet_t packet, uint8_t *src_addr, int ethertype,
    683688    size_t mtu)
    684689{
    685         eth_header_snap_t *header;
    686         eth_header_lsap_t *header_lsap;
    687         eth_header_t *header_dix;
    688         eth_fcs_t *fcs;
     690        eth_header_snap_ref header;
     691        eth_header_lsap_ref header_lsap;
     692        eth_header_ref header_dix;
     693        eth_fcs_ref fcs;
    689694        uint8_t *src;
    690695        uint8_t *dest;
     
    692697        int i;
    693698        void *padding;
    694         eth_preamble_t *preamble;
     699        eth_preamble_ref preamble;
    695700
    696701        i = packet_get_addr(packet, &src, &dest);
     
    783788 * @param[in] packet    The packet queue.
    784789 * @param[in] sender    The sending module service.
    785  * @return              EOK on success.
    786  * @return              ENOENT if there no such device.
    787  * @return              EINVAL if the service parameter is not known.
    788  */
    789 static int eth_send_message(device_id_t device_id, packet_t *packet,
     790 * @returns             EOK on success.
     791 * @returns             ENOENT if there no such device.
     792 * @returns             EINVAL if the service parameter is not known.
     793 */
     794static int eth_send_message(device_id_t device_id, packet_t packet,
    790795    services_t sender)
    791796{
    792         eth_device_t *device;
    793         packet_t *next;
    794         packet_t *tmp;
     797        eth_device_ref device;
     798        packet_t next;
     799        packet_t tmp;
    795800        int ethertype;
    796801        int rc;
     
    840845    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
    841846{
    842         measured_string_t *address;
    843         packet_t *packet;
     847        measured_string_ref address;
     848        packet_t packet;
    844849        size_t addrlen;
    845850        size_t prefix;
Note: See TracChangeset for help on using the changeset viewer.