• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lduchosal / ipnetwork / 960

15 May 2026 07:18AM UTC coverage: 0.0% (-94.1%) from 94.053%
960

Pull #411

appveyor

web-flow
Merge ef6b054ce into 4cec191ae
Pull Request #411: Bump MSTest.TestFramework from 4.2.2 to 4.2.3

0 of 2438 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/System.Net.IPNetwork/IPNetwork2WildcardMask.cs
1
// <copyright file="IPNetwork2WildcardMask.cs" company="IPNetwork">
2
// Copyright (c) IPNetwork. All rights reserved.
3
// </copyright>
4

5
namespace System.Net;
6

7
using System.Numerics;
8
using System.Net.Sockets;
9

10
/// <summary>
11
/// WildcardNetmask.
12
/// </summary>
13
public sealed partial class IPNetwork2
14
{
15
    /// <summary>
16
    /// Gets netmask Inverse
17
    /// https://en.wikipedia.org/wiki/Wildcard_mask
18
    ///
19
    /// A wildcard mask is a mask of bits that indicates which parts of an IP address are available for examination.
20
    /// In the Cisco IOS,[1] they are used in several places, for example:
21
    ///    To indicate the size of a network or subnet for some routing protocols, such as OSPF.
22
    ///    To indicate what IP addresses should be permitted or denied in access control lists(ACLs).
23
    ///
24
    /// A wildcard mask can be thought of as an inverted subnet mask.For example,
25
    /// a subnet mask of 255.255.255.0 (binary equivalent = 11111111.11111111.11111111.00000000)
26
    /// inverts to a wildcard mask of 0.0.0.255 (binary equivalent = 00000000.00000000.00000000.11111111).
27
    ///
28
    /// A wild card mask is a matching rule.[2] The rule for a wildcard mask is:
29
    ///     0 means that the equivalent bit must match
30
    ///     1 means that the equivalent bit does not matter
31
    ///
32
    /// Any wildcard bit-pattern can be masked for examination.For example, a wildcard mask of 0.0.0.254
33
    /// (binary equivalent = 00000000.00000000.00000000.11111110) applied to IP address 10.10.10.2
34
    /// (00001010.00001010.00001010.00000010) will match even-numbered IP addresses 10.10.10.0, 10.10.10.2,
35
    /// 10.10.10.4, 10.10.10.6 etc.
36
    ///
37
    /// Same mask applied to 10.10.10.1 (00001010.00001010.00001010.00000001) will match
38
    /// odd-numbered IP addresses 10.10.10.1, 10.10.10.3, 10.10.10.5 etc.
39
    ///
40
    /// A network and wildcard mask combination of 1.1.1.1 0.0.0.0 would match an interface configured
41
    /// exactly with 1.1.1.1 only, and nothing else.
42
    ///
43
    /// Wildcard masks are used in situations where subnet masks may not apply.For example,
44
    /// when two affected hosts fall in different subnets, the use of a wildcard mask will
45
    /// group them together.
46
    ///
47
    /// List of wildcard masks
48
    /// Slash Netmask Wildcard mask
49
    /// /32   255.255.255.255    0.0.0.0
50
    /// /31   255.255.255.254    0.0.0.1
51
    /// /30   255.255.255.252    0.0.0.3
52
    /// /29   255.255.255.248    0.0.0.7
53
    /// /28   255.255.255.240    0.0.0.15
54
    /// /27   255.255.255.224    0.0.0.31
55
    /// /26   255.255.255.192    0.0.0.63
56
    /// /25   255.255.255.128    0.0.0.127
57
    /// /24   255.255.255.0      0.0.0.255
58
    /// /23   255.255.254.0      0.0.1.255
59
    /// /22   255.255.252.0      0.0.3.255
60
    /// /21   255.255.248.0      0.0.7.255
61
    /// /20   255.255.240.0      0.0.15.255
62
    /// /19   255.255.224.0      0.0.31.255
63
    /// /18   255.255.192.0      0.0.63.255
64
    /// /17   255.255.128.0      0.0.127.255
65
    /// /16   255.255.0.0        0.0.255.255
66
    /// /15   255.254.0.0        0.1.255.255
67
    /// /14   255.252.0.0        0.3.255.255
68
    /// /13   255.248.0.0        0.7.255.255
69
    /// /12   255.240.0.0        0.15.255.255
70
    /// /11   255.224.0.0        0.31.255.255
71
    /// /10   255.192.0.0        0.63.255.255
72
    /// /9    255.128.0.0        0.127.255.255
73
    /// /8    255.0.0.0          0.255.255.255
74
    /// /7    254.0.0.0          1.255.255.255
75
    /// /6    252.0.0.0          3.255.255.255
76
    /// /5    248.0.0.0          7.255.255.255
77
    /// /4    240.0.0.0          15.255.255.255
78
    /// /3    224.0.0.0          31.255.255.255
79
    /// /2    192.0.0.0          63.255.255.255
80
    /// /1    128.0.0.0          127.255.255.255
81
    /// /0    0.0.0.0            255.255.255.255.
82
    ///
83
    /// </summary>
84
    public IPAddress WildcardMask
85
    {
86
        get
87
        {
×
88
            byte acidr = this.family == AddressFamily.InterNetwork ? (byte)32 : (byte)128;
×
89
            BigInteger netmask = ToUint(acidr, this.family);
×
90
            BigInteger wildcardmask = netmask - this.InternalNetmask;
×
91

92
            return ToIPAddress(wildcardmask, this.family);
×
93
        }
×
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc