Changeset 00d7e1b in mainline for uspace/lib/c/include/net/device.h


Ignore:
Timestamp:
2011-10-07T20:20:33Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49bd793b
Parents:
e2c50e1
Message:

networking improvements

  • start the networking stack from init
  • add loopback network interface driver (cherrypicked and sanitized from lp:~helenos-nicf/helenos/nicf)
  • add libnic and various small pieces from lp:~helenos-nicf/helenos/nicf
  • fix client side of NIC_GET_ADDRESS
  • net binary overhaul

Note: "ping 127.0.0.1" works, but the first three pings timeout for some reason

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/net/device.h

    re2c50e1 r00d7e1b  
    4141#include <adt/int_map.h>
    4242#include <net/eth_phys.h>
     43#include <bool.h>
    4344
    4445/** Ethernet address length. */
     
    5152#define ARGSMAC(__a) \
    5253        (__a)[0], (__a)[1], (__a)[2], (__a)[3], (__a)[4], (__a)[5]
     54
     55/* Compare MAC address with specific value */
     56#define MAC_EQUALS_VALUE(__a, __a0, __a1, __a2, __a3, __a4, __a5) \
     57        ((__a)[0] == (__a0) && (__a)[1] == (__a1) && (__a)[2] == (__a2) \
     58        && (__a)[3] == (__a3) && (__a)[4] == (__a4) && (__a)[5] == (__a5))
     59
     60#define MAC_IS_ZERO(__x) \
     61        MAC_EQUALS_VALUE(__x, 0, 0, 0, 0, 0, 0)
    5362
    5463/** Device identifier to generic type map declaration. */
     
    221230} nic_device_stats_t;
    222231
     232/** Errors corresponding to those in the nic_device_stats_t */
     233typedef enum {
     234        NIC_SEC_BUFFER_FULL,
     235        NIC_SEC_ABORTED,
     236        NIC_SEC_CARRIER_LOST,
     237        NIC_SEC_FIFO_OVERRUN,
     238        NIC_SEC_HEARTBEAT,
     239        NIC_SEC_WINDOW_ERROR,
     240        /* Error encountered during TX but with other type of error */
     241        NIC_SEC_OTHER
     242} nic_send_error_cause_t;
     243
     244/** Errors corresponding to those in the nic_device_stats_t */
     245typedef enum {
     246        NIC_REC_BUFFER_FULL,
     247        NIC_REC_LENGTH,
     248        NIC_REC_BUFFER_OVERFLOW,
     249        NIC_REC_CRC,
     250        NIC_REC_FRAME_ALIGNMENT,
     251        NIC_REC_FIFO_OVERRUN,
     252        NIC_REC_MISSED,
     253        /* Error encountered during RX but with other type of error */
     254        NIC_REC_OTHER
     255} nic_receive_error_cause_t;
     256
    223257/**
    224258 * Information about the NIC that never changes - name, vendor, model,
     
    246280
    247281/**
     282 * Type of the ethernet frame
     283 */
     284typedef enum nic_frame_type {
     285        NIC_FRAME_UNICAST,
     286        NIC_FRAME_MULTICAST,
     287        NIC_FRAME_BROADCAST
     288} nic_frame_type_t;
     289
     290/**
    248291 * Specifies which unicast frames is the NIC receiving.
    249292 */
     
    292335
    293336/**
     337 * Structure passed as argument for virtue NIC_WV_MAGIC_PACKET.
     338 */
     339typedef struct nic_wv_magic_packet_data {
     340        uint8_t password[6];
     341} nic_wv_magic_packet_data_t;
     342
     343/**
     344 * Structure passed as argument for virtue NIC_WV_DIRECTED_IPV4
     345 */
     346typedef struct nic_wv_ipv4_data {
     347        uint8_t address[4];
     348} nic_wv_ipv4_data_t;
     349
     350/**
     351 * Structure passed as argument for virtue NIC_WV_DIRECTED_IPV6
     352 */
     353typedef struct nic_wv_ipv6_data {
     354        uint8_t address[16];
     355} nic_wv_ipv6_data_t;
     356
     357/**
    294358 * WOL virtue types defining the interpretation of data passed to the virtue.
    295359 * Those tagged with S can have only single virtue active at one moment, those
     
    376440        NIC_POLL_SOFTWARE_PERIODIC
    377441} nic_poll_mode_t;
     442
     443/**
     444 * Says if this virtue type is a multi-virtue (there can be multiple virtues of
     445 * this type at once).
     446 *
     447 * @param type
     448 *
     449 * @return true or false
     450 */
     451static inline int nic_wv_is_multi(nic_wv_type_t type) {
     452        switch (type) {
     453        case NIC_WV_FULL_MATCH:
     454        case NIC_WV_DESTINATION:
     455        case NIC_WV_DIRECTED_IPV4:
     456        case NIC_WV_DIRECTED_IPV6:
     457                return true;
     458        default:
     459                return false;
     460        }
     461}
    378462
    379463static inline const char *nic_device_state_to_string(nic_device_state_t state)
Note: See TracChangeset for help on using the changeset viewer.