diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-09-29 13:27:13 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-09-29 13:27:13 +0000 |
commit | de1969aa7d4214c5218d3a1bf932b95ed95efe0d (patch) | |
tree | 2b1ed9a6c0d562c0163d3055b93a453502ce4460 /src/identity-provider | |
parent | 22af28fc22725c597831367fa3742070dfa449a8 (diff) | |
download | gnunet-de1969aa7d4214c5218d3a1bf932b95ed95efe0d.tar.gz gnunet-de1969aa7d4214c5218d3a1bf932b95ed95efe0d.zip |
-new service API
Diffstat (limited to 'src/identity-provider')
-rw-r--r-- | src/identity-provider/gnunet-service-identity-provider.c | 275 | ||||
-rw-r--r-- | src/identity-provider/identity_provider.h | 8 | ||||
-rw-r--r-- | src/identity-provider/identity_provider_api.c | 28 |
3 files changed, 168 insertions, 143 deletions
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index a97955aa6..d72b92c0f 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c | |||
@@ -149,11 +149,6 @@ static struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_privkey; | |||
149 | static struct GNUNET_STATISTICS_Handle *stats; | 149 | static struct GNUNET_STATISTICS_Handle *stats; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Notification context, simplifies client broadcasts. | ||
153 | */ | ||
154 | static struct GNUNET_SERVER_NotificationContext *nc; | ||
155 | |||
156 | /** | ||
157 | * Our configuration. | 152 | * Our configuration. |
158 | */ | 153 | */ |
159 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 154 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -165,7 +160,7 @@ struct ExchangeHandle | |||
165 | /** | 160 | /** |
166 | * Client connection | 161 | * Client connection |
167 | */ | 162 | */ |
168 | struct GNUNET_SERVER_Client *client; | 163 | struct GNUNET_SERVICE_Client *client; |
169 | 164 | ||
170 | /** | 165 | /** |
171 | * Ticket | 166 | * Ticket |
@@ -204,7 +199,7 @@ struct IssueHandle | |||
204 | /** | 199 | /** |
205 | * Client connection | 200 | * Client connection |
206 | */ | 201 | */ |
207 | struct GNUNET_SERVER_Client *client; | 202 | struct GNUNET_SERVICE_Client *client; |
208 | 203 | ||
209 | /** | 204 | /** |
210 | * Issuer Key | 205 | * Issuer Key |
@@ -867,11 +862,6 @@ cleanup() | |||
867 | 862 | ||
868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
869 | "Cleaning up\n"); | 864 | "Cleaning up\n"); |
870 | if (NULL != nc) | ||
871 | { | ||
872 | GNUNET_SERVER_notification_context_destroy (nc); | ||
873 | nc = NULL; | ||
874 | } | ||
875 | if (NULL != stats) | 865 | if (NULL != stats) |
876 | { | 866 | { |
877 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 867 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
@@ -929,45 +919,46 @@ do_shutdown (void *cls) | |||
929 | } | 919 | } |
930 | 920 | ||
931 | 921 | ||
932 | static struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage* | 922 | static struct GNUNET_MQ_Envelope* |
933 | create_exchange_result_message (const char* token, | 923 | create_exchange_result_message (const char* token, |
934 | const char* label, | 924 | const char* label, |
935 | uint64_t ticket_nonce) | 925 | uint64_t ticket_nonce, |
926 | uint64_t id) | ||
936 | { | 927 | { |
937 | struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage *erm; | 928 | struct GNUNET_MQ_Envelope *env; |
929 | struct ExchangeResultMessage *erm; | ||
938 | uint16_t token_len = strlen (token) + 1; | 930 | uint16_t token_len = strlen (token) + 1; |
939 | erm = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage) | 931 | |
940 | + token_len); | 932 | env = GNUNET_MQ_msg_extra (erm, |
941 | erm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT); | 933 | token_len, |
942 | erm->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage) | 934 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT); |
943 | + token_len); | ||
944 | erm->ticket_nonce = htonl (ticket_nonce); | 935 | erm->ticket_nonce = htonl (ticket_nonce); |
936 | erm->id = id; | ||
945 | GNUNET_memcpy (&erm[1], token, token_len); | 937 | GNUNET_memcpy (&erm[1], token, token_len); |
946 | return erm; | 938 | return env; |
947 | } | 939 | } |
948 | 940 | ||
949 | 941 | ||
950 | static struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage* | 942 | static struct GNUNET_MQ_Envelope* |
951 | create_issue_result_message (const char* label, | 943 | create_issue_result_message (const char* label, |
952 | const char* ticket, | 944 | const char* ticket, |
953 | const char* token) | 945 | const char* token, |
946 | uint64_t id) | ||
954 | { | 947 | { |
955 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm; | 948 | struct GNUNET_MQ_Envelope *env; |
949 | struct IssueResultMessage *irm; | ||
956 | char *tmp_str; | 950 | char *tmp_str; |
957 | 951 | size_t len; | |
958 | irm = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage) | 952 | |
959 | + strlen (label) + 1 | ||
960 | + strlen (ticket) + 1 | ||
961 | + strlen (token) + 1); | ||
962 | irm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_RESULT); | ||
963 | irm->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage) | ||
964 | + strlen (label) + 1 | ||
965 | + strlen (ticket) + 1 | ||
966 | + strlen (token) + 1); | ||
967 | GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token); | 953 | GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token); |
954 | len = strlen (tmp_str) + 1; | ||
955 | env = GNUNET_MQ_msg_extra (irm, | ||
956 | len, | ||
957 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_RESULT); | ||
958 | irm->id = id; | ||
968 | GNUNET_memcpy (&irm[1], tmp_str, strlen (tmp_str) + 1); | 959 | GNUNET_memcpy (&irm[1], tmp_str, strlen (tmp_str) + 1); |
969 | GNUNET_free (tmp_str); | 960 | GNUNET_free (tmp_str); |
970 | return irm; | 961 | return env; |
971 | } | 962 | } |
972 | 963 | ||
973 | static void | 964 | static void |
@@ -992,7 +983,7 @@ store_token_issue_cont (void *cls, | |||
992 | const char *emsg) | 983 | const char *emsg) |
993 | { | 984 | { |
994 | struct IssueHandle *handle = cls; | 985 | struct IssueHandle *handle = cls; |
995 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm; | 986 | struct GNUNET_MQ_Envelope *env; |
996 | char *ticket_str; | 987 | char *ticket_str; |
997 | char *token_str; | 988 | char *token_str; |
998 | 989 | ||
@@ -1026,17 +1017,13 @@ store_token_issue_cont (void *cls, | |||
1026 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1017 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1027 | return; | 1018 | return; |
1028 | } | 1019 | } |
1029 | irm = create_issue_result_message (handle->label, | 1020 | env = create_issue_result_message (handle->label, |
1030 | ticket_str, | 1021 | ticket_str, |
1031 | token_str); | 1022 | token_str, |
1032 | irm->id = handle->r_id; | 1023 | handle->r_id); |
1033 | GNUNET_SERVER_notification_context_unicast (nc, | 1024 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(handle->client), |
1034 | handle->client, | 1025 | env); |
1035 | &irm->header, | ||
1036 | GNUNET_NO); | ||
1037 | GNUNET_SERVER_client_set_user_context (handle->client, NULL); | ||
1038 | cleanup_issue_handle (handle); | 1026 | cleanup_issue_handle (handle); |
1039 | GNUNET_free (irm); | ||
1040 | GNUNET_free (ticket_str); | 1027 | GNUNET_free (ticket_str); |
1041 | GNUNET_free (token_str); | 1028 | GNUNET_free (token_str); |
1042 | } | 1029 | } |
@@ -1231,7 +1218,7 @@ process_lookup_result (void *cls, uint32_t rd_count, | |||
1231 | const struct GNUNET_GNSRECORD_Data *rd) | 1218 | const struct GNUNET_GNSRECORD_Data *rd) |
1232 | { | 1219 | { |
1233 | struct ExchangeHandle *handle = cls; | 1220 | struct ExchangeHandle *handle = cls; |
1234 | struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage *erm; | 1221 | struct GNUNET_MQ_Envelope *env; |
1235 | char* token_str; | 1222 | char* token_str; |
1236 | char* record_str; | 1223 | char* record_str; |
1237 | 1224 | ||
@@ -1261,24 +1248,38 @@ process_lookup_result (void *cls, uint32_t rd_count, | |||
1261 | &handle->aud_privkey, | 1248 | &handle->aud_privkey, |
1262 | &token_str)); | 1249 | &token_str)); |
1263 | 1250 | ||
1264 | erm = create_exchange_result_message (token_str, | 1251 | env = create_exchange_result_message (token_str, |
1265 | handle->label, | 1252 | handle->label, |
1266 | handle->ticket->payload->nonce); | 1253 | handle->ticket->payload->nonce, |
1267 | erm->id = handle->r_id; | 1254 | handle->r_id); |
1268 | GNUNET_SERVER_notification_context_unicast (nc, | 1255 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(handle->client), |
1269 | handle->client, | 1256 | env); |
1270 | &erm->header, | ||
1271 | GNUNET_NO); | ||
1272 | GNUNET_SERVER_client_set_user_context (handle->client, NULL); | ||
1273 | |||
1274 | cleanup_exchange_handle (handle); | 1257 | cleanup_exchange_handle (handle); |
1275 | GNUNET_free (record_str); | 1258 | GNUNET_free (record_str); |
1276 | GNUNET_free (token_str); | 1259 | GNUNET_free (token_str); |
1277 | GNUNET_free (erm); | ||
1278 | |||
1279 | } | 1260 | } |
1280 | 1261 | ||
1262 | /** | ||
1263 | * Checks a exchange message | ||
1264 | * | ||
1265 | * @param cls client sending the message | ||
1266 | * @param xm message of type `struct ExchangeMessage` | ||
1267 | * @return #GNUNET_OK if @a xm is well-formed | ||
1268 | */ | ||
1269 | static int | ||
1270 | check_exchange_message (void *cls, | ||
1271 | const struct ExchangeMessage *xm) | ||
1272 | { | ||
1273 | uint16_t size; | ||
1281 | 1274 | ||
1275 | size = ntohs (xm->header.size); | ||
1276 | if (size <= sizeof (struct ExchangeMessage)) | ||
1277 | { | ||
1278 | GNUNET_break (0); | ||
1279 | return GNUNET_SYSERR; | ||
1280 | } | ||
1281 | return GNUNET_OK; | ||
1282 | } | ||
1282 | 1283 | ||
1283 | /** | 1284 | /** |
1284 | * | 1285 | * |
@@ -1290,37 +1291,26 @@ process_lookup_result (void *cls, uint32_t rd_count, | |||
1290 | */ | 1291 | */ |
1291 | static void | 1292 | static void |
1292 | handle_exchange_message (void *cls, | 1293 | handle_exchange_message (void *cls, |
1293 | struct GNUNET_SERVER_Client *client, | 1294 | const struct ExchangeMessage *xm) |
1294 | const struct GNUNET_MessageHeader *message) | ||
1295 | { | 1295 | { |
1296 | const struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage *em; | ||
1297 | struct ExchangeHandle *xchange_handle; | 1296 | struct ExchangeHandle *xchange_handle; |
1298 | uint16_t size; | 1297 | struct GNUNET_SERVICE_Client *client = cls; |
1299 | const char *ticket; | 1298 | const char *ticket; |
1300 | char *lookup_query; | 1299 | char *lookup_query; |
1301 | 1300 | ||
1302 | size = ntohs (message->size); | 1301 | ticket = (const char *) &xm[1]; |
1303 | if (size <= sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage)) | ||
1304 | { | ||
1305 | GNUNET_break (0); | ||
1306 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1307 | return; | ||
1308 | } | ||
1309 | em = (const struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage *) message; | ||
1310 | ticket = (const char *) &em[1]; | ||
1311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1312 | "Received EXCHANGE of `%s' from client\n", | 1303 | "Received EXCHANGE of `%s' from client\n", |
1313 | ticket); | 1304 | ticket); |
1314 | xchange_handle = GNUNET_malloc (sizeof (struct ExchangeHandle)); | 1305 | xchange_handle = GNUNET_malloc (sizeof (struct ExchangeHandle)); |
1315 | xchange_handle->aud_privkey = em->aud_privkey; | 1306 | xchange_handle->aud_privkey = xm->aud_privkey; |
1316 | xchange_handle->r_id = em->id; | 1307 | xchange_handle->r_id = xm->id; |
1317 | if (GNUNET_SYSERR == ticket_parse (ticket, | 1308 | if (GNUNET_SYSERR == ticket_parse (ticket, |
1318 | &xchange_handle->aud_privkey, | 1309 | &xchange_handle->aud_privkey, |
1319 | &xchange_handle->ticket)) | 1310 | &xchange_handle->ticket)) |
1320 | { | 1311 | { |
1321 | GNUNET_free (xchange_handle); | 1312 | GNUNET_free (xchange_handle); |
1322 | GNUNET_SERVER_receive_done (client, | 1313 | GNUNET_SERVICE_client_drop (client); |
1323 | GNUNET_SYSERR); | ||
1324 | return; | 1314 | return; |
1325 | } | 1315 | } |
1326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for token under %s\n", | 1316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for token under %s\n", |
@@ -1328,10 +1318,7 @@ handle_exchange_message (void *cls, | |||
1328 | GNUNET_asprintf (&lookup_query, | 1318 | GNUNET_asprintf (&lookup_query, |
1329 | "%s.gnu", | 1319 | "%s.gnu", |
1330 | xchange_handle->ticket->payload->label); | 1320 | xchange_handle->ticket->payload->label); |
1331 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1321 | GNUNET_SERVICE_client_continue (client); |
1332 | GNUNET_SERVER_notification_context_add (nc, client); | ||
1333 | GNUNET_SERVER_client_set_user_context (client, | ||
1334 | xchange_handle); | ||
1335 | xchange_handle->client = client; | 1322 | xchange_handle->client = client; |
1336 | xchange_handle->lookup_request | 1323 | xchange_handle->lookup_request |
1337 | = GNUNET_GNS_lookup (gns_handle, | 1324 | = GNUNET_GNS_lookup (gns_handle, |
@@ -1500,6 +1487,35 @@ find_existing_token (void *cls, | |||
1500 | GNUNET_NAMESTORE_zone_iterator_next (handle->ns_it); | 1487 | GNUNET_NAMESTORE_zone_iterator_next (handle->ns_it); |
1501 | } | 1488 | } |
1502 | 1489 | ||
1490 | /** | ||
1491 | * Checks an issue message | ||
1492 | * | ||
1493 | * @param cls client sending the message | ||
1494 | * @param im message of type `struct IssueMessage` | ||
1495 | * @return #GNUNET_OK if @a im is well-formed | ||
1496 | */ | ||
1497 | static int | ||
1498 | check_issue_message(void *cls, | ||
1499 | const struct IssueMessage *im) | ||
1500 | { | ||
1501 | uint16_t size; | ||
1502 | |||
1503 | size = ntohs (im->header.size); | ||
1504 | if (size <= sizeof (struct IssueMessage)) | ||
1505 | { | ||
1506 | GNUNET_break (0); | ||
1507 | return GNUNET_SYSERR; | ||
1508 | } | ||
1509 | scopes = (char *) &im[1]; | ||
1510 | if ('\0' != scopes[size - sizeof (struct IssueMessage) - 1]) | ||
1511 | { | ||
1512 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1513 | "Malformed scopes received!\n"); | ||
1514 | GNUNET_break (0); | ||
1515 | return GNUNET_SYSERR; | ||
1516 | } | ||
1517 | return GNUNET_OK; | ||
1518 | } | ||
1503 | 1519 | ||
1504 | /** | 1520 | /** |
1505 | * | 1521 | * |
@@ -1511,36 +1527,16 @@ find_existing_token (void *cls, | |||
1511 | */ | 1527 | */ |
1512 | static void | 1528 | static void |
1513 | handle_issue_message (void *cls, | 1529 | handle_issue_message (void *cls, |
1514 | struct GNUNET_SERVER_Client *client, | 1530 | const struct IssueMessage *im) |
1515 | const struct GNUNET_MessageHeader *message) | ||
1516 | { | 1531 | { |
1517 | const struct GNUNET_IDENTITY_PROVIDER_IssueMessage *im; | ||
1518 | const char *scopes; | 1532 | const char *scopes; |
1519 | |||
1520 | uint16_t size; | ||
1521 | char *scopes_tmp; | 1533 | char *scopes_tmp; |
1522 | char *scope; | 1534 | char *scope; |
1523 | struct GNUNET_HashCode key; | 1535 | struct GNUNET_HashCode key; |
1524 | struct IssueHandle *issue_handle; | 1536 | struct IssueHandle *issue_handle; |
1537 | struct GNUNET_SERVICE_Client *client = cls; | ||
1525 | 1538 | ||
1526 | size = ntohs (message->size); | ||
1527 | if (size <= sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueMessage)) | ||
1528 | { | ||
1529 | GNUNET_break (0); | ||
1530 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1531 | return; | ||
1532 | } | ||
1533 | im = (const struct GNUNET_IDENTITY_PROVIDER_IssueMessage *) message; | ||
1534 | scopes = (const char *) &im[1]; | 1539 | scopes = (const char *) &im[1]; |
1535 | if ('\0' != scopes[size - sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueMessage) - 1]) | ||
1536 | { | ||
1537 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1538 | "Malformed scopes received!\n"); | ||
1539 | GNUNET_break (0); | ||
1540 | GNUNET_SERVER_receive_done (client, | ||
1541 | GNUNET_SYSERR); | ||
1542 | return; | ||
1543 | } | ||
1544 | issue_handle = GNUNET_malloc (sizeof (struct IssueHandle)); | 1540 | issue_handle = GNUNET_malloc (sizeof (struct IssueHandle)); |
1545 | issue_handle->attr_map = GNUNET_CONTAINER_multihashmap_create (5, | 1541 | issue_handle->attr_map = GNUNET_CONTAINER_multihashmap_create (5, |
1546 | GNUNET_NO); | 1542 | GNUNET_NO); |
@@ -1564,9 +1560,7 @@ handle_issue_message (void *cls, | |||
1564 | &issue_handle->iss_pkey); | 1560 | &issue_handle->iss_pkey); |
1565 | issue_handle->expiration = GNUNET_TIME_absolute_ntoh (im->expiration); | 1561 | issue_handle->expiration = GNUNET_TIME_absolute_ntoh (im->expiration); |
1566 | issue_handle->nonce = ntohl (im->nonce); | 1562 | issue_handle->nonce = ntohl (im->nonce); |
1567 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1563 | GNUNET_SERVICE_client_continue (client); |
1568 | GNUNET_SERVER_notification_context_add (nc, client); | ||
1569 | GNUNET_SERVER_client_set_user_context (client, issue_handle); | ||
1570 | issue_handle->client = client; | 1564 | issue_handle->client = client; |
1571 | issue_handle->scopes = GNUNET_strdup (scopes); | 1565 | issue_handle->scopes = GNUNET_strdup (scopes); |
1572 | issue_handle->token = token_create (&issue_handle->iss_pkey, | 1566 | issue_handle->token = token_create (&issue_handle->iss_pkey, |
@@ -1593,22 +1587,12 @@ handle_issue_message (void *cls, | |||
1593 | */ | 1587 | */ |
1594 | static void | 1588 | static void |
1595 | run (void *cls, | 1589 | run (void *cls, |
1596 | struct GNUNET_SERVER_Handle *server, | 1590 | const struct GNUNET_CONFIGURATION_Handle *c, |
1597 | const struct GNUNET_CONFIGURATION_Handle *c) | 1591 | struct GNUNET_SERVICE_Handle *server) |
1598 | { | 1592 | { |
1599 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | ||
1600 | {&handle_issue_message, NULL, | ||
1601 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE, 0}, | ||
1602 | {&handle_exchange_message, NULL, | ||
1603 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE, 0}, | ||
1604 | {NULL, NULL, 0, 0} | ||
1605 | }; | ||
1606 | |||
1607 | cfg = c; | 1593 | cfg = c; |
1608 | 1594 | ||
1609 | stats = GNUNET_STATISTICS_create ("identity-provider", cfg); | 1595 | stats = GNUNET_STATISTICS_create ("identity-provider", cfg); |
1610 | GNUNET_SERVER_add_handlers (server, handlers); | ||
1611 | nc = GNUNET_SERVER_notification_context_create (server, 1); | ||
1612 | 1596 | ||
1613 | //Connect to identity and namestore services | 1597 | //Connect to identity and namestore services |
1614 | ns_handle = GNUNET_NAMESTORE_connect (cfg); | 1598 | ns_handle = GNUNET_NAMESTORE_connect (cfg); |
@@ -1644,21 +1628,62 @@ run (void *cls, | |||
1644 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 1628 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
1645 | } | 1629 | } |
1646 | 1630 | ||
1631 | /** | ||
1632 | * Called whenever a client is disconnected. | ||
1633 | * | ||
1634 | * @param cls closure | ||
1635 | * @param client identification of the client | ||
1636 | * @param app_ctx @a client | ||
1637 | */ | ||
1638 | static void | ||
1639 | client_disconnect_cb (void *cls, | ||
1640 | struct GNUNET_SERVICE_Client *client, | ||
1641 | void *app_ctx) | ||
1642 | { | ||
1643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1644 | "Client %p disconnected\n", | ||
1645 | client); | ||
1646 | } | ||
1647 | |||
1647 | 1648 | ||
1648 | /** | 1649 | /** |
1649 | * The main function | 1650 | * Add a client to our list of active clients. |
1650 | * | 1651 | * |
1651 | * @param argc number of arguments from the cli | 1652 | * @param cls NULL |
1652 | * @param argv command line arguments | 1653 | * @param client client to add |
1653 | * @return 0 ok, 1 on error | 1654 | * @param mq message queue for @a client |
1655 | * @return internal namestore client structure for this client | ||
1654 | */ | 1656 | */ |
1655 | int | 1657 | static void * |
1656 | main (int argc, char *const *argv) | 1658 | client_connect_cb (void *cls, |
1659 | struct GNUNET_SERVICE_Client *client, | ||
1660 | struct GNUNET_MQ_Handle *mq) | ||
1657 | { | 1661 | { |
1658 | return (GNUNET_OK == | 1662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1659 | GNUNET_SERVICE_run (argc, argv, "identity-provider", | 1663 | "Client %p connected\n", |
1660 | GNUNET_SERVICE_OPTION_NONE, | 1664 | client); |
1661 | &run, NULL)) ? 0 : 1; | 1665 | return client; |
1662 | } | 1666 | } |
1663 | 1667 | ||
1668 | |||
1669 | |||
1670 | /** | ||
1671 | * Define "main" method using service macro. | ||
1672 | */ | ||
1673 | GNUNET_SERVICE_MAIN | ||
1674 | ("identity-provider", | ||
1675 | GNUNET_SERVICE_OPTION_NONE, | ||
1676 | &run, | ||
1677 | &client_connect_cb, | ||
1678 | &client_disconnect_cb, | ||
1679 | NULL, | ||
1680 | GNUNET_MQ_hd_var_size (issue_message, | ||
1681 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE, | ||
1682 | struct IssueMessage, | ||
1683 | NULL), | ||
1684 | GNUNET_MQ_hd_var_size (exchange_message, | ||
1685 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE, | ||
1686 | struct ExchangeMessage, | ||
1687 | NULL), | ||
1688 | GNUNET_MQ_handler_end()); | ||
1664 | /* end of gnunet-service-identity-provider.c */ | 1689 | /* end of gnunet-service-identity-provider.c */ |
diff --git a/src/identity-provider/identity_provider.h b/src/identity-provider/identity_provider.h index da7470bf9..6fe6102c8 100644 --- a/src/identity-provider/identity_provider.h +++ b/src/identity-provider/identity_provider.h | |||
@@ -58,7 +58,7 @@ struct GNUNET_IDENTITY_PROVIDER_Ticket | |||
58 | /** | 58 | /** |
59 | * Answer from service to client after issue operation | 59 | * Answer from service to client after issue operation |
60 | */ | 60 | */ |
61 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage | 61 | struct IssueResultMessage |
62 | { | 62 | { |
63 | /** | 63 | /** |
64 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE | 64 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE |
@@ -78,7 +78,7 @@ struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage | |||
78 | /** | 78 | /** |
79 | * Ticket exchange message. | 79 | * Ticket exchange message. |
80 | */ | 80 | */ |
81 | struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage | 81 | struct ExchangeResultMessage |
82 | { | 82 | { |
83 | /** | 83 | /** |
84 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE | 84 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE |
@@ -105,7 +105,7 @@ struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage | |||
105 | /** | 105 | /** |
106 | * Client requests IdP to issue token. | 106 | * Client requests IdP to issue token. |
107 | */ | 107 | */ |
108 | struct GNUNET_IDENTITY_PROVIDER_IssueMessage | 108 | struct IssueMessage |
109 | { | 109 | { |
110 | /** | 110 | /** |
111 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT | 111 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT |
@@ -147,7 +147,7 @@ struct GNUNET_IDENTITY_PROVIDER_IssueMessage | |||
147 | /** | 147 | /** |
148 | * Use to exchange a ticket for a token | 148 | * Use to exchange a ticket for a token |
149 | */ | 149 | */ |
150 | struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage | 150 | struct ExchangeMessage |
151 | { | 151 | { |
152 | /** | 152 | /** |
153 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT | 153 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT |
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c index 8317d18ad..28ff90fc4 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/identity-provider/identity_provider_api.c | |||
@@ -220,15 +220,15 @@ mq_error_handler (void *cls, | |||
220 | */ | 220 | */ |
221 | static int | 221 | static int |
222 | check_exchange_result (void *cls, | 222 | check_exchange_result (void *cls, |
223 | const struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage *erm) | 223 | const struct ExchangeResultMessage *erm) |
224 | { | 224 | { |
225 | char *str; | 225 | char *str; |
226 | size_t size = ntohs (erm->header.size) - sizeof (*erm); | 226 | size_t size = ntohs (erm->header.size) - sizeof (*erm); |
227 | 227 | ||
228 | 228 | ||
229 | str = (char *) &erm[1]; | 229 | str = (char *) &erm[1]; |
230 | if ( (size > sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage)) && | 230 | if ( (size > sizeof (struct ExchangeResultMessage)) && |
231 | ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage) - 1]) ) | 231 | ('\0' != str[size - sizeof (struct ExchangeResultMessage) - 1]) ) |
232 | { | 232 | { |
233 | GNUNET_break (0); | 233 | GNUNET_break (0); |
234 | return GNUNET_SYSERR; | 234 | return GNUNET_SYSERR; |
@@ -245,13 +245,13 @@ check_exchange_result (void *cls, | |||
245 | */ | 245 | */ |
246 | static int | 246 | static int |
247 | check_result (void *cls, | 247 | check_result (void *cls, |
248 | const struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm) | 248 | const struct IssueResultMessage *irm) |
249 | { | 249 | { |
250 | char *str; | 250 | char *str; |
251 | size_t size = ntohs (irm->header.size) - sizeof (*irm); | 251 | size_t size = ntohs (irm->header.size) - sizeof (*irm); |
252 | str = (char*) &irm[1]; | 252 | str = (char*) &irm[1]; |
253 | if ( (size > sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage)) && | 253 | if ( (size > sizeof (struct IssueResultMessage)) && |
254 | ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage) - 1]) ) | 254 | ('\0' != str[size - sizeof (struct IssueResultMessage) - 1]) ) |
255 | { | 255 | { |
256 | GNUNET_break (0); | 256 | GNUNET_break (0); |
257 | return GNUNET_SYSERR; | 257 | return GNUNET_SYSERR; |
@@ -267,7 +267,7 @@ check_result (void *cls, | |||
267 | */ | 267 | */ |
268 | static void | 268 | static void |
269 | handle_exchange_result (void *cls, | 269 | handle_exchange_result (void *cls, |
270 | const struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage *erm) | 270 | const struct ExchangeResultMessage *erm) |
271 | { | 271 | { |
272 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; | 272 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; |
273 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 273 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; |
@@ -303,7 +303,7 @@ handle_exchange_result (void *cls, | |||
303 | */ | 303 | */ |
304 | static void | 304 | static void |
305 | handle_result (void *cls, | 305 | handle_result (void *cls, |
306 | const struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm) | 306 | const struct IssueResultMessage *irm) |
307 | { | 307 | { |
308 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; | 308 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; |
309 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 309 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; |
@@ -366,11 +366,11 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) | |||
366 | struct GNUNET_MQ_MessageHandler handlers[] = { | 366 | struct GNUNET_MQ_MessageHandler handlers[] = { |
367 | GNUNET_MQ_hd_var_size (result, | 367 | GNUNET_MQ_hd_var_size (result, |
368 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_RESULT, | 368 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_RESULT, |
369 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage, | 369 | struct IssueResultMessage, |
370 | h), | 370 | h), |
371 | GNUNET_MQ_hd_var_size (exchange_result, | 371 | GNUNET_MQ_hd_var_size (exchange_result, |
372 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT, | 372 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT, |
373 | struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage, | 373 | struct ExchangeResultMessage, |
374 | h), | 374 | h), |
375 | GNUNET_MQ_handler_end () | 375 | GNUNET_MQ_handler_end () |
376 | }; | 376 | }; |
@@ -436,11 +436,11 @@ GNUNET_IDENTITY_PROVIDER_issue_token (struct GNUNET_IDENTITY_PROVIDER_Handle *id | |||
436 | void *cb_cls) | 436 | void *cb_cls) |
437 | { | 437 | { |
438 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 438 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; |
439 | struct GNUNET_IDENTITY_PROVIDER_IssueMessage *im; | 439 | struct IssueMessage *im; |
440 | size_t slen; | 440 | size_t slen; |
441 | 441 | ||
442 | slen = strlen (scopes) + 1; | 442 | slen = strlen (scopes) + 1; |
443 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueMessage)) | 443 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IssueMessage)) |
444 | { | 444 | { |
445 | GNUNET_break (0); | 445 | GNUNET_break (0); |
446 | return NULL; | 446 | return NULL; |
@@ -486,14 +486,14 @@ GNUNET_IDENTITY_PROVIDER_exchange_ticket (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
486 | void *cont_cls) | 486 | void *cont_cls) |
487 | { | 487 | { |
488 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 488 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; |
489 | struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage *em; | 489 | struct ExchangeMessage *em; |
490 | size_t slen; | 490 | size_t slen; |
491 | char *ticket_str; | 491 | char *ticket_str; |
492 | 492 | ||
493 | ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket); | 493 | ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket); |
494 | 494 | ||
495 | slen = strlen (ticket_str) + 1; | 495 | slen = strlen (ticket_str) + 1; |
496 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage)) | 496 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct ExchangeMessage)) |
497 | { | 497 | { |
498 | GNUNET_free (ticket_str); | 498 | GNUNET_free (ticket_str); |
499 | GNUNET_break (0); | 499 | GNUNET_break (0); |