VirtualBox

Changeset 49607 in vbox


Ignore:
Timestamp:
Nov 21, 2013 3:24:27 PM (11 years ago)
Author:
vboxsync
Message:

Use ICMP filters if present.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/pxping.c

    r49593 r49607  
    232232    g_pxping.sock4 = sock4;
    233233    if (g_pxping.sock4 != INVALID_SOCKET) {
     234#ifdef ICMP_FILTER
     235        struct icmp_filter flt = { ~(uint32_t)(1U << ICMP_ECHOREPLY) };
     236
     237        status = setsockopt(icmpsock4, IPPROTO_ICMP, ICMP_FILTER,
     238                            &flt, sizeof(flt));
     239        if (status < 0) {
     240            perror("ICMP_FILTER");
     241        }
     242#endif  /* ICMP_FILTER */
     243
    234244        g_pxping.ttl = -1;
    235245        g_pxping.tos = 0;
     
    245255    g_pxping.sock6 = sock6;
    246256    if (g_pxping.sock6 != INVALID_SOCKET) {
     257#ifdef ICMP6_FILTER
     258        struct icmp6_filter flt;
     259        ICMP6_FILTER_SETBLOCKALL(&flt);
     260
     261        ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &flt);
     262
     263        ICMP6_FILTER_SETPASS(ICMP6_DST_UNREACH, &flt);
     264        ICMP6_FILTER_SETPASS(ICMP6_PACKET_TOO_BIG, &flt);
     265        ICMP6_FILTER_SETPASS(ICMP6_TIME_EXCEEDED, &flt);
     266        ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &flt);
     267
     268        status = setsockopt(icmpsock6, IPPROTO_ICMPV6, ICMP6_FILTER,
     269                            &flt, sizeof(flt));
     270        if (status < 0) {
     271            perror("ICMP6_FILTER");
     272        }
     273#endif  /* ICMP6_FILTER */
     274
    247275        g_pxping.hopl = -1;
    248276
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette