Skip to content

Commit

Permalink
AIX support
Browse files Browse the repository at this point in the history
  • Loading branch information
aklyachkin authored and jtroy committed Sep 6, 2024
1 parent 8187f9b commit 3b197a7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions route_info_aix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package sockaddr

import (
"errors"
"os/exec"
)

var cmds map[string][]string = map[string][]string{
"route": {"/usr/sbin/route", "-n", "get", "default"},
}

type routeInfo struct {
cmds map[string][]string
}

// NewRouteInfo returns a BSD-specific implementation of the RouteInfo
// interface.
func NewRouteInfo() (routeInfo, error) {
return routeInfo{
cmds: cmds,
}, nil
}

// GetDefaultInterfaceName returns the interface name attached to the default
// route on the default interface.
func (ri routeInfo) GetDefaultInterfaceName() (string, error) {
out, err := exec.Command(cmds["route"][0], cmds["route"][1:]...).Output()
if err != nil {
return "", err
}

var ifName string
if ifName, err = parseDefaultIfNameFromRoute(string(out)); err != nil {
return "", errors.New("No default interface found")
}
return ifName, nil
}

0 comments on commit 3b197a7

Please sign in to comment.