{"action":"created","comment":{"url":"https://api.github.com/repos/google/gopacket/pulls/comments/28701489","id":28701489,"diff_hunk":"@@ -0,0 +1,276 @@\n+package defrag\n+\n+import (\n+\t\"container/list\"\n+\t\"fmt\"\n+\t\"log\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\t\"code.google.com/p/gopacket\"\n+\t\"code.google.com/p/gopacket/layers\"\n+)\n+\n+// Quick and Easy yo use debug code to trace\n+// how defrag works.\n+var debug debugging = false // or flip to false\n+type debugging bool\n+\n+func (d debugging) Printf(format string, args ...interface{}) {\n+\tif d {\n+\t\tlog.Printf(format, args...)\n+\t}\n+}\n+\n+type Defragmenter interface {\n+\t// DefragIPv4 takes in an IPv4 packet with a fragment payload.\n+\t//\n+\t// It modifies the IPv4 layer in place, returning true if the\n+\t// modified layer is now a full IPv4 payload.\n+\t//\n+\t// If the passed-in IP layer is NOT fragmented, it will\n+\t// immediately return true without modifying the layer.\n+\t//\n+\t// If the IPv4 layer is a fragment and we don't have all\n+\t// fragments, it will return false and store whatever internal\n+\t// information it needs to eventually defrag the packet.\n+\t//\n+\t// If the IPv4 layer is the last fragment needed to reconstruct\n+\t// the packet, *ip will be set to the entire defragmented packet,\n+\t// and the function will return true.\n+\tDefragIPv4(IPv4 *layers.IPv4) (bool, error)","path":"defrag/defrag.go","position":41,"original_position":41,"commit_id":"f39ff367ad2a35d9b9007dbedd9e54b52c36e607","original_commit_id":"f39ff367ad2a35d9b9007dbedd9e54b52c36e607","user":{"login":"gconnell","id":1211830,"avatar_url":"https://avatars.githubusercontent.com/u/1211830?v=3","gravatar_id":"","url":"https://api.github.com/users/gconnell","html_url":"https://github.com/gconnell","followers_url":"https://api.github.com/users/gconnell/followers","following_url":"https://api.github.com/users/gconnell/following{/other_user}","gists_url":"https://api.github.com/users/gconnell/gists{/gist_id}","starred_url":"https://api.github.com/users/gconnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gconnell/subscriptions","organizations_url":"https://api.github.com/users/gconnell/orgs","repos_url":"https://api.github.com/users/gconnell/repos","events_url":"https://api.github.com/users/gconnell/events{/privacy}","received_events_url":"https://api.github.com/users/gconnell/received_events","type":"User","site_admin":false},"body":"How about:\r\n\r\nDefragIPv4(in *layers.IPv4) (*layers.IPv4, error)\r\n\r\nWhere if 'in' isn't fragmented, we return it.  If it is and it's the last fragment, we return the unfragmented value.  If it's NOT the last fragment, we return (nil, nil).\r\n\r\nIn particular, I'd like to maintain the guarantee that 'in' is not modified.  This will mean allocating packets for output, but that can be done in batch, which should lessen the problem, and only needs to be done during actual fragmentation (since returning 'in' doesn't require any modification to 'in' OR any allocation).","created_at":"2015-04-20T15:56:08Z","updated_at":"2015-04-20T15:56:08Z","html_url":"https://github.com/google/gopacket/pull/71#discussion_r28701489","pull_request_url":"https://api.github.com/repos/google/gopacket/pulls/71","_links":{"self":{"href":"https://api.github.com/repos/google/gopacket/pulls/comments/28701489"},"html":{"href":"https://github.com/google/gopacket/pull/71#discussion_r28701489"},"pull_request":{"href":"https://api.github.com/repos/google/gopacket/pulls/71"}}},"pull_request":{"url":"https://api.github.com/repos/google/gopacket/pulls/71","id":33678431,"html_url":"https://github.com/google/gopacket/pull/71","diff_url":"https://github.com/google/gopacket/pull/71.diff","patch_url":"https://github.com/google/gopacket/pull/71.patch","issue_url":"https://api.github.com/repos/google/gopacket/issues/71","number":71,"state":"open","locked":false,"title":"defrag: Implement a IPv4 defragmenter (EXPERIMENTAL)","user":{"login":"lhausermann","id":7381663,"avatar_url":"https://avatars.githubusercontent.com/u/7381663?v=3","gravatar_id":"","url":"https://api.github.com/users/lhausermann","html_url":"https://github.com/lhausermann","followers_url":"https://api.github.com/users/lhausermann/followers","following_url":"https://api.github.com/users/lhausermann/following{/other_user}","gists_url":"https://api.github.com/users/lhausermann/gists{/gist_id}","starred_url":"https://api.github.com/users/lhausermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhausermann/subscriptions","organizations_url":"https://api.github.com/users/lhausermann/orgs","repos_url":"https://api.github.com/users/lhausermann/repos","events_url":"https://api.github.com/users/lhausermann/events{/privacy}","received_events_url":"https://api.github.com/users/lhausermann/received_events","type":"User","site_admin":false},"body":"This is an *experiment*, I've made during a cloudy weekend ;)\r\nIt is based on the DefragIPv4 interface suggested by Graeme some months ago.\r\n\r\nI am submitting it for  **reviewing purpose and get extensive comments** from the GoPacket Authors\r\n\r\nThis implements the DefragIPv4 interface, which embed IPv4\r\ndefragmentation, and modify packets in place. It returns false\r\nif the packet is fragmented, and caller will need to give subsequent\r\npackets. It returns true, if the packet is in its final state (defragmented\r\nor just pristine).\r\n","created_at":"2015-04-20T15:47:21Z","updated_at":"2015-04-20T15:56:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46560c14e3fc9836f3905442dfb519e8b44a9bab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/gopacket/pulls/71/commits","review_comments_url":"https://api.github.com/repos/google/gopacket/pulls/71/comments","review_comment_url":"https://api.github.com/repos/google/gopacket/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/gopacket/issues/71/comments","statuses_url":"https://api.github.com/repos/google/gopacket/statuses/f39ff367ad2a35d9b9007dbedd9e54b52c36e607","head":{"label":"lhausermann:ip4-defrag","ref":"ip4-defrag","sha":"f39ff367ad2a35d9b9007dbedd9e54b52c36e607","user":{"login":"lhausermann","id":7381663,"avatar_url":"https://avatars.githubusercontent.com/u/7381663?v=3","gravatar_id":"","url":"https://api.github.com/users/lhausermann","html_url":"https://github.com/lhausermann","followers_url":"https://api.github.com/users/lhausermann/followers","following_url":"https://api.github.com/users/lhausermann/following{/other_user}","gists_url":"https://api.github.com/users/lhausermann/gists{/gist_id}","starred_url":"https://api.github.com/users/lhausermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhausermann/subscriptions","organizations_url":"https://api.github.com/users/lhausermann/orgs","repos_url":"https://api.github.com/users/lhausermann/repos","events_url":"https://api.github.com/users/lhausermann/events{/privacy}","received_events_url":"https://api.github.com/users/lhausermann/received_events","type":"User","site_admin":false},"repo":{"id":34269197,"name":"gopacket","full_name":"lhausermann/gopacket","owner":{"login":"lhausermann","id":7381663,"avatar_url":"https://avatars.githubusercontent.com/u/7381663?v=3","gravatar_id":"","url":"https://api.github.com/users/lhausermann","html_url":"https://github.com/lhausermann","followers_url":"https://api.github.com/users/lhausermann/followers","following_url":"https://api.github.com/users/lhausermann/following{/other_user}","gists_url":"https://api.github.com/users/lhausermann/gists{/gist_id}","starred_url":"https://api.github.com/users/lhausermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhausermann/subscriptions","organizations_url":"https://api.github.com/users/lhausermann/orgs","repos_url":"https://api.github.com/users/lhausermann/repos","events_url":"https://api.github.com/users/lhausermann/events{/privacy}","received_events_url":"https://api.github.com/users/lhausermann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lhausermann/gopacket","description":"Provides packet processing capabilities for Go","fork":true,"url":"https://api.github.com/repos/lhausermann/gopacket","forks_url":"https://api.github.com/repos/lhausermann/gopacket/forks","keys_url":"https://api.github.com/repos/lhausermann/gopacket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lhausermann/gopacket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lhausermann/gopacket/teams","hooks_url":"https://api.github.com/repos/lhausermann/gopacket/hooks","issue_events_url":"https://api.github.com/repos/lhausermann/gopacket/issues/events{/number}","events_url":"https://api.github.com/repos/lhausermann/gopacket/events","assignees_url":"https://api.github.com/repos/lhausermann/gopacket/assignees{/user}","branches_url":"https://api.github.com/repos/lhausermann/gopacket/branches{/branch}","tags_url":"https://api.github.com/repos/lhausermann/gopacket/tags","blobs_url":"https://api.github.com/repos/lhausermann/gopacket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lhausermann/gopacket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lhausermann/gopacket/git/refs{/sha}","trees_url":"https://api.github.com/repos/lhausermann/gopacket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lhausermann/gopacket/statuses/{sha}","languages_url":"https://api.github.com/repos/lhausermann/gopacket/languages","stargazers_url":"https://api.github.com/repos/lhausermann/gopacket/stargazers","contributors_url":"https://api.github.com/repos/lhausermann/gopacket/contributors","subscribers_url":"https://api.github.com/repos/lhausermann/gopacket/subscribers","subscription_url":"https://api.github.com/repos/lhausermann/gopacket/subscription","commits_url":"https://api.github.com/repos/lhausermann/gopacket/commits{/sha}","git_commits_url":"https://api.github.com/repos/lhausermann/gopacket/git/commits{/sha}","comments_url":"https://api.github.com/repos/lhausermann/gopacket/comments{/number}","issue_comment_url":"https://api.github.com/repos/lhausermann/gopacket/issues/comments{/number}","contents_url":"https://api.github.com/repos/lhausermann/gopacket/contents/{+path}","compare_url":"https://api.github.com/repos/lhausermann/gopacket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lhausermann/gopacket/merges","archive_url":"https://api.github.com/repos/lhausermann/gopacket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lhausermann/gopacket/downloads","issues_url":"https://api.github.com/repos/lhausermann/gopacket/issues{/number}","pulls_url":"https://api.github.com/repos/lhausermann/gopacket/pulls{/number}","milestones_url":"https://api.github.com/repos/lhausermann/gopacket/milestones{/number}","notifications_url":"https://api.github.com/repos/lhausermann/gopacket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lhausermann/gopacket/labels{/name}","releases_url":"https://api.github.com/repos/lhausermann/gopacket/releases{/id}","created_at":"2015-04-20T15:34:47Z","updated_at":"2015-04-20T15:34:48Z","pushed_at":"2015-04-20T15:43:59Z","git_url":"git://github.com/lhausermann/gopacket.git","ssh_url":"git@github.com:lhausermann/gopacket.git","clone_url":"https://github.com/lhausermann/gopacket.git","svn_url":"https://github.com/lhausermann/gopacket","homepage":"","size":3866,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"521c6020a28662df56e7f0b6f03fd2e1a4975484","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":32351944,"name":"gopacket","full_name":"google/gopacket","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/gopacket","description":"Provides packet processing capabilities for Go","fork":false,"url":"https://api.github.com/repos/google/gopacket","forks_url":"https://api.github.com/repos/google/gopacket/forks","keys_url":"https://api.github.com/repos/google/gopacket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/gopacket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/gopacket/teams","hooks_url":"https://api.github.com/repos/google/gopacket/hooks","issue_events_url":"https://api.github.com/repos/google/gopacket/issues/events{/number}","events_url":"https://api.github.com/repos/google/gopacket/events","assignees_url":"https://api.github.com/repos/google/gopacket/assignees{/user}","branches_url":"https://api.github.com/repos/google/gopacket/branches{/branch}","tags_url":"https://api.github.com/repos/google/gopacket/tags","blobs_url":"https://api.github.com/repos/google/gopacket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/gopacket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/gopacket/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/gopacket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/gopacket/statuses/{sha}","languages_url":"https://api.github.com/repos/google/gopacket/languages","stargazers_url":"https://api.github.com/repos/google/gopacket/stargazers","contributors_url":"https://api.github.com/repos/google/gopacket/contributors","subscribers_url":"https://api.github.com/repos/google/gopacket/subscribers","subscription_url":"https://api.github.com/repos/google/gopacket/subscription","commits_url":"https://api.github.com/repos/google/gopacket/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/gopacket/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/gopacket/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/gopacket/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/gopacket/contents/{+path}","compare_url":"https://api.github.com/repos/google/gopacket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/gopacket/merges","archive_url":"https://api.github.com/repos/google/gopacket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/gopacket/downloads","issues_url":"https://api.github.com/repos/google/gopacket/issues{/number}","pulls_url":"https://api.github.com/repos/google/gopacket/pulls{/number}","milestones_url":"https://api.github.com/repos/google/gopacket/milestones{/number}","notifications_url":"https://api.github.com/repos/google/gopacket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/gopacket/labels{/name}","releases_url":"https://api.github.com/repos/google/gopacket/releases{/id}","created_at":"2015-03-16T20:46:00Z","updated_at":"2015-04-20T05:52:52Z","pushed_at":"2015-04-20T15:47:21Z","git_url":"git://github.com/google/gopacket.git","ssh_url":"git@github.com:google/gopacket.git","clone_url":"https://github.com/google/gopacket.git","svn_url":"https://github.com/google/gopacket","homepage":"","size":3866,"stargazers_count":47,"watchers_count":47,"language":"Go","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":5,"forks":10,"open_issues":5,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/gopacket/pulls/71"},"html":{"href":"https://github.com/google/gopacket/pull/71"},"issue":{"href":"https://api.github.com/repos/google/gopacket/issues/71"},"comments":{"href":"https://api.github.com/repos/google/gopacket/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/google/gopacket/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/google/gopacket/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/gopacket/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/google/gopacket/statuses/f39ff367ad2a35d9b9007dbedd9e54b52c36e607"}}}}