void test_SearchResponse() { printf("TEST SEARCH RESPONSE\n"); /// Building a SearchResponse DNDSMessage_t *msg; // A DNDS Message DNDSMessage_new(&msg); DNDSMessage_set_channel(msg, 0); DNDSMessage_set_pdu(msg, pdu_PR_dsm); DSMessage_set_seqNumber(msg, 0); DSMessage_set_ackNumber(msg, 1); DSMessage_set_action(msg, action_listNode); DSMessage_set_operation(msg, dsop_PR_searchResponse); SearchResponse_set_result(msg, DNDSResult_success); SearchResponse_set_searchType(msg, SearchType_object); /* /// objContext DNDSObject_t *objContext; DNDSObject_new(&objContext); DNDSObject_set_objectType(objContext, DNDSObject_PR_context); Context_set_id(objContext, 40); SearchResponse_add_object(msg, objContext); */ /// Node DNDSObject_t *objNode; DNDSObject_new(&objNode); DNDSObject_set_objectType(objNode, DNDSObject_PR_node); // Node_set_contextId(objNode, 10); Node_set_description(objNode, "yo", strlen("yo")); Node_set_uuid(objNode, "abc", strlen("abc")); Node_set_certificate(objNode, "certificate", 11); Node_set_certificateKey(objNode, "key", 3); Node_set_status(objNode, 2); SearchResponse_add_object(msg, objNode); /// Encoding part asn_enc_rval_t ec; // Encoder return value FILE *fp = fopen("dnds.ber", "wb"); // BER output ec = der_encode(&asn_DEF_DNDSMessage, msg, write_out, fp); fclose(fp); xer_fprint(stdout, &asn_DEF_DNDSMessage, msg); DNDSMessage_del(msg); }
void test_SearchResponse_context() { /// Building a SearchResponse DNDSMessage_t *msg; // A DNDS Message DNDSMessage_new(&msg); DNDSMessage_set_channel(msg, 0); DNDSMessage_set_pdu(msg, pdu_PR_dsm); DSMessage_set_seqNumber(msg, 0); DSMessage_set_ackNumber(msg, 400); DSMessage_set_operation(msg, dsop_PR_searchResponse); SearchResponse_set_result(msg, DNDSResult_success); DNDSObject_t *objContext; DNDSObject_new(&objContext); DNDSObject_set_objectType(objContext, DNDSObject_PR_context); Context_set_id(objContext, 10); Context_set_topology(objContext, Topology_mesh); Context_set_description(objContext, "home network", 12); Context_set_network(objContext, "44.128.0.0"); Context_set_netmask(objContext, "255.255.0.0"); Context_set_serverCert(objContext, "serverCert", 10); Context_set_serverPrivkey(objContext, "serverPrivkey", 13); Context_set_trustedCert(objContext, "trustedCert", 11); SearchResponse_add_object(msg, objContext); /// Encoding part asn_enc_rval_t ec; // Encoder return value FILE *fp = fopen("dnds.ber", "wb"); // BER output ec = der_encode(&asn_DEF_DNDSMessage, msg, write_out, fp); fclose(fp); xer_fprint(stdout, &asn_DEF_DNDSMessage, msg); DNDSMessage_del(msg); }
void test_SearchResponse() { /// Building a SearchResponse DNDSMessage_t *msg; // A DNDS Message DNDSMessage_new(&msg); DNDSMessage_set_channel(msg, 0); DNDSMessage_set_pdu(msg, pdu_PR_dsm); DSMessage_set_seqNumber(msg, 0); DSMessage_set_ackNumber(msg, 400); DSMessage_set_operation(msg, dsop_PR_searchResponse); SearchResponse_set_result(msg, DNDSResult_success); /// objContext DNDSObject_t *objContext; DNDSObject_new(&objContext); DNDSObject_set_objectType(objContext, DNDSObject_PR_context); Context_set_id(objContext, 40); SearchResponse_add_object(msg, objContext); /// Node DNDSObject_t *objNode; DNDSObject_new(&objNode); DNDSObject_set_objectType(objNode, DNDSObject_PR_node); Node_set_contextId(objNode, 10); Node_set_certificate(objNode, "certificate", 11); Node_set_certificateKey(objNode, "key", 3); Node_set_status(objNode, 2); SearchResponse_add_object(msg, objNode); /* /// User1 DNDSObject_t *objUser1; // A User Object DNDSObject_new(&objUser1); DNDSObject_set_objectType(objUser1, DNDSObject_PR_user); User_set_id(objUser1, 1); User_set_contextId(objUser1, 1); User_set_name(objUser1, "1icboul", 7); User_set_password(objUser1, "1wd1wd", 6); User_set_firstname(objUser1, "1icolas", 7); User_set_lastname(objUser1, "1ouliane", 8); User_set_email(objUser1, "*****@*****.**", 15); User_set_role(objUser1, 0); User_set_status(objUser1, 0); SearchResponse_add_object(msg, objUser1); /// User2 DNDSObject_t *objUser2; // A User Object DNDSObject_new(&objUser2); DNDSObject_set_objectType(objUser2, DNDSObject_PR_user); User_set_id(objUser2, 2); User_set_contextId(objUser2, 2); User_set_name(objUser2, "2icboul", 6); User_set_password(objUser2, "2wd2wd", 6); User_set_firstname(objUser2, "2icolas", 7); User_set_lastname(objUser2, "2ouliane", 8); User_set_email(objUser2, "*****@*****.**", 15); User_set_role(objUser2, 0); User_set_status(objUser2, 0); SearchResponse_add_object(msg, objUser2); */ /// Encoding part asn_enc_rval_t ec; // Encoder return value FILE *fp = fopen("dnds.ber", "wb"); // BER output ec = der_encode(&asn_DEF_DNDSMessage, msg, write_out, fp); fclose(fp); xer_fprint(stdout, &asn_DEF_DNDSMessage, msg); DNDSMessage_del(msg); }