{"action":"created","comment":{"url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/comments/98703846","pull_request_review_id":19349496,"id":98703846,"diff_hunk":"@@ -307,30 +320,94 @@ static int\n win_pcopy(unsigned char *dst, struct vr_packet *p_src,\n         unsigned int offset, unsigned int len)\n {\n-    UNREFERENCED_PARAMETER(dst);\n-    UNREFERENCED_PARAMETER(p_src);\n-    UNREFERENCED_PARAMETER(offset);\n-    UNREFERENCED_PARAMETER(len);\n+    PNET_BUFFER_LIST nbl = p_src->vp_net_buffer_list;\n+    if (!nbl) {\n+        return -EFAULT;\n+    }\n+    PNET_BUFFER nb = NET_BUFFER_LIST_FIRST_NB(nbl);\n+    if (!nb) {\n+        return -EFAULT;\n+    }\n+\n+    ULONG data_offset = NET_BUFFER_DATA_OFFSET(nb);\n+    ULONG data_length = NET_BUFFER_DATA_LENGTH(nb);\n+    ULONG data_size = data_offset + data_length;\n+    if (data_offset + (ULONG)offset + (ULONG)len >= data_size) {\n+        /* Attempted to copy more bytes than present in packet */\n+        return -EFAULT;\n+    }\n+\n+    // Walk through MDL list, until `offset` is reached.\n+    PMDL current_mdl = NET_BUFFER_CURRENT_MDL(nb);\n+    ULONG mdl_data_offset = NET_BUFFER_CURRENT_MDL_OFFSET(nb);\n+    ULONG current_offset = offset;\n+    while (mdl_data_offset + current_offset >= MmGetMdlByteCount(current_mdl)) {\n+        current_offset -= MmGetMdlByteCount(current_mdl) - mdl_data_offset;\n+        mdl_data_offset = 0;\n+        current_mdl = current_mdl->Next;\n+    }\n+    mdl_data_offset = current_offset;\n+\n+    unsigned int copied_bytes = 0;\n+    ULONG bytes_to_copy = MmGetMdlByteCount(current_mdl) - mdl_data_offset;\n+    unsigned char *mdl_data =\n+        (unsigned char *)MmGetSystemAddressForMdlSafe(current_mdl, LowPagePriority | MdlMappingNoExecute);\n+    if (!mdl_data) {\n+        return -EFAULT;\n+    }\n+\n+    NdisMoveMemory(dst, mdl_data + mdl_data_offset, bytes_to_copy);\n+    copied_bytes += bytes_to_copy;\n+\n+    current_mdl = current_mdl->Next;\n+    while (copied_bytes < len && current_mdl) {\n+        mdl_data =\n+            (unsigned char *)MmGetSystemAddressForMdlSafe(current_mdl, LowPagePriority | MdlMappingNoExecute);\n+        if (!current_mdl) {\n+            return -EFAULT;\n+        }\n+\n+        unsigned int left_to_copy = len - copied_bytes;\n+        ULONG mdl_size = MmGetMdlByteCount(current_mdl);\n+        if (left_to_copy >= mdl_size) {\n+            NdisMoveMemory(dst + copied_bytes, mdl_data, mdl_size);\n+            copied_bytes += mdl_size;\n+        } else {\n+            NdisMoveMemory(dst + copied_bytes, mdl_data, left_to_copy);\n+            copied_bytes += left_to_copy;\n+        }\n+\n+        current_mdl = current_mdl->Next;\n+    }\n+\n+    if (copied_bytes < len) {\n+        /* MDL list has ended before all of the packet data could be copied. */\n+        return -EFAULT;\n+    }\n \n-    /* Dummy implementation */\n     return len;\n }\n \n static unsigned short\n win_pfrag_len(struct vr_packet *pkt)\n {\n-    UNREFERENCED_PARAMETER(pkt);\n+    PNET_BUFFER_LIST nbl = pkt->vp_net_buffer_list;\n+    if (!nbl)\n+        return 0;\n \n-    /* Dummy implementation */\n-    return 0;\n+    PNET_BUFFER nb = NET_BUFFER_LIST_FIRST_NB(nbl);\n+    if (!nb)\n+        return 0;\n+\n+    unsigned short frag_len = (unsigned short)NET_BUFFER_DATA_LENGTH(nb);\n+    return frag_len;\n }\n \n static unsigned short\n win_phead_len(struct vr_packet *pkt)\n {\n     UNREFERENCED_PARAMETER(pkt);\n \n-    /* Dummy implementation */","path":"windows/vr_host.c","position":131,"original_position":131,"commit_id":"6472d1b4d846414b13e65048ce61e99b644422d8","original_commit_id":"6472d1b4d846414b13e65048ce61e99b644422d8","user":{"login":"michal-clapinski","id":21240386,"avatar_url":"https://avatars.githubusercontent.com/u/21240386?v=3","gravatar_id":"","url":"https://api.github.com/users/michal-clapinski","html_url":"https://github.com/michal-clapinski","followers_url":"https://api.github.com/users/michal-clapinski/followers","following_url":"https://api.github.com/users/michal-clapinski/following{/other_user}","gists_url":"https://api.github.com/users/michal-clapinski/gists{/gist_id}","starred_url":"https://api.github.com/users/michal-clapinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michal-clapinski/subscriptions","organizations_url":"https://api.github.com/users/michal-clapinski/orgs","repos_url":"https://api.github.com/users/michal-clapinski/repos","events_url":"https://api.github.com/users/michal-clapinski/events{/privacy}","received_events_url":"https://api.github.com/users/michal-clapinski/received_events","type":"User","site_admin":false},"body":"Is this correct? You just removed \"/* Dummy implementation */\" and didn't write any code.","created_at":"2017-01-31T16:11:48Z","updated_at":"2017-01-31T16:16:38Z","html_url":"https://github.com/codilime/contrail-vrouter/pull/20#discussion_r98703846","pull_request_url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/comments/98703846"},"html":{"href":"https://github.com/codilime/contrail-vrouter/pull/20#discussion_r98703846"},"pull_request":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20","id":103789179,"html_url":"https://github.com/codilime/contrail-vrouter/pull/20","diff_url":"https://github.com/codilime/contrail-vrouter/pull/20.diff","patch_url":"https://github.com/codilime/contrail-vrouter/pull/20.patch","issue_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues/20","number":20,"state":"open","locked":false,"title":"JW-80 vr_packet manipulation callbacks","user":{"login":"sodar","id":1798621,"avatar_url":"https://avatars.githubusercontent.com/u/1798621?v=3","gravatar_id":"","url":"https://api.github.com/users/sodar","html_url":"https://github.com/sodar","followers_url":"https://api.github.com/users/sodar/followers","following_url":"https://api.github.com/users/sodar/following{/other_user}","gists_url":"https://api.github.com/users/sodar/gists{/gist_id}","starred_url":"https://api.github.com/users/sodar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sodar/subscriptions","organizations_url":"https://api.github.com/users/sodar/orgs","repos_url":"https://api.github.com/users/sodar/repos","events_url":"https://api.github.com/users/sodar/events{/privacy}","received_events_url":"https://api.github.com/users/sodar/received_events","type":"User","site_admin":false},"body":"Depends on https://github.com/codilime/contrail-vrouter/pull/19.\r\n\r\n- [ ] Testing of vr_pcopy callback","created_at":"2017-01-30T18:07:30Z","updated_at":"2017-01-31T16:16:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a418a0bc556c1613bb08e7ce1da36f4442bc1e9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20/commits","review_comments_url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20/comments","review_comment_url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues/20/comments","statuses_url":"https://api.github.com/repos/codilime/contrail-vrouter/statuses/6472d1b4d846414b13e65048ce61e99b644422d8","head":{"label":"codilime:JW-80_vr-packet-manipulation","ref":"JW-80_vr-packet-manipulation","sha":"6472d1b4d846414b13e65048ce61e99b644422d8","user":{"login":"codilime","id":2143695,"avatar_url":"https://avatars.githubusercontent.com/u/2143695?v=3","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"repo":{"id":72856684,"name":"contrail-vrouter","full_name":"codilime/contrail-vrouter","owner":{"login":"codilime","id":2143695,"avatar_url":"https://avatars.githubusercontent.com/u/2143695?v=3","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codilime/contrail-vrouter","description":"Contrail Virtual Router","fork":true,"url":"https://api.github.com/repos/codilime/contrail-vrouter","forks_url":"https://api.github.com/repos/codilime/contrail-vrouter/forks","keys_url":"https://api.github.com/repos/codilime/contrail-vrouter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codilime/contrail-vrouter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codilime/contrail-vrouter/teams","hooks_url":"https://api.github.com/repos/codilime/contrail-vrouter/hooks","issue_events_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues/events{/number}","events_url":"https://api.github.com/repos/codilime/contrail-vrouter/events","assignees_url":"https://api.github.com/repos/codilime/contrail-vrouter/assignees{/user}","branches_url":"https://api.github.com/repos/codilime/contrail-vrouter/branches{/branch}","tags_url":"https://api.github.com/repos/codilime/contrail-vrouter/tags","blobs_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/refs{/sha}","trees_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codilime/contrail-vrouter/statuses/{sha}","languages_url":"https://api.github.com/repos/codilime/contrail-vrouter/languages","stargazers_url":"https://api.github.com/repos/codilime/contrail-vrouter/stargazers","contributors_url":"https://api.github.com/repos/codilime/contrail-vrouter/contributors","subscribers_url":"https://api.github.com/repos/codilime/contrail-vrouter/subscribers","subscription_url":"https://api.github.com/repos/codilime/contrail-vrouter/subscription","commits_url":"https://api.github.com/repos/codilime/contrail-vrouter/commits{/sha}","git_commits_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/commits{/sha}","comments_url":"https://api.github.com/repos/codilime/contrail-vrouter/comments{/number}","issue_comment_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues/comments{/number}","contents_url":"https://api.github.com/repos/codilime/contrail-vrouter/contents/{+path}","compare_url":"https://api.github.com/repos/codilime/contrail-vrouter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codilime/contrail-vrouter/merges","archive_url":"https://api.github.com/repos/codilime/contrail-vrouter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codilime/contrail-vrouter/downloads","issues_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues{/number}","pulls_url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls{/number}","milestones_url":"https://api.github.com/repos/codilime/contrail-vrouter/milestones{/number}","notifications_url":"https://api.github.com/repos/codilime/contrail-vrouter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codilime/contrail-vrouter/labels{/name}","releases_url":"https://api.github.com/repos/codilime/contrail-vrouter/releases{/id}","deployments_url":"https://api.github.com/repos/codilime/contrail-vrouter/deployments","created_at":"2016-11-04T14:49:29Z","updated_at":"2016-11-04T14:49:32Z","pushed_at":"2017-01-30T18:07:31Z","git_url":"git://github.com/codilime/contrail-vrouter.git","ssh_url":"git@github.com:codilime/contrail-vrouter.git","clone_url":"https://github.com/codilime/contrail-vrouter.git","svn_url":"https://github.com/codilime/contrail-vrouter","homepage":null,"size":10599,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"codilime:dev/packets_memory","ref":"dev/packets_memory","sha":"6289901d68054a81d723efc35c91269d4e90dfaf","user":{"login":"codilime","id":2143695,"avatar_url":"https://avatars.githubusercontent.com/u/2143695?v=3","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"repo":{"id":72856684,"name":"contrail-vrouter","full_name":"codilime/contrail-vrouter","owner":{"login":"codilime","id":2143695,"avatar_url":"https://avatars.githubusercontent.com/u/2143695?v=3","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codilime/contrail-vrouter","description":"Contrail Virtual Router","fork":true,"url":"https://api.github.com/repos/codilime/contrail-vrouter","forks_url":"https://api.github.com/repos/codilime/contrail-vrouter/forks","keys_url":"https://api.github.com/repos/codilime/contrail-vrouter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codilime/contrail-vrouter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codilime/contrail-vrouter/teams","hooks_url":"https://api.github.com/repos/codilime/contrail-vrouter/hooks","issue_events_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues/events{/number}","events_url":"https://api.github.com/repos/codilime/contrail-vrouter/events","assignees_url":"https://api.github.com/repos/codilime/contrail-vrouter/assignees{/user}","branches_url":"https://api.github.com/repos/codilime/contrail-vrouter/branches{/branch}","tags_url":"https://api.github.com/repos/codilime/contrail-vrouter/tags","blobs_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/refs{/sha}","trees_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codilime/contrail-vrouter/statuses/{sha}","languages_url":"https://api.github.com/repos/codilime/contrail-vrouter/languages","stargazers_url":"https://api.github.com/repos/codilime/contrail-vrouter/stargazers","contributors_url":"https://api.github.com/repos/codilime/contrail-vrouter/contributors","subscribers_url":"https://api.github.com/repos/codilime/contrail-vrouter/subscribers","subscription_url":"https://api.github.com/repos/codilime/contrail-vrouter/subscription","commits_url":"https://api.github.com/repos/codilime/contrail-vrouter/commits{/sha}","git_commits_url":"https://api.github.com/repos/codilime/contrail-vrouter/git/commits{/sha}","comments_url":"https://api.github.com/repos/codilime/contrail-vrouter/comments{/number}","issue_comment_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues/comments{/number}","contents_url":"https://api.github.com/repos/codilime/contrail-vrouter/contents/{+path}","compare_url":"https://api.github.com/repos/codilime/contrail-vrouter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codilime/contrail-vrouter/merges","archive_url":"https://api.github.com/repos/codilime/contrail-vrouter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codilime/contrail-vrouter/downloads","issues_url":"https://api.github.com/repos/codilime/contrail-vrouter/issues{/number}","pulls_url":"https://api.github.com/repos/codilime/contrail-vrouter/pulls{/number}","milestones_url":"https://api.github.com/repos/codilime/contrail-vrouter/milestones{/number}","notifications_url":"https://api.github.com/repos/codilime/contrail-vrouter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codilime/contrail-vrouter/labels{/name}","releases_url":"https://api.github.com/repos/codilime/contrail-vrouter/releases{/id}","deployments_url":"https://api.github.com/repos/codilime/contrail-vrouter/deployments","created_at":"2016-11-04T14:49:29Z","updated_at":"2016-11-04T14:49:32Z","pushed_at":"2017-01-30T18:07:31Z","git_url":"git://github.com/codilime/contrail-vrouter.git","ssh_url":"git@github.com:codilime/contrail-vrouter.git","clone_url":"https://github.com/codilime/contrail-vrouter.git","svn_url":"https://github.com/codilime/contrail-vrouter","homepage":null,"size":10599,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20"},"html":{"href":"https://github.com/codilime/contrail-vrouter/pull/20"},"issue":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/issues/20"},"comments":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/codilime/contrail-vrouter/statuses/6472d1b4d846414b13e65048ce61e99b644422d8"}}}}
{"actor":{"display_login":"michal-clapinski"}}