{"action":"created","comment":{"url":"https://api.github.com/repos/solettaproject/soletta/pulls/comments/74801054","id":74801054,"diff_hunk":"@@ -802,34 +812,113 @@ observer_entry_del_monitor(struct observer_entry *entry,\n }\n \n SOL_API struct sol_lwm2m_server *\n-sol_lwm2m_server_new(uint16_t port)\n+sol_lwm2m_server_new(uint16_t coap_port, uint16_t dtls_port,\n+    enum sol_lwm2m_security_mode sec_mode, struct sol_vector *known_psks)\n {\n     struct sol_lwm2m_server *server;\n-    struct sol_network_link_addr servaddr = { .family = SOL_NETWORK_FAMILY_INET6,\n-                                              .port = port };\n+    struct sol_network_link_addr servaddr_coap = { .family = SOL_NETWORK_FAMILY_INET6,\n+                                                   .port = coap_port };\n+    struct sol_network_link_addr servaddr_dtls = { .family = SOL_NETWORK_FAMILY_INET6,\n+                                                   .port = dtls_port };\n     int r;\n+    const char *sec_mode_str;\n+    struct sol_lwm2m_security_psk *psk, *given_psk;\n+    uint16_t i;\n \n     SOL_LOG_INTERNAL_INIT_ONCE;\n \n+    switch (sec_mode) {\n+    case SOL_LWM2M_SECURITY_MODE_PRE_SHARED_KEY:\n+        SOL_NULL_CHECK(known_psks, NULL);\n+        sec_mode_str = \"Pre-Shared Key\";\n+        break;\n+    case SOL_LWM2M_SECURITY_MODE_RAW_PUBLIC_KEY:\n+        sec_mode_str = \"Raw Public Key\";\n+        SOL_WRN(\"Raw Public Key security mode is not supported yet.\");\n+        return NULL;\n+    case SOL_LWM2M_SECURITY_MODE_CERTIFICATE:\n+        sec_mode_str = \"Certificate\";\n+        SOL_WRN(\"Certificate security mode is not supported yet.\");\n+        return NULL;\n+    case SOL_LWM2M_SECURITY_MODE_NO_SEC:\n+        sec_mode_str = \"NoSec\";\n+        SOL_DBG(\"Using NoSec Security Mode (No DTLS).\");\n+        break;\n+    default:\n+        SOL_WRN(\"Unknown DTLS Security Mode: %d\", sec_mode);\n+        return NULL;\n+    }\n+\n     server = calloc(1, sizeof(struct sol_lwm2m_server));\n     SOL_NULL_CHECK(server, NULL);\n \n-    server->coap = sol_coap_server_new(&servaddr, false);\n+    server->coap = sol_coap_server_new(&servaddr_coap, false);\n     SOL_NULL_CHECK_GOTO(server->coap, err_coap);\n \n+    if (sec_mode != SOL_LWM2M_SECURITY_MODE_NO_SEC) {\n+        if (sec_mode == SOL_LWM2M_SECURITY_MODE_PRE_SHARED_KEY) {\n+            sol_vector_init(&server->known_psks, sizeof(sol_lwm2m_security_psk));\n+\n+            SOL_VECTOR_FOREACH_IDX (known_psks, given_psk, i) {\n+                psk = sol_vector_append(&server->known_psks);\n+                SOL_NULL_CHECK_GOTO(psk, err_psk);\n+                psk->id = sol_blob_ref(given_psk->id);\n+                psk->key = sol_blob_ref(given_psk->key);\n+            }\n+        }\n+\n+        server->dtls_server = sol_coap_server_new(&servaddr_dtls, true);\n+        SOL_NULL_CHECK_GOTO(server->dtls_server, err_dtls);\n+\n+        server->security = sol_lwm2m_server_security_add(server, sec_mode);\n+        if (!server->security) {","path":"src/lib/comms/sol-lwm2m-server.c","position":153,"original_position":142,"commit_id":"6557fa57f2c70f350eb8351659753f3dd5d8c24c","original_commit_id":"17ab62e0507ccd9a28ea7e1c8afa5d0342c9ee6a","user":{"login":"cabelitos","id":984610,"avatar_url":"https://avatars.githubusercontent.com/u/984610?v=3","gravatar_id":"","url":"https://api.github.com/users/cabelitos","html_url":"https://github.com/cabelitos","followers_url":"https://api.github.com/users/cabelitos/followers","following_url":"https://api.github.com/users/cabelitos/following{/other_user}","gists_url":"https://api.github.com/users/cabelitos/gists{/gist_id}","starred_url":"https://api.github.com/users/cabelitos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cabelitos/subscriptions","organizations_url":"https://api.github.com/users/cabelitos/orgs","repos_url":"https://api.github.com/users/cabelitos/repos","events_url":"https://api.github.com/users/cabelitos/events{/privacy}","received_events_url":"https://api.github.com/users/cabelitos/received_events","type":"User","site_admin":false},"body":"SOL_NULL_CHECK_GOTO(server->security, err_dtls)","created_at":"2016-08-15T17:43:28Z","updated_at":"2016-08-15T17:43:28Z","html_url":"https://github.com/solettaproject/soletta/pull/2285#discussion_r74801054","pull_request_url":"https://api.github.com/repos/solettaproject/soletta/pulls/2285","_links":{"self":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/comments/74801054"},"html":{"href":"https://github.com/solettaproject/soletta/pull/2285#discussion_r74801054"},"pull_request":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2285"}}},"pull_request":{"url":"https://api.github.com/repos/solettaproject/soletta/pulls/2285","id":81045021,"html_url":"https://github.com/solettaproject/soletta/pull/2285","diff_url":"https://github.com/solettaproject/soletta/pull/2285.diff","patch_url":"https://github.com/solettaproject/soletta/pull/2285.patch","issue_url":"https://api.github.com/repos/solettaproject/soletta/issues/2285","number":2285,"state":"open","locked":false,"title":"LWM2M: Support for DTLS with Pre-Shared Key security mode [v2]","user":{"login":"bsmelo","id":15204241,"avatar_url":"https://avatars.githubusercontent.com/u/15204241?v=3","gravatar_id":"","url":"https://api.github.com/users/bsmelo","html_url":"https://github.com/bsmelo","followers_url":"https://api.github.com/users/bsmelo/followers","following_url":"https://api.github.com/users/bsmelo/following{/other_user}","gists_url":"https://api.github.com/users/bsmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmelo/subscriptions","organizations_url":"https://api.github.com/users/bsmelo/orgs","repos_url":"https://api.github.com/users/bsmelo/repos","events_url":"https://api.github.com/users/bsmelo/events{/privacy}","received_events_url":"https://api.github.com/users/bsmelo/received_events","type":"User","site_admin":false},"body":"Main changes since v1 (#2272):\r\nhttps://github.com/solettaproject/soletta/pull/2272#discussion-diff-74065997\r\nhttps://github.com/solettaproject/soletta/pull/2272#discussion-diff-73922416\r\n\r\nThis patch depends on #2283.\r\n_**Edit**: Depends on #2288 as well._\r\n\r\nSigned-off-by: Bruno Melo bsilva.melo@gmail.com","created_at":"2016-08-11T22:57:43Z","updated_at":"2016-08-15T17:43:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2412d14d202bf91131ab634230a23784cd795740","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/solettaproject/soletta/pulls/2285/commits","review_comments_url":"https://api.github.com/repos/solettaproject/soletta/pulls/2285/comments","review_comment_url":"https://api.github.com/repos/solettaproject/soletta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solettaproject/soletta/issues/2285/comments","statuses_url":"https://api.github.com/repos/solettaproject/soletta/statuses/6557fa57f2c70f350eb8351659753f3dd5d8c24c","head":{"label":"bsmelo:lwm2m-dtls_psk-v2","ref":"lwm2m-dtls_psk-v2","sha":"6557fa57f2c70f350eb8351659753f3dd5d8c24c","user":{"login":"bsmelo","id":15204241,"avatar_url":"https://avatars.githubusercontent.com/u/15204241?v=3","gravatar_id":"","url":"https://api.github.com/users/bsmelo","html_url":"https://github.com/bsmelo","followers_url":"https://api.github.com/users/bsmelo/followers","following_url":"https://api.github.com/users/bsmelo/following{/other_user}","gists_url":"https://api.github.com/users/bsmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmelo/subscriptions","organizations_url":"https://api.github.com/users/bsmelo/orgs","repos_url":"https://api.github.com/users/bsmelo/repos","events_url":"https://api.github.com/users/bsmelo/events{/privacy}","received_events_url":"https://api.github.com/users/bsmelo/received_events","type":"User","site_admin":false},"repo":{"id":54440906,"name":"soletta","full_name":"bsmelo/soletta","owner":{"login":"bsmelo","id":15204241,"avatar_url":"https://avatars.githubusercontent.com/u/15204241?v=3","gravatar_id":"","url":"https://api.github.com/users/bsmelo","html_url":"https://github.com/bsmelo","followers_url":"https://api.github.com/users/bsmelo/followers","following_url":"https://api.github.com/users/bsmelo/following{/other_user}","gists_url":"https://api.github.com/users/bsmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmelo/subscriptions","organizations_url":"https://api.github.com/users/bsmelo/orgs","repos_url":"https://api.github.com/users/bsmelo/repos","events_url":"https://api.github.com/users/bsmelo/events{/privacy}","received_events_url":"https://api.github.com/users/bsmelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bsmelo/soletta","description":"Soletta Project is a framework for making IoT devices.  With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.  ","fork":true,"url":"https://api.github.com/repos/bsmelo/soletta","forks_url":"https://api.github.com/repos/bsmelo/soletta/forks","keys_url":"https://api.github.com/repos/bsmelo/soletta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bsmelo/soletta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bsmelo/soletta/teams","hooks_url":"https://api.github.com/repos/bsmelo/soletta/hooks","issue_events_url":"https://api.github.com/repos/bsmelo/soletta/issues/events{/number}","events_url":"https://api.github.com/repos/bsmelo/soletta/events","assignees_url":"https://api.github.com/repos/bsmelo/soletta/assignees{/user}","branches_url":"https://api.github.com/repos/bsmelo/soletta/branches{/branch}","tags_url":"https://api.github.com/repos/bsmelo/soletta/tags","blobs_url":"https://api.github.com/repos/bsmelo/soletta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bsmelo/soletta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bsmelo/soletta/git/refs{/sha}","trees_url":"https://api.github.com/repos/bsmelo/soletta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bsmelo/soletta/statuses/{sha}","languages_url":"https://api.github.com/repos/bsmelo/soletta/languages","stargazers_url":"https://api.github.com/repos/bsmelo/soletta/stargazers","contributors_url":"https://api.github.com/repos/bsmelo/soletta/contributors","subscribers_url":"https://api.github.com/repos/bsmelo/soletta/subscribers","subscription_url":"https://api.github.com/repos/bsmelo/soletta/subscription","commits_url":"https://api.github.com/repos/bsmelo/soletta/commits{/sha}","git_commits_url":"https://api.github.com/repos/bsmelo/soletta/git/commits{/sha}","comments_url":"https://api.github.com/repos/bsmelo/soletta/comments{/number}","issue_comment_url":"https://api.github.com/repos/bsmelo/soletta/issues/comments{/number}","contents_url":"https://api.github.com/repos/bsmelo/soletta/contents/{+path}","compare_url":"https://api.github.com/repos/bsmelo/soletta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bsmelo/soletta/merges","archive_url":"https://api.github.com/repos/bsmelo/soletta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bsmelo/soletta/downloads","issues_url":"https://api.github.com/repos/bsmelo/soletta/issues{/number}","pulls_url":"https://api.github.com/repos/bsmelo/soletta/pulls{/number}","milestones_url":"https://api.github.com/repos/bsmelo/soletta/milestones{/number}","notifications_url":"https://api.github.com/repos/bsmelo/soletta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bsmelo/soletta/labels{/name}","releases_url":"https://api.github.com/repos/bsmelo/soletta/releases{/id}","deployments_url":"https://api.github.com/repos/bsmelo/soletta/deployments","created_at":"2016-03-22T03:04:07Z","updated_at":"2016-03-22T03:04:11Z","pushed_at":"2016-08-15T16:58:17Z","git_url":"git://github.com/bsmelo/soletta.git","ssh_url":"git@github.com:bsmelo/soletta.git","clone_url":"https://github.com/bsmelo/soletta.git","svn_url":"https://github.com/bsmelo/soletta","homepage":"http://solettaproject.org","size":22020,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"solettaproject:master","ref":"master","sha":"a41df87118a5c528883fef450948bdefca05d54b","user":{"login":"solettaproject","id":12736897,"avatar_url":"https://avatars.githubusercontent.com/u/12736897?v=3","gravatar_id":"","url":"https://api.github.com/users/solettaproject","html_url":"https://github.com/solettaproject","followers_url":"https://api.github.com/users/solettaproject/followers","following_url":"https://api.github.com/users/solettaproject/following{/other_user}","gists_url":"https://api.github.com/users/solettaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/solettaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solettaproject/subscriptions","organizations_url":"https://api.github.com/users/solettaproject/orgs","repos_url":"https://api.github.com/users/solettaproject/repos","events_url":"https://api.github.com/users/solettaproject/events{/privacy}","received_events_url":"https://api.github.com/users/solettaproject/received_events","type":"Organization","site_admin":false},"repo":{"id":37087063,"name":"soletta","full_name":"solettaproject/soletta","owner":{"login":"solettaproject","id":12736897,"avatar_url":"https://avatars.githubusercontent.com/u/12736897?v=3","gravatar_id":"","url":"https://api.github.com/users/solettaproject","html_url":"https://github.com/solettaproject","followers_url":"https://api.github.com/users/solettaproject/followers","following_url":"https://api.github.com/users/solettaproject/following{/other_user}","gists_url":"https://api.github.com/users/solettaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/solettaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solettaproject/subscriptions","organizations_url":"https://api.github.com/users/solettaproject/orgs","repos_url":"https://api.github.com/users/solettaproject/repos","events_url":"https://api.github.com/users/solettaproject/events{/privacy}","received_events_url":"https://api.github.com/users/solettaproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solettaproject/soletta","description":"Soletta Project is a framework for making IoT devices.  With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.  ","fork":false,"url":"https://api.github.com/repos/solettaproject/soletta","forks_url":"https://api.github.com/repos/solettaproject/soletta/forks","keys_url":"https://api.github.com/repos/solettaproject/soletta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solettaproject/soletta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solettaproject/soletta/teams","hooks_url":"https://api.github.com/repos/solettaproject/soletta/hooks","issue_events_url":"https://api.github.com/repos/solettaproject/soletta/issues/events{/number}","events_url":"https://api.github.com/repos/solettaproject/soletta/events","assignees_url":"https://api.github.com/repos/solettaproject/soletta/assignees{/user}","branches_url":"https://api.github.com/repos/solettaproject/soletta/branches{/branch}","tags_url":"https://api.github.com/repos/solettaproject/soletta/tags","blobs_url":"https://api.github.com/repos/solettaproject/soletta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solettaproject/soletta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solettaproject/soletta/git/refs{/sha}","trees_url":"https://api.github.com/repos/solettaproject/soletta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solettaproject/soletta/statuses/{sha}","languages_url":"https://api.github.com/repos/solettaproject/soletta/languages","stargazers_url":"https://api.github.com/repos/solettaproject/soletta/stargazers","contributors_url":"https://api.github.com/repos/solettaproject/soletta/contributors","subscribers_url":"https://api.github.com/repos/solettaproject/soletta/subscribers","subscription_url":"https://api.github.com/repos/solettaproject/soletta/subscription","commits_url":"https://api.github.com/repos/solettaproject/soletta/commits{/sha}","git_commits_url":"https://api.github.com/repos/solettaproject/soletta/git/commits{/sha}","comments_url":"https://api.github.com/repos/solettaproject/soletta/comments{/number}","issue_comment_url":"https://api.github.com/repos/solettaproject/soletta/issues/comments{/number}","contents_url":"https://api.github.com/repos/solettaproject/soletta/contents/{+path}","compare_url":"https://api.github.com/repos/solettaproject/soletta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solettaproject/soletta/merges","archive_url":"https://api.github.com/repos/solettaproject/soletta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solettaproject/soletta/downloads","issues_url":"https://api.github.com/repos/solettaproject/soletta/issues{/number}","pulls_url":"https://api.github.com/repos/solettaproject/soletta/pulls{/number}","milestones_url":"https://api.github.com/repos/solettaproject/soletta/milestones{/number}","notifications_url":"https://api.github.com/repos/solettaproject/soletta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solettaproject/soletta/labels{/name}","releases_url":"https://api.github.com/repos/solettaproject/soletta/releases{/id}","deployments_url":"https://api.github.com/repos/solettaproject/soletta/deployments","created_at":"2015-06-08T19:13:18Z","updated_at":"2016-08-11T12:40:07Z","pushed_at":"2016-08-15T16:58:17Z","git_url":"git://github.com/solettaproject/soletta.git","ssh_url":"git@github.com:solettaproject/soletta.git","clone_url":"https://github.com/solettaproject/soletta.git","svn_url":"https://github.com/solettaproject/soletta","homepage":"http://solettaproject.org","size":31008,"stargazers_count":119,"watchers_count":119,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":92,"mirror_url":null,"open_issues_count":107,"forks":92,"open_issues":107,"watchers":119,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2285"},"html":{"href":"https://github.com/solettaproject/soletta/pull/2285"},"issue":{"href":"https://api.github.com/repos/solettaproject/soletta/issues/2285"},"comments":{"href":"https://api.github.com/repos/solettaproject/soletta/issues/2285/comments"},"review_comments":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2285/comments"},"review_comment":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2285/commits"},"statuses":{"href":"https://api.github.com/repos/solettaproject/soletta/statuses/6557fa57f2c70f350eb8351659753f3dd5d8c24c"}}}}
{"actor":{"display_login":"cabelitos"}}