Changeset 49ff5f3 in mainline for uspace/srv/net/tcp/std.h


Ignore:
Timestamp:
2012-04-18T20:55:21Z (14 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7769ec9
Parents:
e895352 (diff), 63920b0 (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/tcp/std.h

    re895352 r49ff5f3  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup tcp
    3030 * @{
    3131 */
    32 /** @file
    33  * General CRC and checksum computation.
     32/** @file TCP header definitions
     33 *
     34 * Based on IETF RFC 793
    3435 */
    3536
    36 #ifndef LIBNET_CHECKSUM_H_
    37 #define LIBNET_CHECKSUM_H_
     37#ifndef STD_H
     38#define 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/** TCP Header (fixed part) */
     43typedef struct {
     44        /** Source port */
     45        uint16_t src_port;
     46        /** Destination port */
     47        uint16_t dest_port;
     48        /** Sequence number */
     49        uint32_t seq;
     50        /** Acknowledgement number */
     51        uint32_t ack;
     52        /** Data Offset, Reserved, Flags */
     53        uint16_t doff_flags;
     54        /** Window */
     55        uint16_t window;
     56        /* Checksum */
     57        uint16_t checksum;
     58        /** Urgent pointer */
     59        uint16_t urg_ptr;
     60} tcp_header_t;
    4861
    49 #ifdef __BE__
     62/** Bits in tcp_header_t.doff_flags */
     63enum doff_flags_bits {
     64        DF_DATA_OFFSET_h        = 15,
     65        DF_DATA_OFFSET_l        = 12,
     66        DF_URG                  = 5,
     67        DF_ACK                  = 4,
     68        DF_PSH                  = 3,
     69        DF_RST                  = 2,
     70        DF_SYN                  = 1,
     71        DF_FIN                  = 0
     72};
    5073
    51 #define compute_crc32(seed, data, length) \
    52         compute_crc32_be(seed, (uint8_t *) data, length)
     74/** TCP pseudo header */
     75typedef struct {
     76        /** Source address */
     77        uint32_t src_addr;
     78        /** Destination address */
     79        uint32_t dest_addr;
     80        /** Zero */
     81        uint8_t zero;
     82        /** Protocol */
     83        uint8_t protocol;
     84        /** TCP length */
     85        uint16_t tcp_length;
     86} tcp_phdr_t;
    5387
    54 #endif
    55 
    56 #ifdef __LE__
    57 
    58 #define compute_crc32(seed, data, length) \
    59         compute_crc32_le(seed, (uint8_t *) data, length)
    60 
    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);
    69 extern uint64_t multicast_hash(const uint8_t addr[6]);
     88/** Option kind */
     89enum opt_kind {
     90        /** End of option list */
     91        OPT_END_LIST            = 0,
     92        /** No-operation */
     93        OPT_NOP                 = 1,
     94        /** Maximum segment size */
     95        OPT_MAX_SEG_SIZE        = 2
     96};
    7097
    7198#endif
Note: See TracChangeset for help on using the changeset viewer.