{"action":"created","comment":{"url":"https://api.github.com/repos/m-labs/smoltcp/pulls/comments/191496271","pull_request_review_id":124078137,"id":191496271,"diff_hunk":"@@ -0,0 +1,231 @@\n+use managed::ManagedMap;\n+use time::Instant;\n+use core::ops::Bound;\n+\n+use {Error, Result};\n+use wire::{IpCidr, IpAddress};\n+#[cfg(feature = \"proto-ipv4\")]\n+use wire::{Ipv4Address, Ipv4Cidr};\n+#[cfg(feature = \"proto-ipv6\")]\n+use wire::{Ipv6Address, Ipv6Cidr};\n+\n+/// A prefix of addresses that should be routed via a router\n+#[derive(Debug, Clone, Copy)]\n+pub struct Route {\n+    pub via_router: IpAddress,\n+    /// `None` means \"forever\".\n+    pub preferred_until: Option<Instant>,\n+    /// `None` means \"forever\".\n+    pub expires_at: Option<Instant>,\n+}\n+\n+impl Route {\n+    /// Returns a route to 0.0.0.0/0 via the `gateway`, with no expiry.\n+    #[cfg(feature = \"proto-ipv4\")]\n+    pub fn new_ipv4_gateway(gateway: Ipv4Address) -> Route {\n+        Route {\n+            via_router: gateway.into(),\n+            preferred_until: None,\n+            expires_at: None,\n+        }\n+    }\n+\n+    /// Returns a route to ::/0 via the `gateway`, with no expiry.\n+    #[cfg(feature = \"proto-ipv6\")]\n+    pub fn new_ipv6_gateway(gateway: Ipv6Address) -> Route {\n+        Route {\n+            via_router: gateway.into(),\n+            preferred_until: None,\n+            expires_at: None,\n+        }\n+    }\n+}\n+\n+/// A routing table.\n+///\n+/// # Examples\n+///\n+/// On systems with heap, this table can be created with:\n+///\n+/// ```rust\n+/// use std::collections::BTreeMap;\n+/// use smoltcp::iface::Routes;\n+/// let mut routes = Routes::new(BTreeMap::new());\n+/// ```\n+///\n+/// On systems without heap, use:\n+///\n+/// ```rust\n+/// use smoltcp::iface::Routes;\n+/// let mut routes_storage = [];\n+/// let mut routes = Routes::new(&mut routes_storage[..]);\n+/// ```\n+#[derive(Debug)]\n+pub struct Routes<'a> {\n+    storage: ManagedMap<'a, IpCidr, Route>,\n+}\n+\n+impl<'a> Routes<'a> {\n+    /// Creates a routing tables. The backing storage is **not** cleared\n+    /// upon creation.\n+    pub fn new<T>(storage: T) -> Routes<'a>\n+            where T: Into<ManagedMap<'a, IpCidr, Route>> {\n+        let storage = storage.into();\n+        Routes { storage }\n+    }\n+\n+    /// Update the routes of this node.\n+    pub fn update_routes<F: FnOnce(&mut ManagedMap<'a, IpCidr, Route>)>(&mut self, f: F) {\n+        f(&mut self.storage);\n+    }\n+\n+    /// Add a default ipv4 gateway (ie. \"ip route add 0.0.0.0/0 via `gateway`\").\n+    ///\n+    /// On success, returns the previous default gateway, if any.\n+    #[cfg(feature = \"proto-ipv4\")]\n+    pub fn add_default_ipv4_gateway(&mut self, gateway: Ipv4Address) -> Result<Option<Route>> {","path":"src/iface/route.rs","position":86,"original_position":86,"commit_id":"ced197fc1d299ea5f13ecf28802c3ee9507aaa97","original_commit_id":"ced197fc1d299ea5f13ecf28802c3ee9507aaa97","user":{"login":"whitequark","id":54771,"avatar_url":"https://avatars1.githubusercontent.com/u/54771?v=4","gravatar_id":"","url":"https://api.github.com/users/whitequark","html_url":"https://github.com/whitequark","followers_url":"https://api.github.com/users/whitequark/followers","following_url":"https://api.github.com/users/whitequark/following{/other_user}","gists_url":"https://api.github.com/users/whitequark/gists{/gist_id}","starred_url":"https://api.github.com/users/whitequark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitequark/subscriptions","organizations_url":"https://api.github.com/users/whitequark/orgs","repos_url":"https://api.github.com/users/whitequark/repos","events_url":"https://api.github.com/users/whitequark/events{/privacy}","received_events_url":"https://api.github.com/users/whitequark/received_events","type":"User","site_admin":false},"body":"This adds a default IPv4 *route* (i.e. a single route is added), not *gateway* (which would imply that other routes might use the same gateway if none is specified). Also docstring and IPv6 needs to be changed.","created_at":"2018-05-29T16:48:21Z","updated_at":"2018-05-29T16:49:39Z","html_url":"https://github.com/m-labs/smoltcp/pull/219#discussion_r191496271","pull_request_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/219","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/comments/191496271"},"html":{"href":"https://github.com/m-labs/smoltcp/pull/219#discussion_r191496271"},"pull_request":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/219"}}},"pull_request":{"url":"https://api.github.com/repos/m-labs/smoltcp/pulls/219","id":190725070,"html_url":"https://github.com/m-labs/smoltcp/pull/219","diff_url":"https://github.com/m-labs/smoltcp/pull/219.diff","patch_url":"https://github.com/m-labs/smoltcp/pull/219.patch","issue_url":"https://api.github.com/repos/m-labs/smoltcp/issues/219","number":219,"state":"open","locked":false,"title":" Add support for arbitrarily many routes instead of only gateways. ","user":{"login":"ProgVal","id":406946,"avatar_url":"https://avatars3.githubusercontent.com/u/406946?v=4","gravatar_id":"","url":"https://api.github.com/users/ProgVal","html_url":"https://github.com/ProgVal","followers_url":"https://api.github.com/users/ProgVal/followers","following_url":"https://api.github.com/users/ProgVal/following{/other_user}","gists_url":"https://api.github.com/users/ProgVal/gists{/gist_id}","starred_url":"https://api.github.com/users/ProgVal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProgVal/subscriptions","organizations_url":"https://api.github.com/users/ProgVal/orgs","repos_url":"https://api.github.com/users/ProgVal/repos","events_url":"https://api.github.com/users/ProgVal/events{/privacy}","received_events_url":"https://api.github.com/users/ProgVal/received_events","type":"User","site_admin":false},"body":"Closes #209.\r\n\r\nNote: As this PR uses the newly introduced `managed::ManagedMap::range` method, I changed Cargo.toml to use `managed`'s git repo instead of the released version.","created_at":"2018-05-26T04:30:32Z","updated_at":"2018-05-29T16:49:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5aa95ce28b8123addfc88e371363096c18670c67","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/219/commits","review_comments_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/219/comments","review_comment_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m-labs/smoltcp/issues/219/comments","statuses_url":"https://api.github.com/repos/m-labs/smoltcp/statuses/ced197fc1d299ea5f13ecf28802c3ee9507aaa97","head":{"label":"ProgVal:managedmap-routes","ref":"managedmap-routes","sha":"ced197fc1d299ea5f13ecf28802c3ee9507aaa97","user":{"login":"ProgVal","id":406946,"avatar_url":"https://avatars3.githubusercontent.com/u/406946?v=4","gravatar_id":"","url":"https://api.github.com/users/ProgVal","html_url":"https://github.com/ProgVal","followers_url":"https://api.github.com/users/ProgVal/followers","following_url":"https://api.github.com/users/ProgVal/following{/other_user}","gists_url":"https://api.github.com/users/ProgVal/gists{/gist_id}","starred_url":"https://api.github.com/users/ProgVal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProgVal/subscriptions","organizations_url":"https://api.github.com/users/ProgVal/orgs","repos_url":"https://api.github.com/users/ProgVal/repos","events_url":"https://api.github.com/users/ProgVal/events{/privacy}","received_events_url":"https://api.github.com/users/ProgVal/received_events","type":"User","site_admin":false},"repo":{"id":132746057,"name":"smoltcp","full_name":"ProgVal/smoltcp","owner":{"login":"ProgVal","id":406946,"avatar_url":"https://avatars3.githubusercontent.com/u/406946?v=4","gravatar_id":"","url":"https://api.github.com/users/ProgVal","html_url":"https://github.com/ProgVal","followers_url":"https://api.github.com/users/ProgVal/followers","following_url":"https://api.github.com/users/ProgVal/following{/other_user}","gists_url":"https://api.github.com/users/ProgVal/gists{/gist_id}","starred_url":"https://api.github.com/users/ProgVal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProgVal/subscriptions","organizations_url":"https://api.github.com/users/ProgVal/orgs","repos_url":"https://api.github.com/users/ProgVal/repos","events_url":"https://api.github.com/users/ProgVal/events{/privacy}","received_events_url":"https://api.github.com/users/ProgVal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ProgVal/smoltcp","description":"a smol tcp/ip stack","fork":true,"url":"https://api.github.com/repos/ProgVal/smoltcp","forks_url":"https://api.github.com/repos/ProgVal/smoltcp/forks","keys_url":"https://api.github.com/repos/ProgVal/smoltcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProgVal/smoltcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProgVal/smoltcp/teams","hooks_url":"https://api.github.com/repos/ProgVal/smoltcp/hooks","issue_events_url":"https://api.github.com/repos/ProgVal/smoltcp/issues/events{/number}","events_url":"https://api.github.com/repos/ProgVal/smoltcp/events","assignees_url":"https://api.github.com/repos/ProgVal/smoltcp/assignees{/user}","branches_url":"https://api.github.com/repos/ProgVal/smoltcp/branches{/branch}","tags_url":"https://api.github.com/repos/ProgVal/smoltcp/tags","blobs_url":"https://api.github.com/repos/ProgVal/smoltcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProgVal/smoltcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProgVal/smoltcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProgVal/smoltcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProgVal/smoltcp/statuses/{sha}","languages_url":"https://api.github.com/repos/ProgVal/smoltcp/languages","stargazers_url":"https://api.github.com/repos/ProgVal/smoltcp/stargazers","contributors_url":"https://api.github.com/repos/ProgVal/smoltcp/contributors","subscribers_url":"https://api.github.com/repos/ProgVal/smoltcp/subscribers","subscription_url":"https://api.github.com/repos/ProgVal/smoltcp/subscription","commits_url":"https://api.github.com/repos/ProgVal/smoltcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProgVal/smoltcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProgVal/smoltcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProgVal/smoltcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProgVal/smoltcp/contents/{+path}","compare_url":"https://api.github.com/repos/ProgVal/smoltcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProgVal/smoltcp/merges","archive_url":"https://api.github.com/repos/ProgVal/smoltcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProgVal/smoltcp/downloads","issues_url":"https://api.github.com/repos/ProgVal/smoltcp/issues{/number}","pulls_url":"https://api.github.com/repos/ProgVal/smoltcp/pulls{/number}","milestones_url":"https://api.github.com/repos/ProgVal/smoltcp/milestones{/number}","notifications_url":"https://api.github.com/repos/ProgVal/smoltcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProgVal/smoltcp/labels{/name}","releases_url":"https://api.github.com/repos/ProgVal/smoltcp/releases{/id}","deployments_url":"https://api.github.com/repos/ProgVal/smoltcp/deployments","created_at":"2018-05-09T11:20:58Z","updated_at":"2018-05-14T17:25:13Z","pushed_at":"2018-05-27T07:01:08Z","git_url":"git://github.com/ProgVal/smoltcp.git","ssh_url":"git@github.com:ProgVal/smoltcp.git","clone_url":"https://github.com/ProgVal/smoltcp.git","svn_url":"https://github.com/ProgVal/smoltcp","homepage":null,"size":1176,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"m-labs:master","ref":"master","sha":"908ef8d0204b4b34644bdde2c930ba028d23f3a2","user":{"login":"m-labs","id":116047,"avatar_url":"https://avatars3.githubusercontent.com/u/116047?v=4","gravatar_id":"","url":"https://api.github.com/users/m-labs","html_url":"https://github.com/m-labs","followers_url":"https://api.github.com/users/m-labs/followers","following_url":"https://api.github.com/users/m-labs/following{/other_user}","gists_url":"https://api.github.com/users/m-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/m-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-labs/subscriptions","organizations_url":"https://api.github.com/users/m-labs/orgs","repos_url":"https://api.github.com/users/m-labs/repos","events_url":"https://api.github.com/users/m-labs/events{/privacy}","received_events_url":"https://api.github.com/users/m-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":75406961,"name":"smoltcp","full_name":"m-labs/smoltcp","owner":{"login":"m-labs","id":116047,"avatar_url":"https://avatars3.githubusercontent.com/u/116047?v=4","gravatar_id":"","url":"https://api.github.com/users/m-labs","html_url":"https://github.com/m-labs","followers_url":"https://api.github.com/users/m-labs/followers","following_url":"https://api.github.com/users/m-labs/following{/other_user}","gists_url":"https://api.github.com/users/m-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/m-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-labs/subscriptions","organizations_url":"https://api.github.com/users/m-labs/orgs","repos_url":"https://api.github.com/users/m-labs/repos","events_url":"https://api.github.com/users/m-labs/events{/privacy}","received_events_url":"https://api.github.com/users/m-labs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m-labs/smoltcp","description":"a smol tcp/ip stack","fork":false,"url":"https://api.github.com/repos/m-labs/smoltcp","forks_url":"https://api.github.com/repos/m-labs/smoltcp/forks","keys_url":"https://api.github.com/repos/m-labs/smoltcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m-labs/smoltcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m-labs/smoltcp/teams","hooks_url":"https://api.github.com/repos/m-labs/smoltcp/hooks","issue_events_url":"https://api.github.com/repos/m-labs/smoltcp/issues/events{/number}","events_url":"https://api.github.com/repos/m-labs/smoltcp/events","assignees_url":"https://api.github.com/repos/m-labs/smoltcp/assignees{/user}","branches_url":"https://api.github.com/repos/m-labs/smoltcp/branches{/branch}","tags_url":"https://api.github.com/repos/m-labs/smoltcp/tags","blobs_url":"https://api.github.com/repos/m-labs/smoltcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m-labs/smoltcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m-labs/smoltcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/m-labs/smoltcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m-labs/smoltcp/statuses/{sha}","languages_url":"https://api.github.com/repos/m-labs/smoltcp/languages","stargazers_url":"https://api.github.com/repos/m-labs/smoltcp/stargazers","contributors_url":"https://api.github.com/repos/m-labs/smoltcp/contributors","subscribers_url":"https://api.github.com/repos/m-labs/smoltcp/subscribers","subscription_url":"https://api.github.com/repos/m-labs/smoltcp/subscription","commits_url":"https://api.github.com/repos/m-labs/smoltcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/m-labs/smoltcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/m-labs/smoltcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/m-labs/smoltcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/m-labs/smoltcp/contents/{+path}","compare_url":"https://api.github.com/repos/m-labs/smoltcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m-labs/smoltcp/merges","archive_url":"https://api.github.com/repos/m-labs/smoltcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m-labs/smoltcp/downloads","issues_url":"https://api.github.com/repos/m-labs/smoltcp/issues{/number}","pulls_url":"https://api.github.com/repos/m-labs/smoltcp/pulls{/number}","milestones_url":"https://api.github.com/repos/m-labs/smoltcp/milestones{/number}","notifications_url":"https://api.github.com/repos/m-labs/smoltcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m-labs/smoltcp/labels{/name}","releases_url":"https://api.github.com/repos/m-labs/smoltcp/releases{/id}","deployments_url":"https://api.github.com/repos/m-labs/smoltcp/deployments","created_at":"2016-12-02T15:21:02Z","updated_at":"2018-05-29T06:51:42Z","pushed_at":"2018-05-28T01:50:08Z","git_url":"git://github.com/m-labs/smoltcp.git","ssh_url":"git@github.com:m-labs/smoltcp.git","clone_url":"https://github.com/m-labs/smoltcp.git","svn_url":"https://github.com/m-labs/smoltcp","homepage":null,"size":1180,"stargazers_count":479,"watchers_count":479,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":38,"mirror_url":null,"archived":false,"open_issues_count":33,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":38,"open_issues":33,"watchers":479,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/219"},"html":{"href":"https://github.com/m-labs/smoltcp/pull/219"},"issue":{"href":"https://api.github.com/repos/m-labs/smoltcp/issues/219"},"comments":{"href":"https://api.github.com/repos/m-labs/smoltcp/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/m-labs/smoltcp/statuses/ced197fc1d299ea5f13ecf28802c3ee9507aaa97"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"whitequark"}}