{"action":"created","comment":{"url":"https://api.github.com/repos/m-labs/smoltcp/pulls/comments/172551115","pull_request_review_id":101586172,"id":172551115,"diff_hunk":"@@ -0,0 +1,451 @@\n+use core::fmt;\n+use byteorder::{ByteOrder, NetworkEndian};\n+\n+use {Error, Result};\n+use super::ip::checksum;\n+use time::Duration;\n+\n+use wire::Ipv4Address;\n+\n+enum_with_unknown! {\n+    /// Internet Group Management Protocol v2 message version/type.\n+    pub doc enum Message(u8) {\n+        /// Membership Query\n+        MembershipQuery = 0x11,\n+        /// Version 2 Membership Report\n+        MembershipReportV2 = 0x16,\n+        /// Leave Group\n+        LeaveGroup = 0x17,\n+        /// Version 1 Membership Report\n+        MembershipReportV1 = 0x12\n+    }\n+}\n+\n+/// A read/write wrapper around an Internet Group Management Protocol v2 packet buffer.\n+#[derive(Debug)]\n+pub struct Packet<T: AsRef<[u8]>> {\n+    buffer: T,\n+}\n+\n+mod field {\n+    use wire::field::*;\n+\n+    pub const TYPE: usize = 0;\n+    pub const MAX_RESP_TIME: usize = 1;\n+    pub const CHECKSUM: Field = 2..4;\n+    pub const GROUP_ADDRESS: Field = 4..8;\n+}\n+\n+impl fmt::Display for Message {\n+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n+        match self {\n+            &Message::MembershipQuery => write!(f, \"membership query\"),\n+            &Message::MembershipReportV2 => write!(f, \"version 2 membership report \"),\n+            &Message::LeaveGroup => write!(f, \"leave group\"),\n+            &Message::MembershipReportV1 => write!(f, \"version 1 membership report\"),\n+            &Message::Unknown(id) => write!(f, \"Unknown message {}\", id),\n+        }\n+    }\n+}\n+\n+\n+/// Internet Group Management Protocol v2\n+/// defined in [RFC 2236]\n+///\n+/// [RFC 2236]: https://tools.ietf.org/html/rfc2236\n+impl<T: AsRef<[u8]>> Packet<T> {\n+    /// Imbue a raw octet buffer with IGMPv2 packet structure.\n+    pub fn new(buffer: T) -> Packet<T> {\n+        Packet { buffer }\n+    }\n+\n+    /// Shorthand for a combination of [new] and [check_len].\n+    ///\n+    /// [new]: #method.new\n+    /// [check_len]: #method.check_len\n+    pub fn new_checked(buffer: T) -> Result<Packet<T>> {\n+        let packet = Self::new(buffer);\n+        packet.check_len()?;\n+        Ok(packet)\n+    }\n+\n+    /// Ensure that no accessor method will panic if called.\n+    /// Returns `Err(Error::Truncated)` if the buffer is too short.\n+    pub fn check_len(&self) -> Result<()> {\n+        let len = self.buffer.as_ref().len();\n+        if len < field::GROUP_ADDRESS.end as usize {\n+            Err(Error::Truncated)\n+        } else {\n+            Ok(())\n+        }\n+    }\n+\n+    /// Consume the packet, returning the underlying buffer.\n+    pub fn into_inner(self) -> T {\n+        self.buffer\n+    }\n+\n+    /// Return the message type field.\n+    #[inline]\n+    pub fn msg_type(&self) -> Message {\n+        let data = self.buffer.as_ref();\n+        Message::from(data[field::TYPE])\n+    }\n+\n+    /// Return the Max reponse time (in 100ms units)\n+    ///\n+    /// See [RFC 3376]: 4.1.1. Max Resp Code\n+    ///\n+    /// [RFC 3376]: https://tools.ietf.org/html/rfc3376\n+    #[inline]\n+    pub fn max_resp_time(&self) -> u8 {\n+        let data = self.buffer.as_ref();\n+        data[field::MAX_RESP_TIME].into()","path":"src/wire/igmpv2.rs","position":103,"original_position":103,"commit_id":"0967bfc83b677503cc43b214259e1c3f125d4368","original_commit_id":"0967bfc83b677503cc43b214259e1c3f125d4368","user":{"login":"dlrobertson","id":7504153,"avatar_url":"https://avatars1.githubusercontent.com/u/7504153?v=4","gravatar_id":"","url":"https://api.github.com/users/dlrobertson","html_url":"https://github.com/dlrobertson","followers_url":"https://api.github.com/users/dlrobertson/followers","following_url":"https://api.github.com/users/dlrobertson/following{/other_user}","gists_url":"https://api.github.com/users/dlrobertson/gists{/gist_id}","starred_url":"https://api.github.com/users/dlrobertson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlrobertson/subscriptions","organizations_url":"https://api.github.com/users/dlrobertson/orgs","repos_url":"https://api.github.com/users/dlrobertson/repos","events_url":"https://api.github.com/users/dlrobertson/events{/privacy}","received_events_url":"https://api.github.com/users/dlrobertson/received_events","type":"User","site_admin":false},"body":"I don't think you need the `into` here if you're returning a `u8`. Did you mean to return a `Duration`?","created_at":"2018-03-06T15:22:33Z","updated_at":"2018-03-06T15:30:14Z","html_url":"https://github.com/m-labs/smoltcp/pull/177#discussion_r172551115","pull_request_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/177","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/comments/172551115"},"html":{"href":"https://github.com/m-labs/smoltcp/pull/177#discussion_r172551115"},"pull_request":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/177"}}},"pull_request":{"url":"https://api.github.com/repos/m-labs/smoltcp/pulls/177","id":172914081,"html_url":"https://github.com/m-labs/smoltcp/pull/177","diff_url":"https://github.com/m-labs/smoltcp/pull/177.diff","patch_url":"https://github.com/m-labs/smoltcp/pull/177.patch","issue_url":"https://api.github.com/repos/m-labs/smoltcp/issues/177","number":177,"state":"open","locked":false,"title":"Implement IGMP packets","user":{"login":"astro","id":12923,"avatar_url":"https://avatars0.githubusercontent.com/u/12923?v=4","gravatar_id":"","url":"https://api.github.com/users/astro","html_url":"https://github.com/astro","followers_url":"https://api.github.com/users/astro/followers","following_url":"https://api.github.com/users/astro/following{/other_user}","gists_url":"https://api.github.com/users/astro/gists{/gist_id}","starred_url":"https://api.github.com/users/astro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astro/subscriptions","organizations_url":"https://api.github.com/users/astro/orgs","repos_url":"https://api.github.com/users/astro/repos","events_url":"https://api.github.com/users/astro/events{/privacy}","received_events_url":"https://api.github.com/users/astro/received_events","type":"User","site_admin":false},"body":"Retake on #60/#176 to clean up commit history.","created_at":"2018-03-05T16:17:38Z","updated_at":"2018-03-06T15:30:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"149a56241b729dc8bffefe1d80cc9f6951d76ff9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/177/commits","review_comments_url":"https://api.github.com/repos/m-labs/smoltcp/pulls/177/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/177/comments","statuses_url":"https://api.github.com/repos/m-labs/smoltcp/statuses/0967bfc83b677503cc43b214259e1c3f125d4368","head":{"label":"astro:igmp-packet","ref":"igmp-packet","sha":"0967bfc83b677503cc43b214259e1c3f125d4368","user":{"login":"astro","id":12923,"avatar_url":"https://avatars0.githubusercontent.com/u/12923?v=4","gravatar_id":"","url":"https://api.github.com/users/astro","html_url":"https://github.com/astro","followers_url":"https://api.github.com/users/astro/followers","following_url":"https://api.github.com/users/astro/following{/other_user}","gists_url":"https://api.github.com/users/astro/gists{/gist_id}","starred_url":"https://api.github.com/users/astro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astro/subscriptions","organizations_url":"https://api.github.com/users/astro/orgs","repos_url":"https://api.github.com/users/astro/repos","events_url":"https://api.github.com/users/astro/events{/privacy}","received_events_url":"https://api.github.com/users/astro/received_events","type":"User","site_admin":false},"repo":{"id":123508171,"name":"smoltcp","full_name":"astro/smoltcp","owner":{"login":"astro","id":12923,"avatar_url":"https://avatars0.githubusercontent.com/u/12923?v=4","gravatar_id":"","url":"https://api.github.com/users/astro","html_url":"https://github.com/astro","followers_url":"https://api.github.com/users/astro/followers","following_url":"https://api.github.com/users/astro/following{/other_user}","gists_url":"https://api.github.com/users/astro/gists{/gist_id}","starred_url":"https://api.github.com/users/astro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astro/subscriptions","organizations_url":"https://api.github.com/users/astro/orgs","repos_url":"https://api.github.com/users/astro/repos","events_url":"https://api.github.com/users/astro/events{/privacy}","received_events_url":"https://api.github.com/users/astro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/astro/smoltcp","description":"a smol tcp/ip stack","fork":true,"url":"https://api.github.com/repos/astro/smoltcp","forks_url":"https://api.github.com/repos/astro/smoltcp/forks","keys_url":"https://api.github.com/repos/astro/smoltcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astro/smoltcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astro/smoltcp/teams","hooks_url":"https://api.github.com/repos/astro/smoltcp/hooks","issue_events_url":"https://api.github.com/repos/astro/smoltcp/issues/events{/number}","events_url":"https://api.github.com/repos/astro/smoltcp/events","assignees_url":"https://api.github.com/repos/astro/smoltcp/assignees{/user}","branches_url":"https://api.github.com/repos/astro/smoltcp/branches{/branch}","tags_url":"https://api.github.com/repos/astro/smoltcp/tags","blobs_url":"https://api.github.com/repos/astro/smoltcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astro/smoltcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astro/smoltcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/astro/smoltcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astro/smoltcp/statuses/{sha}","languages_url":"https://api.github.com/repos/astro/smoltcp/languages","stargazers_url":"https://api.github.com/repos/astro/smoltcp/stargazers","contributors_url":"https://api.github.com/repos/astro/smoltcp/contributors","subscribers_url":"https://api.github.com/repos/astro/smoltcp/subscribers","subscription_url":"https://api.github.com/repos/astro/smoltcp/subscription","commits_url":"https://api.github.com/repos/astro/smoltcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/astro/smoltcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/astro/smoltcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/astro/smoltcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/astro/smoltcp/contents/{+path}","compare_url":"https://api.github.com/repos/astro/smoltcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astro/smoltcp/merges","archive_url":"https://api.github.com/repos/astro/smoltcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astro/smoltcp/downloads","issues_url":"https://api.github.com/repos/astro/smoltcp/issues{/number}","pulls_url":"https://api.github.com/repos/astro/smoltcp/pulls{/number}","milestones_url":"https://api.github.com/repos/astro/smoltcp/milestones{/number}","notifications_url":"https://api.github.com/repos/astro/smoltcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astro/smoltcp/labels{/name}","releases_url":"https://api.github.com/repos/astro/smoltcp/releases{/id}","deployments_url":"https://api.github.com/repos/astro/smoltcp/deployments","created_at":"2018-03-02T00:19:31Z","updated_at":"2018-03-02T00:19:33Z","pushed_at":"2018-03-06T15:04:51Z","git_url":"git://github.com/astro/smoltcp.git","ssh_url":"git@github.com:astro/smoltcp.git","clone_url":"https://github.com/astro/smoltcp.git","svn_url":"https://github.com/astro/smoltcp","homepage":null,"size":1144,"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":"89999a69812659e5241f8561d1ecb3fd1c949a9f","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-03-06T10:54:37Z","pushed_at":"2018-03-06T15:04:53Z","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":1050,"stargazers_count":421,"watchers_count":421,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":36,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":36,"open_issues":32,"watchers":421,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/177"},"html":{"href":"https://github.com/m-labs/smoltcp/pull/177"},"issue":{"href":"https://api.github.com/repos/m-labs/smoltcp/issues/177"},"comments":{"href":"https://api.github.com/repos/m-labs/smoltcp/issues/177/comments"},"review_comments":{"href":"https://api.github.com/repos/m-labs/smoltcp/pulls/177/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/177/commits"},"statuses":{"href":"https://api.github.com/repos/m-labs/smoltcp/statuses/0967bfc83b677503cc43b214259e1c3f125d4368"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dlrobertson"}}