| 60 | namespace link { |
| 61 | |
| 62 | Result<string> eth0() |
| 63 | { |
| 64 | Try<vector<route::Rule>> mainRoutingTable = route::table(); |
| 65 | if (mainRoutingTable.isError()) { |
| 66 | return Error( |
| 67 | "Failed to retrieve the main routing table on the host: " + |
| 68 | mainRoutingTable.error()); |
| 69 | } |
| 70 | |
| 71 | foreach (const route::Rule& rule, mainRoutingTable.get()) { |
| 72 | if (rule.destination.isNone()) { |
| 73 | // Check if the public interface exists. |
| 74 | Try<bool> exists = link::exists(rule.link); |
| 75 | if (exists.isError()) { |
| 76 | return Error( |
| 77 | "Failed to check if " + rule.link + " exists: " + exists.error()); |
| 78 | } else if (!exists.get()) { |
| 79 | return Error( |
| 80 | rule.link + " is in the routing table but not in the system"); |
| 81 | } |
| 82 | |
| 83 | return rule.link; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return None(); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | Result<string> lo() |