Skip to content

Commit

Permalink
Bugfix/fix win netmask (#46)
Browse files Browse the repository at this point in the history
* Fix netmask calc

* Fix netmask calc ipv6

---------

Co-authored-by: Yifan <huangyf@lglab.ac.cn>
  • Loading branch information
QuantumKitty and Yifan authored Jan 3, 2025
1 parent 9892ca4 commit e0145d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod getifaddrs_windows {
let x_byte = ipv4_addr.octets()[n];
let y_byte = a.octets()[n];
for m in 0..8 {
if (n * 8) + m > prefix.PrefixLength as usize {
if (n * 8) + m >= prefix.PrefixLength as usize {
break;
}
let bit = 1 << (7 - m);
Expand Down Expand Up @@ -361,7 +361,7 @@ mod getifaddrs_windows {
let x_word = ipv6_addr.segments()[n];
let y_word = a.segments()[n];
for m in 0..16 {
if (n * 16) + m > prefix.PrefixLength as usize {
if (n * 16) + m >= prefix.PrefixLength as usize {
break;
}
let bit = 1 << (15 - m);
Expand Down

0 comments on commit e0145d2

Please sign in to comment.