|
@@ -53,6 +53,19 @@ type IpSubnetMapper struct {
|
|
|
Mask int
|
|
|
}
|
|
|
|
|
|
+type PromptEntry struct {
|
|
|
+ HostAddress string
|
|
|
+ NetworkAddress string
|
|
|
+ Cidr string
|
|
|
+ SubnetMask string
|
|
|
+ InterfaceName string
|
|
|
+ MacAddress string
|
|
|
+}
|
|
|
+
|
|
|
+type TuiSelectionFeed struct {
|
|
|
+ Choice []PromptEntry
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
Get the next IPv4 address of the address specified in the 'addr' argument,
|
|
|
|
|
@@ -134,33 +147,12 @@ func GetNetworkAddresses(addr string) (*IpSubnetMapper, error) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-type PromptEntry struct {
|
|
|
- HostAddress string
|
|
|
- NetworkAddress string
|
|
|
- Cidr string
|
|
|
- SubnetMask string
|
|
|
- InterfaceName string
|
|
|
- MacAddress string
|
|
|
-}
|
|
|
-
|
|
|
-type TuiSelectionFeed struct {
|
|
|
- Choice []PromptEntry
|
|
|
-}
|
|
|
-
|
|
|
-func matchAddressToMac(ip string, intfs []net.Interface) (*PromptEntry, error) {
|
|
|
- for i := range intfs {
|
|
|
- intfsAddr, err := intfs[i].Addrs()
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- for x := range intfsAddr {
|
|
|
- fmt.Println(intfsAddr[x].String())
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return nil, nil
|
|
|
-}
|
|
|
+/*
|
|
|
+Turns a set of network mask bits into a valid IPv4 representation
|
|
|
|
|
|
+ :param ones: number of 1's in the netmask, i.e. 16 == 11111111 11111111 00000000 00000000
|
|
|
+ :param bits: the number of bits that the mask consists of (need to keep this param for ipv6 support later)
|
|
|
+*/
|
|
|
func bitsToMask(ones int, bits int) string {
|
|
|
var bitmask []int
|
|
|
|
|
@@ -207,6 +199,7 @@ func powerInt(x int, y int) int {
|
|
|
return int(math.Pow(float64(x), float64(y)))
|
|
|
}
|
|
|
|
|
|
+// Needs cleanup, but this function populatest a data structure that will be used during TUI program startup
|
|
|
func RetrieveLocalAddresses() (TuiSelectionFeed, error) {
|
|
|
var tuidata TuiSelectionFeed
|
|
|
intf, err := net.Interfaces()
|
|
@@ -237,6 +230,7 @@ func RetrieveLocalAddresses() (TuiSelectionFeed, error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
tuidata.Choice = append(tuidata.Choice, PromptEntry{
|
|
|
HostAddress: ip.String(),
|
|
|
NetworkAddress: ip.Mask(net.Mask).String(),
|