public static int getHostSegmentIndex ( int networkPrefixLength , int bytesPerSegment , int bitsPerSegment ) { if ( bytesPerSegment > 1 ) { if ( bytesPerSegment == 2 ) { return networkPrefixLength >> 4 ; } return networkPrefixLength / bitsPerSegment ; } return networkPrefixLength >> 3 ; }
Returns the index of the segment containing the first byte outside the network prefix . When networkPrefixLength is null or it matches or exceeds the bit length returns the segment count .