Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7f95c904 in mainline


Ignore:
Timestamp:
2012-04-16T07:04:19Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
7fda2e0
Parents:
347768d
Message:

Prototype datagram reassembly.

Location:
uspace/srv/inet
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/inet/Makefile

    r347768d r7f95c904  
    3939        inetping.c \
    4040        pdu.c \
     41        reass.c \
    4142        sroute.c
    4243
  • uspace/srv/inet/inet.c

    r347768d r7f95c904  
    5454#include "inetping.h"
    5555#include "inet_link.h"
     56#include "reass.h"
    5657#include "sroute.h"
    5758
     
    375376}
    376377
    377 static int inet_recv_dgram_local(inet_dgram_t *dgram, uint8_t proto)
     378int inet_recv_dgram_local(inet_dgram_t *dgram, uint8_t proto)
    378379{
    379380        inet_client_t *client;
     
    404405                /* Destined for one of the local addresses */
    405406
    406                 /* XXX Reassemble packets */
    407                 dgram.src = packet->src;
    408                 dgram.dest = packet->dest;
    409                 dgram.tos = packet->tos;
    410                 dgram.data = packet->data;
    411                 dgram.size = packet->size;
    412 
    413                 return inet_recv_dgram_local(&dgram, packet->proto);
     407                /* Check if packet is a complete datagram */
     408                if (packet->offs == 0 && !packet->mf) {
     409                        /* It is complete deliver it immediately */
     410                        dgram.src = packet->src;
     411                        dgram.dest = packet->dest;
     412                        dgram.tos = packet->tos;
     413                        dgram.data = packet->data;
     414                        dgram.size = packet->size;
     415
     416                        return inet_recv_dgram_local(&dgram, packet->proto);
     417                } else {
     418                        /* It is a fragment, queue it for reassembly */
     419                        inet_reass_queue_packet(packet);
     420                }
    414421        }
    415422
  • uspace/srv/inet/inet.h

    r347768d r7f95c904  
    3939
    4040#include <adt/list.h>
     41#include <bool.h>
    4142#include <inet/iplink.h>
    4243#include <ipc/loc.h>
     
    103104
    104105typedef struct {
     106        /** Source address */
    105107        inet_addr_t src;
     108        /** Destination address */
    106109        inet_addr_t dest;
     110        /** Type of service */
    107111        uint8_t tos;
     112        /** Protocol */
    108113        uint8_t proto;
     114        /** Time to live */
    109115        uint8_t ttl;
    110         int df;
     116        /** Identifier */
     117        uint16_t ident;
     118        /** Do not fragment */
     119        bool df;
     120        /** More fragments */
     121        bool mf;
     122        /** Offset of fragment into datagram, in bytes */
     123        size_t offs;
     124        /** Packet data */
    111125        void *data;
     126        /** Packet data size in bytes */
    112127        size_t size;
    113128} inet_packet_t;
     
    180195extern int inet_route_packet(inet_dgram_t *, uint8_t, uint8_t, int);
    181196extern int inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
    182 
     197extern int inet_recv_dgram_local(inet_dgram_t *, uint8_t);
    183198
    184199#endif
  • uspace/srv/inet/inet_link.c

    r347768d r7f95c904  
    7474        rc = inet_recv_packet(&packet);
    7575        log_msg(LVL_DEBUG, "call inet_recv_packet -> %d", rc);
     76        free(packet.data);
    7677
    7778        return rc;
  • uspace/srv/inet/pdu.c

    r347768d r7f95c904  
    201201        uint8_t version;
    202202        uint16_t ident;
     203        uint16_t flags_foff;
     204        uint16_t foff;
    203205
    204206        log_msg(LVL_DEBUG, "inet_pdu_decode()");
     
    231233
    232234        ident = uint16_t_be2host(hdr->id);
    233         (void)ident;
    234         /* XXX Flags */
    235         /* XXX Fragment offset */
     235        flags_foff = uint16_t_be2host(hdr->flags_foff);
     236        foff = BIT_RANGE_EXTRACT(uint16_t, FF_FRAGOFF_h, FF_FRAGOFF_l,
     237            flags_foff);
    236238        /* XXX Checksum */
    237239
     
    241243        packet->proto = hdr->proto;
    242244        packet->ttl = hdr->ttl;
    243         packet->df = (uint16_t_be2host(hdr->tos) & BIT_V(uint16_t, FF_FLAG_DF))
    244             ? 1 : 0;
     245        packet->ident = ident;
     246
     247        packet->df = (flags_foff & BIT_V(uint16_t, FF_FLAG_DF)) != 0;
     248        packet->mf = (flags_foff & BIT_V(uint16_t, FF_FLAG_MF)) != 0;
     249        packet->offs = foff * FRAG_OFFS_UNIT;
    245250
    246251        /* XXX IP options */
Note: See TracChangeset for help on using the changeset viewer.