{"action":"created","comment":{"url":"https://api.github.com/repos/embox/embox/pulls/comments/31390993","id":31390993,"diff_hunk":"@@ -12,100 +14,244 @@\n #include <kernel/panic.h>\n #include <embox/unit.h>\n #include <drivers/usb/usb_cdc.h>\n+#include <drivers/usb/usb_driver.h>\n #include <kernel/printk.h>\n #include <stdlib.h>\n+#include <string.h>\n \n EMBOX_UNIT_INIT(usb_cdc_init);\n \n POOL_DEF(cdc_classes, struct usb_class_cdc, USB_CDC_MAX_DEVS);\n \n-#if 0\n-static uint32_t line_coding;\n+/* Storage for device configuration*/\n+static char cdc_conf[16];\n \n-static void get_line_coding_conf_hnd(struct usb_request *req, void *arg) {\n+#define INTERFACE_DESC_OFFSET          (sizeof (struct usb_desc_configuration))\n+#define CS_INTERFACE                   0x24\n+\n+/* Configuration */\n+static void cdc_get_conf_len_hnd(struct usb_request *req, void *arg);\n+static void cdc_get_conf(struct usb_dev *dev, struct usb_class_cdc *cdc,\n+\t\tsize_t idx, size_t len, usb_request_notify_hnd_t cb);\n+static void cdc_get_conf_content_hnd(struct usb_request *req, void *arg);\n+static void cdc_get_conf_hnd(struct usb_request *req, void *arg);\n+static void cdc_next_conf(struct usb_dev *dev);\n+\n+/* Endpoint */\n+static size_t cdc_skip_func_descs(char *start);\n+static size_t cdc_skip_endpoints(char *start);\n+static void cdc_get_endpoints(struct usb_dev *dev, struct usb_class_cdc *cdc);\n+\n+/* Misc */\n+static int is_rndis(struct usb_desc_interface *desc);\n+\n+/**\n+ * Skip all functional descriptors.\n+ * Return size of all functional descriptors.\n+ * @see ecm120.pdf (Subclass Specification for\n+ *  Ethernet Control Model Devices) Section 5\n+ * XXX skip is a default action now, but it is possible to redefine this behavior\n+ */\n+static size_t cdc_skip_func_descs(char *start) {\n+\tchar *cur = start;\n+\n+\twhile (1) {\n+\t\tuint8_t len, type;\n+\n+\t\ttype = *(cur + 1);\n+\t\tif (type == CS_INTERFACE) {\n+\t\t\tlen = *cur;\n+\t\t\tcur += len;\n+\t\t} else {\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn (cur - start);\n }","path":"src/drivers/usb/class/usb_class_cdc.c","position":70,"original_position":70,"commit_id":"212fcfa96bf2777417359d6d65d3ddd5e78336b6","original_commit_id":"212fcfa96bf2777417359d6d65d3ddd5e78336b6","user":{"login":"alexkalmuk","id":10322525,"avatar_url":"https://avatars.githubusercontent.com/u/10322525?v=3","gravatar_id":"","url":"https://api.github.com/users/alexkalmuk","html_url":"https://github.com/alexkalmuk","followers_url":"https://api.github.com/users/alexkalmuk/followers","following_url":"https://api.github.com/users/alexkalmuk/following{/other_user}","gists_url":"https://api.github.com/users/alexkalmuk/gists{/gist_id}","starred_url":"https://api.github.com/users/alexkalmuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexkalmuk/subscriptions","organizations_url":"https://api.github.com/users/alexkalmuk/orgs","repos_url":"https://api.github.com/users/alexkalmuk/repos","events_url":"https://api.github.com/users/alexkalmuk/events{/privacy}","received_events_url":"https://api.github.com/users/alexkalmuk/received_events","type":"User","site_admin":false},"body":"Thank you, it looks better.","created_at":"2015-05-31T15:03:57Z","updated_at":"2015-05-31T15:03:57Z","html_url":"https://github.com/embox/embox/pull/763#discussion_r31390993","pull_request_url":"https://api.github.com/repos/embox/embox/pulls/763","_links":{"self":{"href":"https://api.github.com/repos/embox/embox/pulls/comments/31390993"},"html":{"href":"https://github.com/embox/embox/pull/763#discussion_r31390993"},"pull_request":{"href":"https://api.github.com/repos/embox/embox/pulls/763"}}},"pull_request":{"url":"https://api.github.com/repos/embox/embox/pulls/763","id":36581236,"html_url":"https://github.com/embox/embox/pull/763","diff_url":"https://github.com/embox/embox/pull/763.diff","patch_url":"https://github.com/embox/embox/pull/763.patch","issue_url":"https://api.github.com/repos/embox/embox/issues/763","number":763,"state":"open","locked":false,"title":"usbnet driver","user":{"login":"alexkalmuk","id":10322525,"avatar_url":"https://avatars.githubusercontent.com/u/10322525?v=3","gravatar_id":"","url":"https://api.github.com/users/alexkalmuk","html_url":"https://github.com/alexkalmuk","followers_url":"https://api.github.com/users/alexkalmuk/followers","following_url":"https://api.github.com/users/alexkalmuk/following{/other_user}","gists_url":"https://api.github.com/users/alexkalmuk/gists{/gist_id}","starred_url":"https://api.github.com/users/alexkalmuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexkalmuk/subscriptions","organizations_url":"https://api.github.com/users/alexkalmuk/orgs","repos_url":"https://api.github.com/users/alexkalmuk/repos","events_url":"https://api.github.com/users/alexkalmuk/events{/privacy}","received_events_url":"https://api.github.com/users/alexkalmuk/received_events","type":"User","site_admin":false},"body":"Purpose: Obtain ping between Embox and Linux through usbnet driver.\r\n\r\nWhat 's done:\r\n- Added usbnet (Ethernet over USB) driver\r\n- Added USB CDC class","created_at":"2015-05-31T12:14:09Z","updated_at":"2015-05-31T15:03:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8bbe3d1573e8dbd7bb8315d088824f3b98b6c446","assignee":{"login":"abusalimov","id":530396,"avatar_url":"https://avatars.githubusercontent.com/u/530396?v=3","gravatar_id":"","url":"https://api.github.com/users/abusalimov","html_url":"https://github.com/abusalimov","followers_url":"https://api.github.com/users/abusalimov/followers","following_url":"https://api.github.com/users/abusalimov/following{/other_user}","gists_url":"https://api.github.com/users/abusalimov/gists{/gist_id}","starred_url":"https://api.github.com/users/abusalimov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abusalimov/subscriptions","organizations_url":"https://api.github.com/users/abusalimov/orgs","repos_url":"https://api.github.com/users/abusalimov/repos","events_url":"https://api.github.com/users/abusalimov/events{/privacy}","received_events_url":"https://api.github.com/users/abusalimov/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/embox/embox/pulls/763/commits","review_comments_url":"https://api.github.com/repos/embox/embox/pulls/763/comments","review_comment_url":"https://api.github.com/repos/embox/embox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/embox/embox/issues/763/comments","statuses_url":"https://api.github.com/repos/embox/embox/statuses/212fcfa96bf2777417359d6d65d3ddd5e78336b6","head":{"label":"embox:usb-net","ref":"usb-net","sha":"212fcfa96bf2777417359d6d65d3ddd5e78336b6","user":{"login":"embox","id":9039916,"avatar_url":"https://avatars.githubusercontent.com/u/9039916?v=3","gravatar_id":"","url":"https://api.github.com/users/embox","html_url":"https://github.com/embox","followers_url":"https://api.github.com/users/embox/followers","following_url":"https://api.github.com/users/embox/following{/other_user}","gists_url":"https://api.github.com/users/embox/gists{/gist_id}","starred_url":"https://api.github.com/users/embox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embox/subscriptions","organizations_url":"https://api.github.com/users/embox/orgs","repos_url":"https://api.github.com/users/embox/repos","events_url":"https://api.github.com/users/embox/events{/privacy}","received_events_url":"https://api.github.com/users/embox/received_events","type":"Organization","site_admin":false},"repo":{"id":33078138,"name":"embox","full_name":"embox/embox","owner":{"login":"embox","id":9039916,"avatar_url":"https://avatars.githubusercontent.com/u/9039916?v=3","gravatar_id":"","url":"https://api.github.com/users/embox","html_url":"https://github.com/embox","followers_url":"https://api.github.com/users/embox/followers","following_url":"https://api.github.com/users/embox/following{/other_user}","gists_url":"https://api.github.com/users/embox/gists{/gist_id}","starred_url":"https://api.github.com/users/embox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embox/subscriptions","organizations_url":"https://api.github.com/users/embox/orgs","repos_url":"https://api.github.com/users/embox/repos","events_url":"https://api.github.com/users/embox/events{/privacy}","received_events_url":"https://api.github.com/users/embox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/embox/embox","description":"The OS Kernel","fork":false,"url":"https://api.github.com/repos/embox/embox","forks_url":"https://api.github.com/repos/embox/embox/forks","keys_url":"https://api.github.com/repos/embox/embox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/embox/embox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/embox/embox/teams","hooks_url":"https://api.github.com/repos/embox/embox/hooks","issue_events_url":"https://api.github.com/repos/embox/embox/issues/events{/number}","events_url":"https://api.github.com/repos/embox/embox/events","assignees_url":"https://api.github.com/repos/embox/embox/assignees{/user}","branches_url":"https://api.github.com/repos/embox/embox/branches{/branch}","tags_url":"https://api.github.com/repos/embox/embox/tags","blobs_url":"https://api.github.com/repos/embox/embox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/embox/embox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/embox/embox/git/refs{/sha}","trees_url":"https://api.github.com/repos/embox/embox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/embox/embox/statuses/{sha}","languages_url":"https://api.github.com/repos/embox/embox/languages","stargazers_url":"https://api.github.com/repos/embox/embox/stargazers","contributors_url":"https://api.github.com/repos/embox/embox/contributors","subscribers_url":"https://api.github.com/repos/embox/embox/subscribers","subscription_url":"https://api.github.com/repos/embox/embox/subscription","commits_url":"https://api.github.com/repos/embox/embox/commits{/sha}","git_commits_url":"https://api.github.com/repos/embox/embox/git/commits{/sha}","comments_url":"https://api.github.com/repos/embox/embox/comments{/number}","issue_comment_url":"https://api.github.com/repos/embox/embox/issues/comments{/number}","contents_url":"https://api.github.com/repos/embox/embox/contents/{+path}","compare_url":"https://api.github.com/repos/embox/embox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/embox/embox/merges","archive_url":"https://api.github.com/repos/embox/embox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/embox/embox/downloads","issues_url":"https://api.github.com/repos/embox/embox/issues{/number}","pulls_url":"https://api.github.com/repos/embox/embox/pulls{/number}","milestones_url":"https://api.github.com/repos/embox/embox/milestones{/number}","notifications_url":"https://api.github.com/repos/embox/embox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/embox/embox/labels{/name}","releases_url":"https://api.github.com/repos/embox/embox/releases{/id}","created_at":"2015-03-29T15:27:48Z","updated_at":"2015-05-28T21:43:36Z","pushed_at":"2015-05-31T12:14:09Z","git_url":"git://github.com/embox/embox.git","ssh_url":"git@github.com:embox/embox.git","clone_url":"https://github.com/embox/embox.git","svn_url":"https://github.com/embox/embox","homepage":"","size":32108,"stargazers_count":44,"watchers_count":44,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":79,"forks":11,"open_issues":79,"watchers":44,"default_branch":"master"}},"base":{"label":"embox:master","ref":"master","sha":"e3739c3e589b59cf551f58ff516a2e55de41476f","user":{"login":"embox","id":9039916,"avatar_url":"https://avatars.githubusercontent.com/u/9039916?v=3","gravatar_id":"","url":"https://api.github.com/users/embox","html_url":"https://github.com/embox","followers_url":"https://api.github.com/users/embox/followers","following_url":"https://api.github.com/users/embox/following{/other_user}","gists_url":"https://api.github.com/users/embox/gists{/gist_id}","starred_url":"https://api.github.com/users/embox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embox/subscriptions","organizations_url":"https://api.github.com/users/embox/orgs","repos_url":"https://api.github.com/users/embox/repos","events_url":"https://api.github.com/users/embox/events{/privacy}","received_events_url":"https://api.github.com/users/embox/received_events","type":"Organization","site_admin":false},"repo":{"id":33078138,"name":"embox","full_name":"embox/embox","owner":{"login":"embox","id":9039916,"avatar_url":"https://avatars.githubusercontent.com/u/9039916?v=3","gravatar_id":"","url":"https://api.github.com/users/embox","html_url":"https://github.com/embox","followers_url":"https://api.github.com/users/embox/followers","following_url":"https://api.github.com/users/embox/following{/other_user}","gists_url":"https://api.github.com/users/embox/gists{/gist_id}","starred_url":"https://api.github.com/users/embox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embox/subscriptions","organizations_url":"https://api.github.com/users/embox/orgs","repos_url":"https://api.github.com/users/embox/repos","events_url":"https://api.github.com/users/embox/events{/privacy}","received_events_url":"https://api.github.com/users/embox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/embox/embox","description":"The OS Kernel","fork":false,"url":"https://api.github.com/repos/embox/embox","forks_url":"https://api.github.com/repos/embox/embox/forks","keys_url":"https://api.github.com/repos/embox/embox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/embox/embox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/embox/embox/teams","hooks_url":"https://api.github.com/repos/embox/embox/hooks","issue_events_url":"https://api.github.com/repos/embox/embox/issues/events{/number}","events_url":"https://api.github.com/repos/embox/embox/events","assignees_url":"https://api.github.com/repos/embox/embox/assignees{/user}","branches_url":"https://api.github.com/repos/embox/embox/branches{/branch}","tags_url":"https://api.github.com/repos/embox/embox/tags","blobs_url":"https://api.github.com/repos/embox/embox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/embox/embox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/embox/embox/git/refs{/sha}","trees_url":"https://api.github.com/repos/embox/embox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/embox/embox/statuses/{sha}","languages_url":"https://api.github.com/repos/embox/embox/languages","stargazers_url":"https://api.github.com/repos/embox/embox/stargazers","contributors_url":"https://api.github.com/repos/embox/embox/contributors","subscribers_url":"https://api.github.com/repos/embox/embox/subscribers","subscription_url":"https://api.github.com/repos/embox/embox/subscription","commits_url":"https://api.github.com/repos/embox/embox/commits{/sha}","git_commits_url":"https://api.github.com/repos/embox/embox/git/commits{/sha}","comments_url":"https://api.github.com/repos/embox/embox/comments{/number}","issue_comment_url":"https://api.github.com/repos/embox/embox/issues/comments{/number}","contents_url":"https://api.github.com/repos/embox/embox/contents/{+path}","compare_url":"https://api.github.com/repos/embox/embox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/embox/embox/merges","archive_url":"https://api.github.com/repos/embox/embox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/embox/embox/downloads","issues_url":"https://api.github.com/repos/embox/embox/issues{/number}","pulls_url":"https://api.github.com/repos/embox/embox/pulls{/number}","milestones_url":"https://api.github.com/repos/embox/embox/milestones{/number}","notifications_url":"https://api.github.com/repos/embox/embox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/embox/embox/labels{/name}","releases_url":"https://api.github.com/repos/embox/embox/releases{/id}","created_at":"2015-03-29T15:27:48Z","updated_at":"2015-05-28T21:43:36Z","pushed_at":"2015-05-31T12:14:09Z","git_url":"git://github.com/embox/embox.git","ssh_url":"git@github.com:embox/embox.git","clone_url":"https://github.com/embox/embox.git","svn_url":"https://github.com/embox/embox","homepage":"","size":32108,"stargazers_count":44,"watchers_count":44,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":79,"forks":11,"open_issues":79,"watchers":44,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/embox/embox/pulls/763"},"html":{"href":"https://github.com/embox/embox/pull/763"},"issue":{"href":"https://api.github.com/repos/embox/embox/issues/763"},"comments":{"href":"https://api.github.com/repos/embox/embox/issues/763/comments"},"review_comments":{"href":"https://api.github.com/repos/embox/embox/pulls/763/comments"},"review_comment":{"href":"https://api.github.com/repos/embox/embox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/embox/embox/pulls/763/commits"},"statuses":{"href":"https://api.github.com/repos/embox/embox/statuses/212fcfa96bf2777417359d6d65d3ddd5e78336b6"}}}}