Changeset 0773396 in mainline for uspace/srv/net/inetsrv/icmp.c


Ignore:
Timestamp:
2013-12-25T13:05:25Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bc54126c
Parents:
f4a47e52 (diff), 6946f23 (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 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/inetsrv/icmp.c

    rf4a47e52 r0773396  
    4040#include <mem.h>
    4141#include <stdlib.h>
    42 #include <net/socket_codes.h>
     42#include <types/inetping.h>
    4343#include "icmp.h"
    4444#include "icmp_std.h"
     
    105105        reply->checksum = host2uint16_t_be(checksum);
    106106
     107        rdgram.iplink = 0;
    107108        rdgram.src = dgram->dest;
    108109        rdgram.dest = dgram->src;
     
    121122{
    122123        log_msg(LOG_DEFAULT, LVL_DEBUG, "icmp_recv_echo_reply()");
    123        
     124
    124125        if (dgram->size < sizeof(icmp_echo_t))
    125126                return EINVAL;
    126        
     127
    127128        icmp_echo_t *reply = (icmp_echo_t *) dgram->data;
    128        
     129
    129130        inetping_sdu_t sdu;
    130        
    131         uint16_t family = inet_addr_get(&dgram->src, &sdu.src, NULL);
    132         if (family != AF_INET)
    133                 return EINVAL;
    134        
    135         family = inet_addr_get(&dgram->dest, &sdu.dest, NULL);
    136         if (family != AF_INET)
    137                 return EINVAL;
    138        
     131
     132        sdu.src = dgram->src;
     133        sdu.dest = dgram->dest;
    139134        sdu.seq_no = uint16_t_be2host(reply->seq_no);
    140135        sdu.data = reply + sizeof(icmp_echo_t);
    141136        sdu.size = dgram->size - sizeof(icmp_echo_t);
    142        
     137
    143138        uint16_t ident = uint16_t_be2host(reply->ident);
    144139
     
    152147        if (rdata == NULL)
    153148                return ENOMEM;
    154        
     149
    155150        icmp_echo_t *request = (icmp_echo_t *) rdata;
    156        
     151
    157152        request->type = ICMP_ECHO_REQUEST;
    158153        request->code = 0;
     
    160155        request->ident = host2uint16_t_be(ident);
    161156        request->seq_no = host2uint16_t_be(sdu->seq_no);
    162        
     157
    163158        memcpy(rdata + sizeof(icmp_echo_t), sdu->data, sdu->size);
    164        
     159
    165160        uint16_t checksum = inet_checksum_calc(INET_CHECKSUM_INIT, rdata, rsize);
    166161        request->checksum = host2uint16_t_be(checksum);
    167        
     162
    168163        inet_dgram_t dgram;
    169        
    170         inet_addr_set(sdu->src, &dgram.src);
    171         inet_addr_set(sdu->dest, &dgram.dest);
    172        
     164
     165        dgram.src = sdu->src;
     166        dgram.dest = sdu->dest;
     167        dgram.iplink = 0;
    173168        dgram.tos = ICMP_TOS;
    174169        dgram.data = rdata;
    175170        dgram.size = rsize;
    176        
     171
    177172        int rc = inet_route_packet(&dgram, IP_PROTO_ICMP, INET_TTL_MAX, 0);
    178        
     173
    179174        free(rdata);
    180175        return rc;
Note: See TracChangeset for help on using the changeset viewer.