Exemplo n.º 1
0
s32 socket_sendDataWaitAck(void* data, s32 len, MSG_RESEND_FAILED_HANDLER pfn, void* userdata)
{
    s32 rc = socket_sendData(data, len);

    msg_push(data, len, pfn, userdata);

    return rc;
}
Exemplo n.º 2
0
static void
tx_ui(layer2_t *l2)
{
	msg_t *msg;
	u_char header[MAX_HEADER_LEN];
	int i;

	i = sethdraddr(l2, header, CMD);
	if (test_bit(FLG_LAPD_NET, &l2->flag))
		header[1] = 0xff; /* tei 127 */
	header[i++] = UI;
	while ((msg = msg_dequeue(&l2->ui_queue))) {
		msg_pull(msg, mISDNUSER_HEAD_SIZE);
		memcpy(msg_push(msg, i), header, i);
		msg_push(msg, mISDNUSER_HEAD_SIZE);
		enqueue_ui(l2, msg);
	}
}
Exemplo n.º 3
0
static void
l2_got_ui(struct FsmInst *fi, int event, void *arg)
{
	layer2_t *l2 = fi->userdata;
	msg_t *msg = arg;

	msg_pull(msg, l2headersize(l2, 1));
/*
 *		in states 1-3 for broadcast
 */
	msg_push(msg, mISDNUSER_HEAD_SIZE);
	if (l2up(l2, DL_UNITDATA | INDICATION, CES(l2), msg))
		free_msg(msg);
}
Exemplo n.º 4
0
static void kernel_interrupt_others(register_t pending) {
	for(size_t i=0; i<7; i++) {
		if(pending & (1<<i)) {
			if(int_child[i] == 0) {
				KERNEL_ERROR("unknown interrupt %lx", i);
				continue;
			}
			cp0_status_im_disable(1<<i);
			struct reg_frame * frame = kernel_exception_framep + 0;
			frame->mf_v0 = -3;
			frame->mf_a0 = i;
			if(msg_push(int_child[i], 0, NULL, NULL)) {
				kernel_panic("queue full (int)");
			}
		}
	}
}
Exemplo n.º 5
0
static void
l2_start_multi(struct FsmInst *fi, int event, void *arg)
{
	layer2_t *l2 = fi->userdata;
	msg_t *msg = arg;

	send_uframe(l2, NULL, UA | get_PollFlag(l2, msg), RSP);

	clear_exception(l2);
	l2->vs = 0;
	l2->va = 0;
	l2->vr = 0;
	l2->sow = 0;
	FsmChangeState(fi, ST_L2_7);
	FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3);
	msg_trim(msg, 0);
	msg_push(msg, mISDNUSER_HEAD_SIZE);
	if (l2up(l2, DL_ESTABLISH | INDICATION, CES(l2), msg))
		free_msg(msg);
}
Exemplo n.º 6
0
static void
send_uframe(layer2_t *l2, msg_t *msg, u_char cmd, u_char cr)
{
	u_char tmp[MAX_HEADER_LEN];
	int i;

	i = sethdraddr(l2, tmp, cr);
	tmp[i++] = cmd;
	if (msg)
		msg_trim(msg, 0);
	else if ((msg = alloc_msg(i + mISDNUSER_HEAD_SIZE)))
		msg_reserve(msg, mISDNUSER_HEAD_SIZE);
	else {
		dprint(DBGM_L2, l2->nst->cardnr,"%s: can't alloc msguff\n", __FUNCTION__);
		return;
	}
	memcpy(msg_put(msg, i), tmp, i);
	msg_push(msg, mISDNUSER_HEAD_SIZE);
	enqueue_super(l2, msg);
}
Exemplo n.º 7
0
void
enquiry_cr(layer2_t *l2, u_char typ, u_char cr, u_char pf)
{
	msg_t *msg;
	u_char tmp[MAX_HEADER_LEN];
	int i;

	i = sethdraddr(l2, tmp, cr);
	if (test_bit(FLG_MOD128, &l2->flag)) {
		tmp[i++] = typ;
		tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0);
	} else
		tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0);
	if (!(msg = alloc_msg(i + mISDNUSER_HEAD_SIZE))) {
		dprint(DBGM_L2, l2->nst->cardnr, "isdnl2 can't alloc sbbuff for enquiry_cr\n");
		return;
	} else
		msg_reserve(msg, mISDNUSER_HEAD_SIZE);
	memcpy(msg_put(msg, i), tmp, i);
	msg_push(msg, mISDNUSER_HEAD_SIZE);
	enqueue_super(l2, msg);
}
Exemplo n.º 8
0
static void * monitor_fun(void * arg)
{

	int ret = -1;
	int i = 0;
	
	int epfd = -1;
	int mmc_fd = -1;
	int eth_fd = -1;

	int count_bytes = -1;
	char buf[2048] = {0}; 
	
	mmc_fd = mmc_init_socket();
	if(mmc_fd < 0 )
	{
		dbg_printf("mmc_init_socket is fail ! \n");
	}

	eth_fd = eth_init_socket();
	if(eth_fd < 0)
	{
		dbg_printf("eth_init_socket is fail ! \n");
	}


	struct epoll_event ev;
	struct epoll_event events[16];
	epfd = epoll_create(16);
    ev.events = EPOLLIN;

	if(mmc_fd > 0)
	{
	    ev.data.fd = mmc_fd;
	    ret = epoll_ctl(epfd, EPOLL_CTL_ADD, mmc_fd, &ev);
	}

	if(eth_fd > 0 )
	{
	    ev.data.fd = eth_fd;
	    ret = epoll_ctl(epfd, EPOLL_CTL_ADD, eth_fd, &ev);	
	
	}
	

	while(1)
	{
		ret = epoll_wait(epfd, events, 8, -1);	
		if(ret <= 0)continue;
		for(i=0;i<ret;++i)
		{
			memset(buf,'\0',sizeof(buf));
			if(mmc_fd == events[i].data.fd)
			{
				int flag = -1;
				recv(mmc_fd, buf, sizeof(buf), 0); 
				if(NULL != strstr(buf,"remove") && NULL != strstr(buf,"mmc_host")) {flag = 0;}
				else if( NULL != strstr(buf,"add") && NULL != strstr(buf,"mmc_host")) { flag = 1; }

				if(-1 == flag)continue;
			  
				msg_header_t * msg = calloc(1,sizeof(msg_header_t)+sizeof(monitor_mmc_t)+1);
				if(NULL == msg)continue;
				monitor_mmc_t * mmc_dev = (monitor_mmc_t*)(msg+1);
				msg->cmd = MMC_MSG_CMD;
				mmc_dev->status = flag;
				ret = msg_push(msg);
				if(0 != ret)
				{
					free(msg);
					msg = NULL;
				}
				//dbg_printf("%s\n",buf);
				  
			}
			else if(eth_fd == events[i].data.fd)
			{
				count_bytes = recv(eth_fd,buf, sizeof(buf), 0);
				struct nlmsghdr *p = (struct nlmsghdr *) buf;
				for (; count_bytes > 0; p = NLMSG_NEXT(p, count_bytes))
				{
		            if (!NLMSG_OK(p, count_bytes) || (size_t) count_bytes < sizeof(struct nlmsghdr) || (size_t) count_bytes < p->nlmsg_len)
					{
						dbg_printf("the packet is wrong ! \n");
						break;
		            }
					if(p->nlmsg_type == RTM_NEWLINK || RTM_DELLINK == p->nlmsg_type)
					{
						int status = -1;
						status = eth_link_status();
						dbg_printf("status====%d\n",status);

					}

		
		        }


			}

				
		}
		
	}
	
	return(NULL);
	
}