Browse Source

...

doc_update_sequoia
Volker Birk 6 years ago
parent
commit
7b76b34a68
4 changed files with 33 additions and 38 deletions
  1. +3
    -7
      asn.1/devicegroup.asn1
  2. +3
    -6
      asn.1/pEp.asn1
  3. +10
    -7
      src/map_asn1.c
  4. +17
    -18
      src/sync_impl.c

+ 3
- 7
asn.1/devicegroup.asn1 View File

@ -8,13 +8,9 @@ BEGIN
EXPORTS DeviceGroup-Protocol;
IMPORTS Version, Identity, IdentityList FROM PEP;
Beacon ::= SEQUENCE {
Beacon ::= NULL
}
HandshakeRequest ::= SEQUENCE {
}
HandshakeRequest ::= NULL
GroupKeys ::= SEQUENCE {
ownIdentities IdentityList
@ -28,7 +24,7 @@ DeviceGroup-Protocol ::= SEQUENCE {
sequence INTEGER, /* always increases */
me Identity, /* identity of the sender */
state INTEGER, /* state the sender is in */
devicegroup BOOLEAN DEFAULT FALSE
devicegroup BOOLEAN
/* signals if this message is coming from a device group member */
},


+ 3
- 6
asn.1/pEp.asn1 View File

@ -7,9 +7,6 @@ BEGIN
EXPORTS Version, Identity, IdentityList;
major-version INTEGER ::= 1
minor-version INTEGER ::= 0
ISO639-1 ::= PrintableString(FROM ("a".."z")) (SIZE(2))
Hex ::= PrintableString(FROM ("A".."F") | FROM ("0".."9"))
Hash ::= Hex(SIZE(1..128)) -- SHA1 to SHA512 in hex
@ -20,14 +17,14 @@ Identity ::= SEQUENCE {
user-id UTF8String (SIZE(1..1024)) OPTIONAL,
username UTF8String (SIZE(1..1024)) OPTIONAL,
comm-type INTEGER (0..255) OPTIONAL,
lang ISO639-1 DEFAULT "en"
lang ISO639-1
}
IdentityList ::= SEQUENCE OF Identity
Version ::= SEQUENCE {
major INTEGER (0..255) DEFAULT major-version,
minor INTEGER (0..255) DEFAULT minor-version
major INTEGER (0..255),
minor INTEGER (0..255)
}
END


+ 10
- 7
src/map_asn1.c View File

@ -51,10 +51,12 @@ Identity_t *Identity_from_Struct(
}
if (ident->lang[0]) {
result->lang = OCTET_STRING_new_fromBuf(&asn_DEF_ISO639_1,
ident->lang, 2);
if (!result->lang)
goto enomem;
int r = OCTET_STRING_fromBuf(&result->lang, ident->lang, 2);
assert(r == 0);
}
else {
int r = OCTET_STRING_fromBuf(&result->lang, "en", 2);
assert(r == 0);
}
return result;
@ -107,9 +109,10 @@ pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result)
if (ident->comm_type)
result->comm_type = (PEP_comm_type) *ident->comm_type;
if (ident->lang) {
result->lang[0] = ident->lang->buf[0];
result->lang[1] = ident->lang->buf[1];
if (ident->lang.size == 2) {
result->lang[0] = ident->lang.buf[0];
result->lang[1] = ident->lang.buf[1];
result->lang[2] = 0;
}
return result;


+ 17
- 18
src/sync_impl.c View File

@ -6,6 +6,9 @@
#include "map_asn1.h"
#include "baseprotocol.h"
#define SYNC_VERSION_MAJOR 1
#define SYNC_VERSION_MINOR 0
PEP_STATUS receive_sync_msg(
PEP_SESSION session,
DeviceGroup_Protocol_t *msg
@ -28,16 +31,14 @@ PEP_STATUS receive_sync_msg(
break;
case DeviceGroup_Protocol__payload_PR_handshakeRequest:
partner = Identity_to_Struct(
&msg->header.me, NULL);
partner = Identity_to_Struct(&msg->header.me, NULL);
if (!partner)
return PEP_OUT_OF_MEMORY;
event = HandshakeRequest;
break;
case DeviceGroup_Protocol__payload_PR_groupKeys:
partner = Identity_to_Struct(&msg->header.me,
NULL);
partner = Identity_to_Struct(&msg->header.me, NULL);
if (!partner)
return PEP_OUT_OF_MEMORY;
identity_list *group_keys = IdentityList_to_identity_list(
@ -68,7 +69,7 @@ PEP_STATUS receive_DeviceState_msg(PEP_SESSION session, message *src)
for (bloblist_t *bl = src->attachments; bl && bl->value; bl = bl->next) {
if (bl->mime_type && strcasecmp(bl->mime_type, "application/pEp") == 0
&& bl->size) {
DeviceGroup_Protocol_t *msg;
DeviceGroup_Protocol_t *msg = NULL;
uper_decode_complete(NULL, &asn_DEF_DeviceGroup_Protocol,
(void **) &msg, bl->value, bl->size);
if (msg) {
@ -134,31 +135,29 @@ PEP_STATUS unicast_msg(
goto error;
}
msg->header.version.major = SYNC_VERSION_MAJOR;
msg->header.version.minor = SYNC_VERSION_MINOR;
int32_t seq;
status = sequence_value(session, "DeviceGroup", &seq);
if (status != PEP_STATUS_OK)
goto error;
msg->header.sequence = (long) seq;
bool devicegroup = storedGroupKeys(session);
if (devicegroup) { // default is FALSE
BOOLEAN_t *dg = malloc(sizeof(BOOLEAN_t));
assert(dg);
if (!dg)
goto enomem;
*dg = 1;
msg->header.devicegroup = dg;
}
msg->header.state = (long) state;
status = get_identity(session, partner->address, PEP_OWN_USERID, &me);
if (status != PEP_STATUS_OK)
goto error;
if (Identity_from_Struct(me, &msg->header.me) == NULL)
goto enomem;
msg->header.state = (long) state;
bool devicegroup = storedGroupKeys(session);
if (devicegroup)
msg->header.devicegroup = 1;
else
msg->header.devicegroup = 0;
if (asn_check_constraints(&asn_DEF_DeviceGroup_Protocol, msg, NULL, NULL)) {
status = PEP_CONTRAINTS_VIOLATED;
goto error;


Loading…
Cancel
Save