forked from rosa/hakurei
internal/netlink: make full response available
The previous API makes it impossible to retrieve remaining messages in the current iteration. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -18,23 +18,23 @@ func DialRoute() (*RouteConn, error) {
|
||||
}
|
||||
|
||||
// rtnlConsume consumes a message from rtnetlink.
|
||||
func rtnlConsume(msg *syscall.NetlinkMessage) error {
|
||||
switch msg.Header.Type {
|
||||
case syscall.NLMSG_DONE:
|
||||
return Complete{}
|
||||
func rtnlConsume(resp []syscall.NetlinkMessage) error {
|
||||
for i := range resp {
|
||||
switch resp[i].Header.Type {
|
||||
case syscall.NLMSG_DONE:
|
||||
return Complete{}
|
||||
|
||||
case syscall.NLMSG_ERROR:
|
||||
if e := As[syscall.NlMsgerr](msg.Data); e != nil {
|
||||
if e.Error == 0 {
|
||||
return Complete{}
|
||||
case syscall.NLMSG_ERROR:
|
||||
if e := As[syscall.NlMsgerr](resp[i].Data); e != nil {
|
||||
if e.Error == 0 {
|
||||
return Complete{}
|
||||
}
|
||||
return syscall.Errno(-e.Error)
|
||||
}
|
||||
return syscall.Errno(-e.Error)
|
||||
return syscall.EBADE
|
||||
}
|
||||
return syscall.EBADE
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InAddr is equivalent to struct in_addr.
|
||||
|
||||
Reference in New Issue
Block a user