This should be done via the IpAddress relationships.  IpAddress.network should return this automatically.