Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* TEST TEST TEST */
- static plist covert = NULL; // lista che contiene tutti i bit covert
- static int length_covert=0; // lunghezza lista covert
- int len;
- int exitCond = 0;
- int i = 0;
- int j = 0;
- struct timespec now,after;
- double difference = 0;
- double timing_interval = 1;
- char* covert_message;
- clock_gettime(CLOCK_MONOTONIC, &now);
- int fail_or_len = recvfrom(sock, (char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen);
- clock_gettime(CLOCK_MONOTONIC, &after);
- difference = ( ((double)after.tv_sec + 1.0e-9*after.tv_nsec) - ((double)now.tv_sec + 1.0e-9*now.tv_nsec) ) * 100 * 1000;
- //printf("D: %4f\n", difference);
- if(fail_or_len > 800) {
- difference = difference-timing_interval/2;
- printf("Difference: %4f\n", difference);
- int zeros=(int)(difference/timing_interval);
- if(difference < 0) // sto ancora inviando in covert mode
- insertCovert(&covert,zeros,&length_covert);
- covert_message = list_to_array(covert,length_covert+1);
- printf("covert_message[0]: %4d\n", covert_message[0]);
- covert_message = decodeCovert(covert_message);
- }
- if(covert_message)
- if(strcmp(covert_message, "") != 0)
- printf("Messaggio covert: %s\n",covert_message);
- /**/
- /***** insertCovert ********/
- void insertCovert(plist* l, int zeros, int* length) {
- int i;
- plist x = *l;
- /*
- if(x!=NULL) {
- while(x->next != NULL)
- x = x->next;
- } else {
- x = (plist)malloc(sizeof(list));
- x->next = (plist)malloc(sizeof(list));
- *l = x->next;
- }
- for (i = 0; i < zeros; i++) {
- if(x->next==NULL)
- x->next = (plist)malloc(sizeof(list));
- x = x->next;
- x->value = 0;
- x->next = NULL;
- }
- */
- if (x == NULL) {
- x = (plist)malloc(sizeof(list));
- x->value=0;
- x->next=NULL;
- zeros--;
- *l = x;
- }
- while(x->next != NULL)
- x = x->next;
- for (i = 0; i < zeros; i++) {
- x->next = (plist)malloc(sizeof(list));
- x = x->next;
- x->value = 0;
- x->next = NULL;
- }
- x->next=(plist)malloc(sizeof(list));
- x = x->next;
- x->value = 1;
- x->next = NULL;
- *length = *length + zeros + 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement