コード例 #1
0
void SIPRegistrarClient::onNewRegistration(SIPNewRegistrationEvent* new_reg) {

  SIPRegistration* reg = new SIPRegistration(new_reg->handle, new_reg->info, 
					     new_reg->sess_link);
  
  if (uac_auth_i != NULL) {
    DBG("enabling UAC Auth for new registration.\n");
    
    // get a sessionEventHandler from uac_auth
    AmArg di_args,ret;
    AmArg a;
    a.setBorrowedPointer(reg);
    di_args.push(a);
    di_args.push(a);
    DBG("arg type is %d\n", a.getType());

    uac_auth_i->invoke("getHandler", di_args, ret);
    if (!ret.size()) {
      ERROR("Can not add auth handler to new registration!\n");
    } else {
      ArgObject* p = ret.get(0).asObject();
      if (p != NULL) {
	AmSessionEventHandler* h = dynamic_cast<AmSessionEventHandler*>(p);	
	if (h != NULL)
	  reg->setSessionEventHandler(h);
      }
    }
  }
  
  add_reg(new_reg->handle, reg);
  reg->doRegistration();
}
コード例 #2
0
ファイル: devtree.c プロジェクト: E-LLP/n900
static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
		unsigned long *size)
{
	u32 last_addr[MAX_ADDR_CELLS];
	u32 this_addr[MAX_ADDR_CELLS];
	void *parent;
	u64 ret_addr, ret_size;
	u32 naddr, nsize, prev_naddr, prev_nsize;
	int buflen, offset;

	parent = get_parent(node);
	if (!parent)
		return 0;

	dt_get_reg_format(parent, &naddr, &nsize);

	if (nsize > 2)
		return 0;

	offset = (naddr + nsize) * res;

	if (reglen < offset + naddr + nsize ||
	    MAX_PROP_LEN < (offset + naddr + nsize) * 4)
		return 0;

	copy_val(last_addr, prop_buf + offset, naddr);

	ret_size = prop_buf[offset + naddr];
	if (nsize == 2) {
		ret_size <<= 32;
		ret_size |= prop_buf[offset + naddr + 1];
	}

	for (;;) {
		prev_naddr = naddr;
		prev_nsize = nsize;
		node = parent;

		parent = get_parent(node);
		if (!parent)
			break;

		dt_get_reg_format(parent, &naddr, &nsize);

		buflen = getprop(node, "ranges", prop_buf,
				sizeof(prop_buf));
		if (buflen == 0)
			continue;
		if (buflen < 0 || buflen > sizeof(prop_buf))
			return 0;

		offset = find_range(last_addr, prop_buf, prev_naddr,
		                    naddr, prev_nsize, buflen / 4);

		if (offset < 0)
			return 0;

		copy_val(this_addr, prop_buf + offset, prev_naddr);

		if (!sub_reg(last_addr, this_addr))
			return 0;

		copy_val(this_addr, prop_buf + offset + prev_naddr, naddr);

		if (!add_reg(last_addr, this_addr, naddr))
			return 0;
	}

	if (naddr > 2)
		return 0;

	ret_addr = ((u64)last_addr[2] << 32) | last_addr[3];

	if (sizeof(void *) == 4 &&
	    (ret_addr >= 0x100000000ULL || ret_size > 0x100000000ULL ||
	     ret_addr + ret_size > 0x100000000ULL))
		return 0;

	*addr = ret_addr;
	if (size)
		*size = ret_size;

	return 1;
}
コード例 #3
0
static void add_modrm(unsigned modrm, unsigned size) {
    unsigned mod = (modrm >> 6) & 3;
    unsigned rm = modrm & 7;
    if (mod == 3) {
        add_reg(rm, size);
    }
    else {
        switch (size) {
        case 1: add_str("byte"); break;
        case 2: add_str("word"); break;
        case 4: add_str("dword"); break;
        case 8: add_str("qword"); break;
        }
        add_char('[');
        if (addr_size == 4) {
            switch (rm) {
            case 0: add_str("eax"); break;
            case 1: add_str("acx"); break;
            case 2: add_str("edx"); break;
            case 3: add_str("ebx"); break;
            case 4:
                {
                    uint8_t sib = get_code();
                    unsigned base = sib & 7;
                    unsigned index = (sib >> 3) & 7;
                    unsigned scale = (sib >> 6) & 3;
                    int bs = 0;
                    if ((mod == 0 && base != 5) || mod == 1 || mod == 2) {
                        add_reg(base, 4);
                        bs = 1;
                    }
                    if (index != 4) {
                        if (bs) add_char('+');
                        add_reg(index, 4);
                        switch (scale) {
                        case 1: add_str("*2"); break;
                        case 2: add_str("*4"); break;
                        case 3: add_str("*8"); break;
                        }
                        bs = 1;
                    }
                    if ((mod == 0 && base == 5) || mod == 2) {
                        if (bs) add_char('+');
                        add_disp32();
                    }
                    else if (mod == 1) {
                        add_disp8();
                    }
                    add_char(']');
                }
                return;
            case 5: if (mod != 0) add_str("ebp"); break;
            case 6: add_str("esi"); break;
            case 7: add_str("edi"); break;
            }
        }
        else {
            switch (rm) {
            case 0: add_str("bx+si"); break;
            case 1: add_str("bx+di"); break;
            case 2: add_str("bp+si"); break;
            case 3: add_str("bp+di"); break;
            case 4: add_str("si"); break;
            case 5: add_str("di"); break;
            case 6: if (mod != 0) add_str("bp"); break;
            case 7: add_str("bx"); break;
            }
        }
        switch (mod) {
        case 0:
            if (addr_size == 2 && rm == 6) add_disp16();
            if (addr_size == 4 && rm == 5) add_disp32();
            if (addr_size == 8 && rm == 5) add_disp32();
            break;
        case 1:
            add_disp8();
            break;
        case 2:
            add_char('+');
            if (addr_size <= 2) add_disp16();
            else add_disp32();
            break;
        }
        add_char(']');
    }