I created a struct with some client info in function1. I populate the struct with the info in function1 and then trying to pass it along to function2, but the value does not pass. I've tried making the struct variable both a pointer and object, in both the value does not pass. I've also tried different combinations of pointers, pass by value and pass by address at different places.
//The struct
typedef struct arguments {
  SSL *ssl;
  int *i; 
  socket_address_union *addr1; 
  socket_address_union *addr2;
} arguments;    
void function1(socket_address_union *addr2, socket_address_union *addr1, int *i) {
  
  //socket_address_union client_address;
  BIO *bio;
  SSL *ssl;
  arguments *args;
  memset(addr1, 0, sizeof(struct socket_address_union));
  
  printf("Calling DTLS v1 listen\n");
  while (DTLSv1_listen(ssl, addr1) <= 0);
  args = (arguments *) malloc (sizeof(arguments));
  
  args->i = i;
  memcpy(&args->addr1, &addr1, sizeof addr1);
  memcpy(&args->addr2, &addr2, sizeof addr2);
  args->ssl = ssl;
  
  function2(addr1, addr2, &args);
}
void function2(socket_address_union *addr1, socket_address_union *addr2, void *args) {
  int num_timeouts = 0;
  int reading = 0;
  int len;
  char buf[BUFFER_SIZE];
  SSL *ssl;
  int *i;
  //socket_address_union *client_address;
  struct arguments *args = (struct arguments*) args;
  ssl = args->ssl;
  i = args->i;
  function3(ssl, &i, addr1, addr2);
}
//function3 defination
void function3(SSL **ssl, int *i, socket_address_union *addr1, socket_address_union *addr2)
