Changeset 7719958 in mainline for uspace/srv/net/ethip/std.h


Ignore:
Timestamp:
2012-04-23T22:51:36Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6a3808e
Parents:
3293a94 (diff), 32fef47 (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 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/ethip/std.h

    r3293a94 r7719958  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup ethip
    3030 * @{
    3131 */
    32 /** @file
    33  * General CRC and checksum computation.
     32/**
     33 * @file Ethernet, IP/Ethernet standard definitions
     34 *
    3435 */
    3536
    36 #ifndef LIBNET_CHECKSUM_H_
    37 #define LIBNET_CHECKSUM_H_
     37#ifndef ETHIP_STD_H_
     38#define ETHIP_STD_H_
    3839
    39 #include <byteorder.h>
    4040#include <sys/types.h>
    4141
    42 /** IP checksum value for computed zero checksum.
    43  *
    44  * Zero is returned as 0xFFFF (not flipped)
    45  *
    46  */
    47 #define IP_CHECKSUM_ZERO  0xffffU
     42#define ETH_ADDR_SIZE 6
     43#define IPV4_ADDR_SIZE 4
     44#define ETH_FRAME_MIN_SIZE 60
    4845
    49 #ifdef __BE__
     46/** Ethernet frame header */
     47typedef struct {
     48        /** Destination Address */
     49        uint8_t dest[ETH_ADDR_SIZE];
     50        /** Source Address */
     51        uint8_t src[ETH_ADDR_SIZE];
     52        /** Ethertype or Length */
     53        uint16_t etype_len;
     54} eth_header_t;
    5055
    51 #define compute_crc32(seed, data, length) \
    52         compute_crc32_be(seed, (uint8_t *) data, length)
     56/** ARP packet format (for 48-bit MAC addresses and IPv4) */
     57typedef struct {
     58        /** Hardware address space */
     59        uint16_t hw_addr_space;
     60        /** Protocol address space */
     61        uint16_t proto_addr_space;
     62        /** Hardware address size */
     63        uint8_t hw_addr_size;
     64        /** Protocol address size */
     65        uint8_t proto_addr_size;
     66        /** Opcode */
     67        uint16_t opcode;
     68        /** Sender hardware address */
     69        uint8_t sender_hw_addr[ETH_ADDR_SIZE];
     70        /** Sender protocol address */
     71        uint32_t sender_proto_addr;
     72        /** Target hardware address */
     73        uint8_t target_hw_addr[ETH_ADDR_SIZE];
     74        /** Target protocol address */
     75        uint32_t target_proto_addr;
     76} __attribute__((packed)) arp_eth_packet_fmt_t;
    5377
    54 #endif
     78enum arp_opcode_fmt {
     79        AOP_REQUEST = 1,
     80        AOP_REPLY   = 2
     81};
    5582
    56 #ifdef __LE__
     83enum arp_hw_addr_space {
     84        AHRD_ETHERNET = 1
     85};
    5786
    58 #define compute_crc32(seed, data, length) \
    59         compute_crc32_le(seed, (uint8_t *) data, length)
     87/** IP Ethertype */
     88enum ether_type {
     89        ETYPE_ARP = 0x0806,
     90        ETYPE_IP  = 0x0800
     91};
    6092
    61 #endif
    62 
    63 extern uint32_t compute_crc32_le(uint32_t, uint8_t *, size_t);
    64 extern uint32_t compute_crc32_be(uint32_t, uint8_t *, size_t);
    65 extern uint32_t compute_checksum(uint32_t, uint8_t *, size_t);
    66 extern uint16_t compact_checksum(uint32_t);
    67 extern uint16_t flip_checksum(uint16_t);
    68 extern uint16_t ip_checksum(uint8_t *, size_t);
    6993
    7094#endif
Note: See TracChangeset for help on using the changeset viewer.