title: ip address matching with subnetmask in java
body: <p>I have the following scenario: Suppose I receive a packet which has an Ipv4 address. I need to execute certain methods based upon the matching of this IP address with a certain subnetmask. I would like to make an if instruction based on IP and mask.</p>
  
  <p>Example: suppose the condition to pass is that the destination IP address of a packet needs to be <code>150.0.0.0/8</code>. If I get a packet with an IP address <code>150.1.1.1</code> then the packet is processed, whereas if I get a packet with IP <code>151.2.2.2</code> then the packet would simply be ignored.</p>
  
  <p>How do I set such a rule?
  Thank you!</p>