lib/praesidio.c
//Returns the starting index for the next message.
Returns the starting index for the next message.
Returns the starting index for the next message .
int send_enclave_message(char *mailbox_address, char *message, int length) {
  int current_offset = ((long long) mailbox_address) & ((1 << PAGE_BIT_SHIFT) - 1);
  int offset = LENGTH_SIZE + length;
  int i, index;
  if(length > ((1 << PAGE_BIT_SHIFT) - 2*LENGTH_SIZE)) {
    return 0;
  }
  mailbox_address[0] = BUSY_BYTE;
  for(i = 0; i < length; i++) {
    index = LENGTH_SIZE + i;
    if((current_offset + index) >= (1 << PAGE_BIT_SHIFT)) {
      index -= (1 << PAGE_BIT_SHIFT);
    }
    mailbox_address[index] = message[i];
  }
  if((current_offset + offset) >= (1 << PAGE_BIT_SHIFT)) {
    offset -= (1 << PAGE_BIT_SHIFT);
  }
  mailbox_address[offset] = BUSY_BYTE;
  for(i = 0; i < LENGTH_SIZE; i++) {
    index = LENGTH_SIZE-1-i;
    if((current_offset + index) >= (1 << PAGE_BIT_SHIFT)) {
      index -= (1 << PAGE_BIT_SHIFT);
    }
    mailbox_address[index] = ((length >> (8*i)) & 0xFF);
  }
  return offset;
}
int send_enclave_message ( char * mailbox_address , char * message , int length ) { int current_offset = ( ( long long ) mailbox_address ) & ( ( 1 << PAGE_BIT_SHIFT ) - 1 ) ; int offset = LENGTH_SIZE + length ; int i , index ; if ( length > ( ( 1 << PAGE_BIT_SHIFT ) - 2 * LENGTH_SIZE ) ) { return 0 ; } mailbox_address [ 0 ] = BUSY_BYTE ; for ( i = 0 ; i < length ; i ++ ) { index = LENGTH_SIZE + i ; if ( ( current_offset + index ) >= ( 1 << PAGE_BIT_SHIFT ) ) { index -= ( 1 << PAGE_BIT_SHIFT ) ; } mailbox_address [ index ] = message [ i ] ; } if ( ( current_offset + offset ) >= ( 1 << PAGE_BIT_SHIFT ) ) { offset -= ( 1 << PAGE_BIT_SHIFT ) ; } mailbox_address [ offset ] = BUSY_BYTE ; for ( i = 0 ; i < LENGTH_SIZE ; i ++ ) { index = LENGTH_SIZE - 1 - i ; if ( ( current_offset + index ) >= ( 1 << PAGE_BIT_SHIFT ) ) { index -= ( 1 << PAGE_BIT_SHIFT ) ; } mailbox_address [ index ] = ( ( length >> ( 8 * i ) ) & 0xFF ) ; } return offset ; }
Returns the starting index for the next message.
Returns the starting index for the next message .