This commit is contained in:
emanuel 2021-05-17 16:55:05 +01:00
parent 6a4f8cba3c
commit d212396fe2
2 changed files with 18 additions and 38 deletions

View File

@ -1,7 +1,9 @@
mkdir -p /tmp/itss
echo Spawning [facilities]
nohup ../build/src/it2s-itss-facilities > /dev/null 2>&1 &
echo Running [tester]
echo Running tester...
../build/test/./tester
code=$?

View File

@ -5,10 +5,6 @@
#include <itss-management/ManagementRequest.h>
#include <itss-management/ManagementReply.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <pthread.h>
#include <zmq.h>
#include <unistd.h>
@ -25,22 +21,16 @@ void hex2bin(char* hex, uint8_t** bin, uint16_t* bin_len) {
}
int init(void* ctx) {
printf("Initializing management simulator \n");
fflush(stdout);
printf("Simulating [management] ... \n"); fflush(stdout);
void* management_socket = zmq_socket(ctx, ZMQ_REP);
struct stat st = {0};
if (stat("/tmp/itss/", &st) == -1) {
mkdir("/tmp/itss", 0777);
}
int ra = zmq_bind(management_socket, "ipc:///tmp/itss/management");
zmq_bind(management_socket, "ipc:///tmp/itss/management");
uint8_t buffer[2048];
// Ignore first request (set)
zmq_recv(management_socket, buffer, 2048, 0);
printf(" - Received MREQ.set \n");
fflush(stdout);
printf(" - Received MREQ.set \n"); fflush(stdout);
int code = 0;
zmq_send(management_socket, &code, 1, 0);
@ -52,12 +42,10 @@ int init(void* ctx) {
asn_dec_rval_t dec = asn_decode(NULL, ATS_CANONICAL_OER, &asn_DEF_ManagementRequest, (void**) &mreq, buffer, 2048);
if (dec.code) {
rv = 1;
printf(" FAIL: MREQ decode error\n");
fflush(stdout);
printf(" FAIL: MREQ decode error\n"); fflush(stdout);
goto cleanup;
}
printf(" - Received MREQ.get\n");
fflush(stdout);
printf(" - Received MREQ.get\n"); fflush(stdout);
ManagementReply_t* mrep = calloc(1, sizeof(ManagementReply_t));
switch (mreq->present) {
@ -118,16 +106,14 @@ int init(void* ctx) {
case ManagementRequest_PR_set:
default:
rv = 1;
printf(" FAIL: MREQ. not GET (%d)\n", mreq->present);
fflush(stdout);
printf(" FAIL: MREQ. not GET (%d)\n", mreq->present); fflush(stdout);
goto cleanup;
}
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_ManagementReply, NULL, mrep, buffer, 256);
zmq_send(management_socket, buffer, enc.encoded, 0);
printf(" OK\n");
fflush(stdout);
printf(" OK\n"); fflush(stdout);
cleanup:
ASN_STRUCT_FREE(asn_DEF_ManagementRequest, mreq);
@ -142,7 +128,6 @@ int cam_gen(void* ctx) {
void* transport_socket = zmq_socket(ctx, ZMQ_REP);
int rv = zmq_bind(transport_socket, "ipc:///tmp/itss/transport");
printf("rv %d\n", rv); fflush(stdout);
uint8_t buffer[2048];
zmq_recv(transport_socket, buffer, 2048, 0);
int code = 0;
@ -170,8 +155,7 @@ int cam_gen(void* ctx) {
int forward_up(void* ctx) {
printf("Testing forwarding up:\n");
fflush(stdout);
printf("Testing forwarding up:\n"); fflush(stdout);
BTPDataIndication_t* bdi = calloc(1, sizeof(BTPDataIndication_t));
char* cam_hex = "02027dfddf4403ca4059bba5f38cc40dba9ffffffc2230eff200e11fc0078082a88a8337fee3fff600004dffea800618d08018efff14003ac68800c77ff8e002263460063bffd1000fb1a30031dffe2800958d30018efff840048c68800c77ffae002c63480063bffbd001a31a40031dfff28002d8cf0018c0";
@ -199,12 +183,10 @@ int forward_up(void* ctx) {
zmq_send(facilities_socket, b_bdi_cam, enc.encoded+1, 0);
zmq_recv(facilities_socket, &code, 1, 0);
if (code) {
printf(" FAIL\n");
fflush(stdout);
printf(" FAIL\n"); fflush(stdout);
return 1;
}
printf(" - Sent CAM BDI (%ldB)\n", bdi->data.size);
fflush(stdout);
printf(" - Sent CAM BDI (%ldB)\n", bdi->data.size); fflush(stdout);
void* applications_socket = zmq_socket(ctx, ZMQ_REP);
@ -220,19 +202,15 @@ int forward_up(void* ctx) {
FacilitiesDataIndication_t* fdi = NULL;
asn_dec_rval_t dec = asn_decode(NULL, ATS_CANONICAL_OER, &asn_DEF_FacilitiesDataIndication, (void**) &fdi, buffer+1, 2047);
if (dec.code) {
printf(" FAIL\n");
fflush(stdout);
printf(" FAIL\n"); fflush(stdout);
return 1;
}
printf(" - Received CAM FDI (%ldB)\n", fdi->data.size);
fflush(stdout);
printf(" - Received CAM FDI (%ldB)\n", fdi->data.size); fflush(stdout);
if (fdi->data.size == bdi->data.size) {
printf(" OK\n");
fflush(stdout);
printf(" OK\n"); fflush(stdout);
} else {
printf(" FAIL\n");
fflush(stdout);
printf(" FAIL\n"); fflush(stdout);
return 1;
}
@ -250,7 +228,7 @@ int main() {
if (rv) return 1;
rv += forward_up(ctx);
rv += cam_gen(ctx);
//rv += cam_gen(ctx);
return rv;
}