Beispiel #1
0
int dot2_init_netlink(struct nlmsghdr *nlh, struct msghdr *msg){
    int ret =0;
	struct confirm_content *confirm;
    struct wme_dot2_pid_request req;

    req.type = DOT2_PID;
    req.operat = SET_MIB;
    req.pid = getpid();

    int fd = create_netlink(msg, nlh);
    if(fd < 0){
        wave_error_printf("fd创建失败");
        return -1;
    }
    memcpy(NLMSG_DATA(nlh), &req, sizeof(struct wme_generic_service_request));
    ret = sendmsg(fd, msg, 0);
	perror(strerror(errno));
    if(ret < 0){
        wave_error_printf("netlink发送消息失败");
        return -1;
    }
	memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));
	ret = recvmsg(fd, msg, 0);
	if(ret < 0){
		wave_error_printf("netlink recvmsg error");
		return -1;
	}
	confirm = (struct confirm_content*)NLMSG_DATA(nlh);
	if(confirm->result != RES_ACCPTED){
		wave_error_printf("zhu ce fail!");
		return -1;
	}
	nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);
    return fd;
}
Beispiel #2
0
static int __init init_hrh_fs(void){
    int ret;

    dprintk("Loading hrhfs......\n");
    ret = create_netlink(&netlinkfd, THIS_MODULE);
    if(ret != 0){
        return -ENOMEM;
    }
    register_filesystem(&hrhfs_fs_type);
    dprintk("Loading hrhfs......Done\n");
    return 0;
}
Beispiel #3
0
/*** Parse sites section ***/
void parse_sites_section(void) {
	NL_OBJECT nl;
	static int in_section=0;

if (!strcmp(wrd[0],"SITES:")) { 
  if (++in_section>1) {
    fprintf(stderr,"Lotos: Unexpected SITES section header on line %d.\n",config_line);
    boot_exit(1);
    }
  return;
  }
if (!wrd[3][0]) {
  fprintf(stderr,"Lotos: Required parameter(s) missing on line %d.\n",config_line);
  boot_exit(1);
  }
if (strlen(wrd[0])>SERV_NAME_LEN) {
  fprintf(stderr,"Lotos: Link name length too long on line %d.\n",config_line);
  boot_exit(1);
  }
if (strlen(wrd[3])>VERIFY_LEN) {
  fprintf(stderr,"Lotos: Verification too long on line %d.\n",config_line);
  boot_exit(1);
  }
if ((nl=create_netlink())==NULL) {
  fprintf(stderr,"Lotos: Memory allocation failure creating netlink on line %d.\n",config_line);
  boot_exit(1);
  }
if (!wrd[4][0] || wrd[4][0]=='#' || !strcmp(wrd[4],"ALL")) nl->allow=ALL;
else if (!strcmp(wrd[4],"IN")) nl->allow=IN;
else if (!strcmp(wrd[4],"OUT")) nl->allow=OUT;
else {
  fprintf(stderr,"Lotos: Unknown netlink access type on line %d.\n",config_line);
  boot_exit(1);
  }
if ((nl->port=atoi(wrd[2]))<1 || nl->port>65535) {
  fprintf(stderr,"Lotos: Illegal port number on line %d.\n",config_line);
  boot_exit(1);
  }
strcpy(nl->service,wrd[0]);
strtolower(wrd[1]);
strcpy(nl->site,wrd[1]);
strcpy(nl->verification,wrd[3]);
}