Exemple #1
0
/*
 * Convert IPv4/IPv6 address to text.
 */
PJ_DEF(pj_status_t) pj_inet_ntop(int af, const void *src,
				 char *dst, int size)

{
    PJ_ASSERT_RETURN(src && dst && size, PJ_EINVAL);

    *dst = '\0';

    if (af==PJ_AF_INET) {

	TBuf<PJ_INET_ADDRSTRLEN> str16;
	pj_in_addr inaddr;

	if (size < PJ_INET_ADDRSTRLEN)
	    return PJ_ETOOSMALL;

	pj_memcpy(&inaddr, src, 4);

	/* Symbian IP address is in host byte order */
	TInetAddr temp_addr((TUint32)pj_ntohl(inaddr.s_addr), (TUint)0);
	temp_addr.Output(str16);
 
	pj_unicode_to_ansi((const wchar_t*)str16.PtrZ(), str16.Length(),
			   dst, size);
	return PJ_SUCCESS;

    } else if (af==PJ_AF_INET6) {
	TBuf<PJ_INET6_ADDRSTRLEN> str16;

	if (size < PJ_INET6_ADDRSTRLEN)
	    return PJ_ETOOSMALL;

	TIp6Addr ip6;
	pj_memcpy(ip6.u.iAddr8, src, 16);

	TInetAddr temp_addr(ip6, (TUint)0);
	temp_addr.Output(str16);
 
	pj_unicode_to_ansi((const wchar_t*)str16.PtrZ(), str16.Length(),
			   dst, size);
	return PJ_SUCCESS;

    } else {
	pj_assert(!"Unsupport address family");
	return PJ_EINVAL;
    }

}
Exemple #2
0
void frame::follow_roots() {
  if (is_interpreted_frame()) {
    if (has_interpreted_float_marker() && follow_roots_interpreted_float_frame()) return;

    // Follow the roots of the frame
    for (oop* p = sp(); p <= temp_addr(0); p++) {
      MarkSweep::follow_root(p);
    }
    MarkSweep::follow_root((oop*)hp_addr());
    MarkSweep::follow_root(receiver_addr());
    return;
  } 
  
  if (is_compiled_frame()) {
    if (has_compiled_float_marker() && follow_roots_compiled_float_frame()) return;

    for (oop* p = sp(); p < (oop*)fp(); p++) MarkSweep::follow_root(p);
    return;
  }
    
  if (is_entry_frame()) {
    for (oop* p = sp(); p < (oop*)fp(); p++) MarkSweep::follow_root(p);
    return;
  }

  if (is_deoptimized_frame()) {
    // Expression stack
    oop* end = (oop*)fp() + frame_real_sender_sp_offset;
    for (oop* p = sp(); p < end; p++) MarkSweep::follow_root(p);
    MarkSweep::follow_root((oop*)frame_array_addr());
    return;
  }
}
Exemple #3
0
void *read(void *input){
  struct Params *params = (struct Params*)input;
  int MSGBUFSIZE = 256;
  char msgbuf[MSGBUFSIZE];
  int nbytes;
  int s = params->s;
  struct sockaddr_in addr = params->myaddr;
  socklen_t addrlen=sizeof(params->myaddr);

  while (1) {
    addrlen=sizeof(addr);
    if ((nbytes=recvfrom(s,msgbuf,MSGBUFSIZE,0,(struct sockaddr *) &addr  ,&addrlen)) < 0) {
        perror("recvfrom");
        exit(1);
    }
    msgbuf[nbytes] = 0;
    if(strncmp(msgbuf,"ANNOUNCE ",9) == 0){
      char name[nbytes - 8];
      memcpy( name, &msgbuf[9], nbytes - 9 );
      name[nbytes - 8] = '\0';
      std::string temp_addr(inet_ntoa(addr.sin_addr));
      std::string temp_name(name);
      table[temp_name] = temp_addr;
      std::cout << "announce: " << name << std::endl;

    }
    else {
    std::cout << "message: " << msgbuf << std::endl;
  }
  }
  pthread_exit(NULL);
}
Exemple #4
0
void frame::layout_iterate(FrameLayoutClosure* blk) {
  if (is_interpreted_frame()){ 
    oop* eos = temp_addr(0);
    for (oop* p = sp(); p <= eos; p++) 
      blk->do_stack(eos-p, p);
    blk->do_hp(hp_addr());
    blk->do_receiver(receiver_addr());
    blk->do_link(link_addr());
    blk->do_return_addr(return_addr_addr());
  }
}
Exemple #5
0
/*
 * Convert an Internet host address given in network byte order
 * to string in standard numbers and dots notation.
 */
PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
{
	static char str8[PJ_INET_ADDRSTRLEN];
    TBuf<PJ_INET_ADDRSTRLEN> str16(0);

    /* (Symbian IP address is in host byte order) */
    TInetAddr temp_addr((TUint32)pj_ntohl(inaddr.s_addr), (TUint)0);
    temp_addr.Output(str16);
 
    return pj_unicode_to_ansi((const wchar_t*)str16.PtrZ(), str16.Length(),
			      str8, sizeof(str8));
}
Exemple #6
0
void frame::oop_iterate(OopClosure* blk) {
  if (is_interpreted_frame()) {
    if (has_interpreted_float_marker() && oop_iterate_interpreted_float_frame(blk)) return;
 
    // lprintf("Frame: fp = %#lx, sp = %#lx]\n", fp(), sp());
    for (oop* p = sp(); p <= temp_addr(0); p++) {
      // lprintf("\t[%#lx]: ", p);
      // (*p)->short_print();
      // lprintf("\n");
      blk->do_oop(p);
    }
    // lprintf("\t{%#lx}: ", receiver_addr());
    // (*receiver_addr())->short_print();
    // lprintf("\n");
    blk->do_oop(receiver_addr());
    return;
  }
  
  if (is_compiled_frame()) {
    if (has_compiled_float_marker() && oop_iterate_compiled_float_frame(blk)) return;

     // All oops are [sp..fp[
    for (oop* p = sp(); p < (oop*)fp(); p++) {
      blk->do_oop(p);
    }
    return;
  }

  if (is_entry_frame()) {
    // All oops are [sp..fp[
    for (oop* p = sp(); p < (oop*)fp(); p++) {
      blk->do_oop(p);
    }
    return;
  }
  
  if (is_deoptimized_frame()) {
    // Expression stack
    oop* end = (oop*)fp() + frame_real_sender_sp_offset;
    // All oops are [sp..end[
    for (oop* p = sp(); p < end; p++) {
      blk->do_oop(p);
    }
    blk->do_oop((oop*)frame_array_addr());
    return;
  }
}
Exemple #7
0
bool frame::oop_iterate_interpreted_float_frame(OopClosure* blk) {
  methodOop m =  methodOopDesc::methodOop_from_hcode(hp());
  // Return if this activation has no floats (the marker is conservative)
  if (!m->has_float_temporaries()) return false;
        
  // Iterator from stack pointer to end of float section
  oop* end = (oop*) addr_at(m->float_section_start_offset() - m->float_section_size());
  for (oop* p = sp(); p <= end; p++) {
    blk->do_oop(p);
  }

  // Skip the float section and magic_value

  // Iterate from just before the float section to the first temp
  for (oop* q = (oop*) addr_at(m->float_section_start_offset() + 2); q <= temp_addr(0); q++) {
    blk->do_oop(q);
  }

  // The receiver
  blk->do_oop(receiver_addr());

  return true;
}
Exemple #8
0
bool frame::follow_roots_interpreted_float_frame() {
  methodOop m = methodOop(hp());
  assert(m->is_method(), "must be method");
  // Return if this activation has no floats (the marker is conservative)
  if (!m->has_float_temporaries()) return false;

  // Iterator from stack pointer to end of float section
  oop* end = (oop*) addr_at(m->float_section_start_offset() - m->float_section_size());
  for (oop* p = sp(); p <= end; p++) {
    MarkSweep::follow_root(p);
  }

  // Skip the float section and magic_value

  // Iterate from just before the float section to the first temp
  for (oop* q = (oop*) addr_at(m->float_section_start_offset() + 2); q <= temp_addr(0); q++) {
    MarkSweep::follow_root(q);
  }

  // The receiver
  MarkSweep::follow_root(receiver_addr());

  return true;
}
Exemple #9
0
 void  set_temp(int offset, oop obj)	{ *temp_addr(offset) = obj; }
Exemple #10
0
 // Temporaries
 oop       temp(int offset) const	{ return *temp_addr(offset); }