Check if generated Mac Address matchs the NIC of all Interfaces except lo #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
check_mac_conflictFunction:0if a conflict is found, and1if no conflict is found.macrandFunction:oui_fileand the last three octets randomly.while trueloop to keep generating new MAC addresses untilcheck_mac_conflictreturns1(indicating no conflict).phmacrandFunction:macrandfunction but for phone interfaces, it generates a new MAC address with the first three octets from thephoui_fileand the last three octets randomly.while trueloop to keep generating new MAC addresses untilcheck_mac_conflictreturns1(indicating no conflict).This ensures that the script keeps generating MAC addresses until it finds one that does not conflict with the last three octets of any existing NICs, effectively "blacklisting" existing NICs' MAC address segments to prevent duplication.
This is key when generating random MAC Adresses as to not leak the real NIC of the permaddress as this what other projects do. NetworkManager does not currently do this but wipri doesn't rely on NetworkManager.