SetNICCoordinator sets a coordinator device.
(id tcpip.NICID, mid tcpip.NICID)
| 1097 | |
| 1098 | // SetNICCoordinator sets a coordinator device. |
| 1099 | func (s *Stack) SetNICCoordinator(id tcpip.NICID, mid tcpip.NICID) tcpip.Error { |
| 1100 | s.mu.Lock() |
| 1101 | defer s.mu.Unlock() |
| 1102 | |
| 1103 | nic, ok := s.nics[id] |
| 1104 | if !ok { |
| 1105 | return &tcpip.ErrUnknownNICID{} |
| 1106 | } |
| 1107 | // Setting a coordinator for a coordinator NIC is not allowed. |
| 1108 | if _, ok := nic.NetworkLinkEndpoint.(CoordinatorNIC); ok { |
| 1109 | return &tcpip.ErrNoSuchFile{} |
| 1110 | } |
| 1111 | m, ok := s.nics[mid] |
| 1112 | if !ok { |
| 1113 | return &tcpip.ErrUnknownNICID{} |
| 1114 | } |
| 1115 | b, ok := m.NetworkLinkEndpoint.(CoordinatorNIC) |
| 1116 | if !ok { |
| 1117 | return &tcpip.ErrNotSupported{} |
| 1118 | } |
| 1119 | if err := b.AddNIC(nic); err != nil { |
| 1120 | return err |
| 1121 | } |
| 1122 | nic.Primary = m |
| 1123 | return nil |
| 1124 | } |
| 1125 | |
| 1126 | // SetNICAddress sets the hardware address which is identified by the nic ID. |
| 1127 | func (s *Stack) SetNICAddress(id tcpip.NICID, addr tcpip.LinkAddress) tcpip.Error { |