Changeset a35b458 in mainline for uspace/srv/net/inetsrv/icmpv6.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

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

    r3061bc1 ra35b458  
    5050{
    5151        log_msg(LOG_DEFAULT, LVL_DEBUG, "icmpv6_recv_echo_request()");
    52        
     52
    5353        if (dgram->size < sizeof(icmpv6_message_t))
    5454                return EINVAL;
    55        
     55
    5656        icmpv6_message_t *request = (icmpv6_message_t *) dgram->data;
    5757        size_t size = dgram->size;
    58        
     58
    5959        addr128_t src_v6;
    6060        ip_ver_t src_ver = inet_addr_get(&dgram->src, NULL, &src_v6);
    61        
     61
    6262        addr128_t dest_v6;
    6363        ip_ver_t dest_ver = inet_addr_get(&dgram->dest, NULL, &dest_v6);
    64        
     64
    6565        if ((src_ver != dest_ver) || (src_ver != ip_v6))
    6666                return EINVAL;
    67        
     67
    6868        icmpv6_message_t *reply = calloc(1, size);
    6969        if (reply == NULL)
    7070                return ENOMEM;
    71        
     71
    7272        memcpy(reply, request, size);
    73        
     73
    7474        reply->type = ICMPV6_ECHO_REPLY;
    7575        reply->code = 0;
    7676        reply->checksum = 0;
    77        
     77
    7878        inet_dgram_t rdgram;
    79        
     79
    8080        inet_get_srcaddr(&dgram->src, 0, &rdgram.src);
    8181        rdgram.dest = dgram->src;
     
    8484        rdgram.data = reply;
    8585        rdgram.size = size;
    86        
     86
    8787        icmpv6_phdr_t phdr;
    88        
     88
    8989        host2addr128_t_be(dest_v6, phdr.src_addr);
    9090        host2addr128_t_be(src_v6, phdr.dest_addr);
     
    9292        memset(phdr.zeroes, 0, 3);
    9393        phdr.next = IP_PROTO_ICMPV6;
    94        
     94
    9595        uint16_t cs_phdr =
    9696            inet_checksum_calc(INET_CHECKSUM_INIT, &phdr,
    9797            sizeof(icmpv6_phdr_t));
    98        
     98
    9999        uint16_t cs_all = inet_checksum_calc(cs_phdr, reply, size);
    100        
     100
    101101        reply->checksum = host2uint16_t_be(cs_all);
    102        
     102
    103103        errno_t rc = inet_route_packet(&rdgram, IP_PROTO_ICMPV6,
    104104            INET6_HOP_LIMIT_MAX, 0);
    105        
     105
    106106        free(reply);
    107        
     107
    108108        return rc;
    109109}
     
    112112{
    113113        log_msg(LOG_DEFAULT, LVL_DEBUG, "icmpv6_recv_echo_reply()");
    114        
     114
    115115        if (dgram->size < sizeof(icmpv6_message_t))
    116116                return EINVAL;
    117        
     117
    118118        inetping_sdu_t sdu;
    119        
     119
    120120        sdu.src = dgram->src;
    121121        sdu.dest = dgram->dest;
    122        
     122
    123123        icmpv6_message_t *reply = (icmpv6_message_t *) dgram->data;
    124        
     124
    125125        sdu.seq_no = uint16_t_be2host(reply->un.echo.seq_no);
    126126        sdu.data = reply + sizeof(icmpv6_message_t);
    127127        sdu.size = dgram->size - sizeof(icmpv6_message_t);
    128        
     128
    129129        uint16_t ident = uint16_t_be2host(reply->un.echo.ident);
    130        
     130
    131131        return inetping_recv(ident, &sdu);
    132132}
     
    135135{
    136136        log_msg(LOG_DEFAULT, LVL_DEBUG, "icmpv6_recv()");
    137        
     137
    138138        if (dgram->size < 1)
    139139                return EINVAL;
    140        
     140
    141141        uint8_t type = *(uint8_t *) dgram->data;
    142        
     142
    143143        switch (type) {
    144144        case ICMPV6_ECHO_REQUEST:
     
    153153                break;
    154154        }
    155        
     155
    156156        return EINVAL;
    157157}
     
    163163        if (rdata == NULL)
    164164                return ENOMEM;
    165        
     165
    166166        icmpv6_message_t *request = (icmpv6_message_t *) rdata;
    167        
     167
    168168        request->type = ICMPV6_ECHO_REQUEST;
    169169        request->code = 0;
     
    171171        request->un.echo.ident = host2uint16_t_be(ident);
    172172        request->un.echo.seq_no = host2uint16_t_be(sdu->seq_no);
    173        
     173
    174174        memcpy(rdata + sizeof(icmpv6_message_t), sdu->data, sdu->size);
    175        
     175
    176176        inet_dgram_t dgram;
    177        
     177
    178178        dgram.src = sdu->src;
    179179        dgram.dest = sdu->dest;
     
    182182        dgram.data = rdata;
    183183        dgram.size = rsize;
    184        
     184
    185185        icmpv6_phdr_t phdr;
    186        
     186
    187187        assert(sdu->src.version == ip_v6);
    188188        assert(sdu->dest.version == ip_v6);
    189        
     189
    190190        host2addr128_t_be(sdu->src.addr6, phdr.src_addr);
    191191        host2addr128_t_be(sdu->dest.addr6, phdr.dest_addr);
     
    193193        memset(phdr.zeroes, 0, 3);
    194194        phdr.next = IP_PROTO_ICMPV6;
    195        
     195
    196196        uint16_t cs_phdr =
    197197            inet_checksum_calc(INET_CHECKSUM_INIT, &phdr,
    198198            sizeof(icmpv6_phdr_t));
    199        
     199
    200200        uint16_t cs_all = inet_checksum_calc(cs_phdr, rdata, rsize);
    201        
     201
    202202        request->checksum = host2uint16_t_be(cs_all);
    203        
     203
    204204        errno_t rc = inet_route_packet(&dgram, IP_PROTO_ICMPV6,
    205205            INET6_HOP_LIMIT_MAX, 0);
    206        
     206
    207207        free(rdata);
    208        
     208
    209209        return rc;
    210210}
Note: See TracChangeset for help on using the changeset viewer.