예제 #1
0
파일: io.c 프로젝트: ebichu/dd-wrt
void notify(const UN_CTX *ctx,uint32_t ip,const ENTRY *entry)
{
    struct atmarp_req reply;

    memset(&reply,0,sizeof(reply));
    reply.type = art_query;
    reply.ip = ip;
    if (entry && entry->addr) reply.addr = *entry->addr;
    if (un_send(ctx,&reply,sizeof(reply)) < 0)
        diag(COMPONENT,DIAG_WARN,"notify: %s",strerror(errno));
}
예제 #2
0
int un_reply(int s,void *buf,int size,
  int (*handler)(void *buf,int len,void *user),void *user)
{
    UN_CTX ctx;
    int len;

    len = un_recv(&ctx,s,buf,size);
    if (len < 0) return len;
    len = handler(buf,len,user);
    if (len <= 0) return len;
    return un_send(&ctx,buf,len);
}
예제 #3
0
파일: io.c 프로젝트: ebichu/dd-wrt
static void recv_unix(void)
{
    UN_CTX ctx;
    struct atmarp_req req;
    int len,reply;

    len = un_recv(&ctx,unix_sock,&req,sizeof(req));
    if (len < 0) {
	diag(COMPONENT,DIAG_ERROR,"recv_unix: %s",strerror(errno));
	return;
    }
    if (len != sizeof(req)) {
	diag(COMPONENT,DIAG_ERROR,"bad unix read: %d != %d",len,sizeof(req));
	return;
    }
    switch (req.type) {
	case art_create:
	    reply = ioctl(kernel,SIOCMKCLIP,req.itf);
	    if (reply >= 0) itf_create(reply);
	    break;
	case art_qos:
	case art_set:
	case art_delete:
	    reply = arp_ioctl(&req);
	    break;
	case art_table:
	    reply = table_update();
	    break;
	case art_query:
	    query_ip(&ctx,req.ip);
	    return;
	default:
	    diag(COMPONENT,DIAG_ERROR,"invalid request msg type 0x%x",req.type);
	    reply = -EINVAL;
    }
    if (un_send(&ctx,&reply,sizeof(reply)) < 0)
	diag(COMPONENT,DIAG_ERROR,"un_send: %s",strerror(errno));
}