void main(void) { unsigned char freshout[20], seedbyte = 1; unsigned int bytesneeded; R_RANDOM_STRUCT randomstruct; fprintf(stderr, "RANDEMO - Random Object Demo Using %s.\n", RSAEURO_IDENT); R_RandomCreate(&randomstruct); R_GenerateBytes(freshout, sizeof(freshout), &randomstruct); printf("\n Random Output 1 - "); printbuff(freshout, sizeof(freshout)); R_RandomMix(&randomstruct); R_GenerateBytes(freshout, sizeof(freshout), &randomstruct); printf(" Mixed Random Output 1 - "); printbuff(freshout, sizeof(freshout)); R_RandomFinal(&randomstruct); R_RandomInit(&randomstruct); while(1) { R_GetRandomBytesNeeded(&bytesneeded, &randomstruct); if(bytesneeded == 0) break; R_RandomUpdate(&randomstruct, &seedbyte, 1); } R_GenerateBytes(freshout, sizeof(freshout), &randomstruct); printf(" Random Output 2 - "); printbuff(freshout, sizeof(freshout)); R_RandomMix(&randomstruct); R_GenerateBytes(freshout, sizeof(freshout), &randomstruct); printf(" Mixed Random Output 2 - "); printbuff(freshout, sizeof(freshout)); R_GenerateBytes(freshout, sizeof(freshout), &randomstruct); printf(" Mixed Random Output 2 - "); printbuff(freshout, sizeof(freshout)); R_RandomFinal(&randomstruct); }
int main(void) { int sock, ret, run = 0; char buff_sender[BUFFSIZE]; char buff_receiver[2 * BUFFSIZE]; char name[FBNAMSIZ]; int iterations = 41; int i = 0; sock = socket(27, SOCK_RAW, 0); if (sock < 0) panic("Cannot create socket!\n"); ret = ioctl(sock, 35296, name); if (ret < 0) panic("Cannot do ioctl!\n"); fprintf(stderr, "our instance: %s\n", name); printf("our instance: %s\n", name); preparebuff(buff_sender, run++); for (i = 0; i < iterations; i++) { printbuff(buff_sender, sizeof(buff_sender)); retry_send: ret = sendto(sock, buff_sender, sizeof(buff_sender), 0, NULL, 0); if (ret == -1){ perror("sendto"); fprintf(stderr, "iteration: %d\n", i); sleep(25); goto retry_send; } fprintf(stderr, "[echo:]##############waiting######################\n"); retry_rcv: ret = recvfrom(sock, buff_receiver, sizeof(buff_receiver), 0, NULL, 0); if (ret == -1){ perror("recvfrom"); sleep(5); goto retry_rcv; } fprintf(stderr, "[echo:]##############received new message with len %d######################\n", ret); printbuff(buff_receiver, ret); } close(sock); return 0; }