예제 #1
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_pfc_state(char *ifname, __u8 *state)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_PFC_GSTATE);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);

	if (send_msg(nlh))
		return -EIO;
	free(nlh);

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_PFC_GSTATE) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}

	if (rta->rta_type != DCB_ATTR_PFC_STATE) {
		return -EIO;
	}
	*state = *(__u8 *)NLA_DATA(rta);
	return 0;
}
예제 #2
0
파일: filter.cpp 프로젝트: Andrew-He/botan
/*
* Start a new message
*/
void Filter::new_msg()
   {
   start_msg();
   for(size_t j = 0; j != total_ports(); ++j)
      if(m_next[j])
         m_next[j]->new_msg();
   }
예제 #3
0
파일: nltest.c 프로젝트: openSUSE/lldpad
int set_ieee(char *ifname, struct ieee_ets *ets_data, struct ieee_pfc *pfc_data,
	     struct dcb_app *app_data)
{
	struct nlmsghdr *nlh;
	struct rtattr *ieee, *apptbl;

	nlh = start_msg(RTM_SETDCB, DCB_CMD_IEEE_SET);
	if (NULL == nlh)
		return -EIO;

	addattr_l(nlh, DCB_ATTR_IFNAME, ifname, strlen(ifname) + 1);
	ieee = addattr_nest(nlh, DCB_ATTR_IEEE);
	if (ets_data)
		addattr_l(nlh, DCB_ATTR_IEEE_ETS, ets_data, sizeof(*ets_data));
	if (pfc_data)
		addattr_l(nlh, DCB_ATTR_IEEE_PFC, pfc_data, sizeof(*pfc_data));
	if (app_data) {
		apptbl = addattr_nest(nlh, DCB_ATTR_IEEE_APP_TABLE);
		addattr_l(nlh, DCB_ATTR_IEEE_APP, app_data, sizeof(*app_data));
#if 1
		app_data->protocol++;
		addattr_l(nlh, DCB_ATTR_IEEE_APP, app_data, sizeof(*app_data));
#endif
		addattr_nest_end(nlh, apptbl);
	}
	addattr_nest_end(nlh, ieee);

	if (send_msg(nlh))
		return -EIO;

	return recv_msg(DCB_CMD_IEEE_SET, DCB_ATTR_IEEE);
}
예제 #4
0
파일: nltest.c 프로젝트: openSUSE/lldpad
int set_hw_app0(char *ifname, appgroup_attribs *app_data)
{
	struct nlmsghdr *nlh;
	struct rtattr *rta_parent, *rta_child;

	printf("set_hw_app0: %s\n", ifname);

	nlh = start_msg(RTM_SETDCB, DCB_CMD_SAPP);
	if (NULL == nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_APP, NULL, 0);

	rta_child = add_rta(nlh, DCB_APP_ATTR_IDTYPE,
		(void *)&app_data->dcb_app_idtype, sizeof(__u8));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_APP_ATTR_ID,
		(void *)&app_data->dcb_app_id, sizeof(__u16));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_APP_ATTR_PRIORITY,
		(void *)&app_data->dcb_app_priority, sizeof(__u8));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	return(recv_msg(DCB_CMD_SAPP, DCB_ATTR_APP));
}
예제 #5
0
파일: filter.cpp 프로젝트: graydon/monotone
/*************************************************
* Start a new message                            *
*************************************************/
void Filter::new_msg()
   {
   start_msg();
   for(u32bit j = 0; j != total_ports(); ++j)
      if(next[j])
         next[j]->new_msg();
   }
예제 #6
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_pfc_cfg(char *ifname, __u8 *pfc)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta_parent, *rta_child;
	int i;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_PFC_GCFG);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname,
		strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_PFC_CFG, NULL, 0);

	rta_child = add_rta(nlh, DCB_PFC_UP_ATTR_ALL, NULL, 0);
	rta_parent->rta_len += NLMSG_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta_parent = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_PFC_GCFG) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}
	if (rta_parent->rta_type != DCB_ATTR_PFC_CFG) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		return -EIO;
	}
	rta_child = NLA_DATA(rta_parent);
	rta_parent = (struct rtattr *)((char *)rta_parent +
				       NLMSG_ALIGN(rta_parent->rta_len));
	for (i = 0; rta_parent > rta_child; i++) {
		if (i == 8) {
			printf("pfc array out of range\n");
			break;
		}
		pfc[rta_child->rta_type - DCB_PFC_UP_ATTR_0] =
			*(__u8 *)NLA_DATA(rta_child);
		rta_child = (struct rtattr *)((char *)rta_child +
					      NLMSG_ALIGN(rta_child->rta_len));
	}
	if (rta_parent != rta_child)
		printf("rta pointers are off\n");

	return 0;
}
예제 #7
0
파일: srlog2.c 프로젝트: bruceg/srlog2
static int make_msg(void)
{
  const struct line* line;
  if ((line = buffer->read()) == 0)
    return 0;
  start_msg(line);
  while ((line = buffer->peek()) != 0) {
    if (!add_msg(line))
      break;
    buffer->read();
  }
  end_msg();
  return 1;
}
예제 #8
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int set_state(char *ifname, __u8 state)
{
	struct nlmsghdr *nlh;

	nlh = start_msg(RTM_SETDCB, DCB_CMD_SSTATE);
	if (NULL == nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	add_rta(nlh, DCB_ATTR_STATE, (void *)&state, sizeof(__u8));

	if (send_msg(nlh))
		return -EIO;

	return(recv_msg(DCB_CMD_SSTATE, DCB_ATTR_STATE));
}
예제 #9
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_perm_hwaddr(char *ifname, __u8 *buf_perm, __u8 *buf_san)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_GPERM_HWADDR);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	add_rta(nlh, DCB_ATTR_PERM_HWADDR, NULL, 0);
	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh) {
		printf("get msg failed\n");
		return -EIO;
	}

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_GPERM_HWADDR) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}

	if (rta->rta_type != DCB_ATTR_PERM_HWADDR) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		return -EIO;
	}

	memcpy(buf_perm, NLA_DATA(rta), ETH_ALEN);
	memcpy(buf_san, NLA_DATA(rta + ETH_ALEN*sizeof(__u8)), ETH_ALEN);

	return 0;
}
예제 #10
0
파일: nltest.c 프로젝트: openSUSE/lldpad
/* returns: 0 on success
 *          1 on failure
*/
static int set_numtcs(char *ifname, int tcid, __u8 numtcs)
{
	struct nlmsghdr *nlh;
	struct rtattr *rta_parent, *rta_child;

	printf("set_numtcs_cfg: %s\n", ifname);

	nlh = start_msg(RTM_SETDCB, DCB_CMD_SNUMTCS);
	if (NULL == nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_NUMTCS, NULL, 0);
	rta_child = add_rta(nlh, tcid, &numtcs, sizeof(__u8));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	return(recv_msg(DCB_CMD_SNUMTCS, DCB_ATTR_NUMTCS));
}
예제 #11
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_state(char *ifname, __u8 *state)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_GSTATE);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);

	if (send_msg(nlh))
		return -EIO;

	free(nlh);

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_GSTATE) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}
	if (rta->rta_type != DCB_ATTR_STATE) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		return -EIO;
	}
	*state = *(__u8 *)NLA_DATA(rta);

	return 0;
}
예제 #12
0
파일: pipe.cpp 프로젝트: AlexNk/botan
/*
* Process a full message at once
*/
void Pipe::process_msg(const byte input[], size_t length)
   {
   start_msg();
   write(input, length);
   end_msg();
   }
예제 #13
0
파일: nltest.c 프로젝트: openSUSE/lldpad
/* returns: 0 on success
 *          1 on failure
*/
static int set_bcn_cfg(char *ifname, bcn_cfg *bcn_data)
{
	struct nlmsghdr *nlh;
	struct rtattr *rta_parent, *rta_child;

	int i;
	int temp_int;

	printf("set_bcn_cfg: %s\n", ifname);

	nlh = start_msg(RTM_SETDCB, DCB_CMD_BCN_SCFG);
	if (NULL == nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_BCN, NULL, 0);
	for (i = DCB_BCN_ATTR_RP_0; i <= DCB_BCN_ATTR_RP_7; i++) {
		rta_child = add_rta(nlh, i,
		   (void *)&bcn_data->up_settings[i - DCB_BCN_ATTR_RP_0].rp_admin,
		     sizeof(__u8));
		rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);
	}

	temp_int = 0;
	for (i = 0; i < BCN_ADDR_OPTION_LEN/2; i++)
		temp_int |= bcn_data->bcna[i]<<(i*8);
	rta_child = add_rta(nlh, DCB_BCN_ATTR_BCNA_0,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = 0;
	for (i = BCN_ADDR_OPTION_LEN/2; i < BCN_ADDR_OPTION_LEN; i++)
		temp_int |= bcn_data->bcna[i]<<((i- BCN_ADDR_OPTION_LEN/2)*8);
	rta_child = add_rta(nlh, DCB_BCN_ATTR_BCNA_1,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_BCN_ATTR_ALPHA,
		(void *)&bcn_data->rp_alpha, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_BCN_ATTR_BETA,
		(void *)&bcn_data->rp_beta, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_BCN_ATTR_GD,
		(void *)&bcn_data->rp_gd, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_BCN_ATTR_GI,
		(void *)&bcn_data->rp_gi, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_BCN_ATTR_TMAX,
		(void *)&bcn_data->rp_tmax, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = (int)bcn_data->rp_td;
	rta_child = add_rta(nlh, DCB_BCN_ATTR_TD,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = (int)bcn_data->rp_rmin;
	rta_child = add_rta(nlh, DCB_BCN_ATTR_RMIN,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = (int)bcn_data->rp_w;
	rta_child = add_rta(nlh, DCB_BCN_ATTR_W,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = (int)bcn_data->rp_rd;
	rta_child = add_rta(nlh, DCB_BCN_ATTR_RD,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = (int)bcn_data->rp_ru;
	rta_child = add_rta(nlh, DCB_BCN_ATTR_RU,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	temp_int = (int)bcn_data->rp_wrtt;
	rta_child = add_rta(nlh, DCB_BCN_ATTR_WRTT,
		(void *)&temp_int, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_BCN_ATTR_RI,
		(void *)&bcn_data->rp_ri, sizeof(__u32));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	return(recv_msg(DCB_CMD_BCN_SCFG, DCB_ATTR_BCN));
}
예제 #14
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_bcn(char *ifname, bcn_cfg *bcn_data)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta_parent, *rta_child;
	int i, j;
	unsigned int temp_int;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_BCN_GCFG);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname,
		strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_BCN, NULL, 0);
	rta_child = add_rta(nlh, DCB_BCN_ATTR_ALL, NULL, 0);
	rta_parent->rta_len += NLMSG_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh)
	{
		printf("error getting BCN cfg.\n");
		return -EIO;
	}

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta_parent = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_BCN_GCFG) {
		printf("Hmm, this is not the message we were expecting.\n");
		free(nlh);
		return -EIO;
	}
	if (rta_parent->rta_type != DCB_ATTR_BCN) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with rtnl and attribute support) "
		       "would sure be nice.\n");
		free(nlh);
		return -EIO;
	}
	rta_child = NLA_DATA(rta_parent);
	rta_parent = (struct rtattr *)((char *)rta_parent +
				       NLMSG_ALIGN(rta_parent->rta_len));
	for (i = 0; rta_parent > rta_child; i++) {
		if (i == DCB_BCN_ATTR_RP_ALL - DCB_BCN_ATTR_RP_0) {
			printf("bcn param out of range\n");
			break;
		}
		bcn_data->up_settings[rta_child->rta_type
			- DCB_BCN_ATTR_RP_0].rp_admin =
				*(__u8 *)NLA_DATA(rta_child);
		rta_child = (struct rtattr *)((char *)rta_child +
					      NLMSG_ALIGN(rta_child->rta_len));

	}

	for (i = 0; i < BCN_ADDR_OPTION_LEN/4; i++) { /*2 bytes for BCNA data */
		temp_int = *(__u32 *)NLA_DATA(rta_child);
		rta_child = (struct rtattr *)((char *)rta_child +
					     NLMSG_ALIGN(rta_child->rta_len));
		for (j = 0; j < 4; j++) {
			bcn_data->bcna[j+i*4] =
			    (__u8)((temp_int & (0xFF << (j*8))) >> (j*8));
		}
	}

	memcpy((void *)&bcn_data->rp_alpha, (__u32 *)NLA_DATA(rta_child),
		sizeof(__u32));
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	memcpy((void *)&bcn_data->rp_beta, (__u32 *)NLA_DATA(rta_child),
		sizeof(__u32));
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	memcpy((void *)&bcn_data->rp_gd, (__u32 *)NLA_DATA(rta_child),
		sizeof(__u32));
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	memcpy((void *)&bcn_data->rp_gi, (__u32 *)NLA_DATA(rta_child),
		sizeof(__u32));
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_tmax = *(__u32 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_td = *(__u16 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_rmin = *(__u16 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_w = *(__u8 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_rd = *(__u8 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_ru = *(__u8 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_wrtt = *(__u8 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	bcn_data->rp_ri = *(__u32 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	if (rta_parent != rta_child)
		printf("rta pointers are off\n");

	return 0;
}
예제 #15
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_numtcs(char *ifname, int tcid, __u8 *numtcs)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta_parent, *rta_child;
	int found;
	int i;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_GNUMTCS);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_NUMTCS, NULL, 0);

	rta_child = add_rta(nlh, DCB_NUMTCS_ATTR_ALL, NULL, 0);
	rta_parent->rta_len += NLMSG_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta_parent = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_GNUMTCS) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}
	if (rta_parent->rta_type != DCB_ATTR_NUMTCS) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		return -EIO;
	}
	rta_child = NLA_DATA(rta_parent);
	rta_parent = (struct rtattr *)((char *)rta_parent +
				       NLMSG_ALIGN(rta_parent->rta_len));

	found = 0;
	for (i = 0; rta_parent > rta_child; i++) {

		if (!found && rta_child->rta_type == tcid) {
			*numtcs = *(__u8 *)NLA_DATA(rta_child);
			found = 1;
		}

		rta_child = (struct rtattr *)((char *)rta_child +
					      NLMSG_ALIGN(rta_child->rta_len));
	}
	if (rta_parent != rta_child)
		printf("rta pointers are off\n");

	if (found)
		return 0;
	else	return -1;
}
예제 #16
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_cap(char *ifname, __u8 *cap)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta_parent, *rta_child;
	int i;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_GCAP);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_CAP, NULL, 0);

	rta_child = add_rta(nlh, DCB_CAP_ATTR_ALL, NULL, 0);
	rta_parent->rta_len += NLMSG_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta_parent = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_GCAP) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}
	if (rta_parent->rta_type != DCB_ATTR_CAP) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		return -EIO;
	}

	rta_child = NLA_DATA(rta_parent);
	rta_parent = (struct rtattr *)((char *)rta_parent +
				       NLMSG_ALIGN(rta_parent->rta_len));
	for (i = 0; rta_parent > rta_child; i++) {
		if (i == 8) {
			printf("cap array out of range\n");
			break;
		}

		cap[rta_child->rta_type] = *(__u8 *)NLA_DATA(rta_child);

		switch (rta_child->rta_type) {
		case DCB_CAP_ATTR_ALL:
			break;
		case DCB_CAP_ATTR_PG:
			printf("pg:      ");
			break;
		case DCB_CAP_ATTR_PFC:
			printf("pfc:     ");
			break;
		case DCB_CAP_ATTR_UP2TC:
			printf("up2tc:   ");
			break;
		case DCB_CAP_ATTR_PG_TCS:
			printf("pg tcs:  ");
			break;
		case DCB_CAP_ATTR_PFC_TCS:
			printf("pfc tcs: ");
			break;
		case DCB_CAP_ATTR_GSP:
			printf("gsp:     ");
			break;
		case DCB_CAP_ATTR_BCN:
			printf("bcn:     ");
			break;
		case DCB_CAP_ATTR_DCBX:
			printf("dcbx:    ");
			break;
		default:
			printf("unknown type: ");
			break;
		}
		printf("%02x\n", cap[rta_child->rta_type]);

		rta_child = (struct rtattr *)((char *)rta_child +
					      NLMSG_ALIGN(rta_child->rta_len));
	}
	if (rta_parent != rta_child)
		printf("rta pointers are off\n");

	return 0;
}
예제 #17
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_app_cfg(char *ifname, appgroup_attribs *app_data)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *rta_parent, *rta_child;
	int rval = 0;
	__u8 idtype;
	__u16 id;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_GAPP);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	rta_parent = add_rta(nlh, DCB_ATTR_APP, NULL, 0);

	rta_child = add_rta(nlh, DCB_APP_ATTR_IDTYPE,
		(void *)&app_data->dcb_app_idtype, sizeof(__u8));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	rta_child = add_rta(nlh, DCB_APP_ATTR_ID,
		(void *)&app_data->dcb_app_id, sizeof(__u16));
	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);

	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	rta_parent = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != DCB_CMD_GAPP) {
		printf("Hmm, this is not the message we were expecting.\n");
		rval = -EIO;
		goto get_error;
	}
	if (rta_parent->rta_type != DCB_ATTR_APP) {
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		rval = -EIO;
		goto get_error;
	}

	rta_child = NLA_DATA(rta_parent);
	rta_parent = (struct rtattr *)((char *)rta_parent +
				       NLMSG_ALIGN(rta_parent->rta_len));

	idtype = *(__u8 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));
	if (idtype != app_data->dcb_app_idtype) {
		rval = -EIO;
		goto get_error;
	}

	id = *(__u16 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));
	if (id != app_data->dcb_app_id) {
		rval = -EIO;
		goto get_error;
	}

	app_data->dcb_app_priority = *(__u8 *)NLA_DATA(rta_child);
	rta_child = (struct rtattr *)((char *)rta_child +
				      NLMSG_ALIGN(rta_child->rta_len));

	if (rta_parent != rta_child)
		printf("rta pointers are off\n");

get_error:
	free(nlh);
	return rval;
}
예제 #18
0
파일: pipe.cpp 프로젝트: AlexNk/botan
/*
* Process a full message at once
*/
void Pipe::process_msg(DataSource& input)
   {
   start_msg();
   write(input);
   end_msg();
   }
예제 #19
0
파일: nltest.c 프로젝트: openSUSE/lldpad
int get_ieee(char *ifname)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *dcb, *ieee[DCB_ATTR_IEEE_MAX+1];
	struct rtattr *tb[DCB_ATTR_MAX + 1];
	int len;

	nlh = start_msg(RTM_GETDCB, DCB_CMD_IEEE_GET);
	if (NULL == nlh) {
		printf("start_msg failed\n");
		return -EIO;
	}

	addattr_l(nlh, DCB_ATTR_IFNAME, ifname, strlen(ifname) + 1);
	if (send_msg(nlh)) {
		printf("send failure\n");
		return -EIO;
	}

	/* Receive 802.1Qaz parameters */
	memset(nlh, 0, MAX_MSG_SIZE);
	len = recv(nl_sd, (void *)nlh, MAX_MSG_SIZE, 0);
	if (len < 0) {
		perror("ieee_get");
		return -EIO;
	}

	if (nlh->nlmsg_type != RTM_GETDCB) {
		struct nlmsgerr *err = (struct nlmsgerr *) NLMSG_DATA(nlh);
		if (nlh->nlmsg_type == NLMSG_ERROR) {
			printf("NLMSG_ERROR: err(%i): %s\n",
				err->error, strerror(err->error * -1));
		}
		return -1;
	}

	d = NLMSG_DATA(nlh);
	len -= NLMSG_LENGTH(sizeof(*d));
	if (len < 0) {
		printf("Broken message\n");
		return -1;
	}

	parse_rtattr(tb, DCB_ATTR_MAX, DCB_RTA(d), len);
	if (!tb[DCB_ATTR_IEEE]) {
		printf("Missing DCB_ATTR_IEEE attribute!\n");
		return -1;
	}

	if (tb[DCB_ATTR_IFNAME]) {
		printf("\tifname %s\n", (char *)RTA_DATA(tb[DCB_ATTR_IFNAME]));
	} else {
		printf("Missing DCB_ATTR_IFNAME attribute!\n");
		return -1;
	}

	dcb = tb[DCB_ATTR_IEEE];
	parse_rtattr_nested(ieee, DCB_ATTR_IEEE_MAX, dcb);
	if (ieee[DCB_ATTR_IEEE_ETS]) {
		struct ieee_ets *ets = RTA_DATA(ieee[DCB_ATTR_IEEE_ETS]);
		print_ets(ets);
	}

	if (ieee[DCB_ATTR_IEEE_PFC]) {
		struct ieee_pfc *pfc = RTA_DATA(ieee[DCB_ATTR_IEEE_PFC]);
		print_pfc(pfc);
	}

	if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
		struct rtattr *i, *app_list = ieee[DCB_ATTR_IEEE_APP_TABLE];
		int rem = RTA_PAYLOAD(app_list);
		printf("APP:\n");
		for (i = RTA_DATA(app_list);
		     RTA_OK(i, rem);
		     i = RTA_NEXT(i, rem))
			print_app(i);
	}

	return 0;
}
예제 #20
0
파일: nltest.c 프로젝트: openSUSE/lldpad
int main(int argc, char *argv[])
{
	struct tc_config tc[8];
	int i, err = 0;
	int newstate = -1;
	int read_only = 0;
	__u8 state;
	__u8 pfc[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
	__u8 bwg[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
	__u8 mac[ETH_ALEN], san_mac[ETH_ALEN];
	__u8 cap[DCB_CAP_ATTR_MAX+1];
	__u8 numtcs;
	bcn_cfg bcn_set_data, bcn_data;
#ifdef DCB_APP_DRV_IF_SUPPORTED
	appgroup_attribs app_data = {DCB_APP_IDTYPE_ETHTYPE, 0x8906, 0x08};
#endif /* DCB_APP_DRV_IF_SUPPORTED */
	int ifindex;
	int optind = 1;
	char *ifname;

	printf("Calling RTNETLINK interface.\n");
	if (argc < 2) {
		fprintf(stderr, "usage: %s [-v] <ifname> [on|off|ro]\n",
			argv[0]);
		exit(1);
	}

	if (argc > 2) {
		if (!strcmp(argv[1], "-v")) {
			hexdump = 1;
			optind++;
		}
		if (argc > optind + 1) {
			if (!strcmp(argv[optind + 1], "on"))
				newstate = 1;
			if (!strcmp(argv[optind + 1], "off"))
				newstate = 0;
			if (!strcmp(argv[optind + 1], "ro"))
				read_only = 1;
		}
	}
	ifname = argv[optind];
	ifindex = if_nametoindex(ifname);
	if (ifindex == 0) {
		printf("no ifindex for %s\n", ifname);
		exit(1);
	}

	if ((nl_sd = init_socket()) < 0) {
		fprintf(stderr, "error creating netlink socket\n");
		return nl_sd;
	}

#ifdef DO_GETLINK_QUERY
	printf("DOING A GETLINK COMMAND\n");
	nlh = start_msg(RTM_GETLINK, ifindex);
	if (nlh == NULL)
		exit(1);
	if (send_msg(nlh))
		exit(1);
	free(nlh);
	nlh = get_msg();
#endif

	printf("GETTING DCB STATE\n");
	err = get_state(ifname, &state);
	if (err) {
		fprintf(stderr, "Error getting DCB state\n");
		goto err_main;
	}
	printf("DCB State = %d\n", state);

	if (newstate >= 0) {
		printf("\nSETTING DCB STATE TO: %d\n", newstate);
		err = set_state(ifname, newstate);
		if (err)
			goto err_main;

		err = get_state(ifname, &state);
		if (err) {
			fprintf(stderr, "Error getting DCB state\n");
			goto err_main;
		}
		printf("New DCB State = %d\n", state);
	}

	printf("\nGETTING PFC CONFIGURATION\n");
	for (i=0; i<8; i++)
		pfc[i] = 0x0f;
	get_pfc_cfg(ifname, pfc);
	printf("PFC config:\n");
	for (i=0; i<8; i++)
		printf("%x ", pfc[i]);
	printf("\n");

	get_pfc_state(ifname, &state);
	if (err) {
		fprintf(stderr, "Error getting PFC status\n");
		goto err_main;
	}
	printf("PFC State = %d\n", state);

	printf("\nGETTING PG TX CONFIGURATION\n");
	get_pg(ifname, tc, bwg, DCB_CMD_PGTX_GCFG);
	for (i = 0; i < 8; i++) {
		printf("%d: pr=%d\tbwgid=%d\tbw%%=%d\tu2t=%d\tlk%%=%d\n", i,
			tc[i].prio_type,
			tc[i].bwg_id,
			tc[i].bwg_percent,
			tc[i].up_to_tc_bitmap,
			bwg[i]);

		tc[i].prio_type = 3;
		tc[i].bwg_id = i;
		tc[i].bwg_percent = 100;
		tc[i].up_to_tc_bitmap = i;
		bwg[i] = 12 + (i & 1);
	}

	printf("\nGETTING PG RX CONFIGURATION\n");
	memset(bwg, 0, sizeof(bwg));
	memset(&tc[0], 0, sizeof(tc));
	get_pg(ifname, tc, bwg, DCB_CMD_PGRX_GCFG);
	for (i = 0; i < 8; i++) {
		printf("%d: pr=%d\tbwgid=%d\tbw%%=%d\tu2t=%d\tlk%%=%d\n", i,
			tc[i].prio_type,
			tc[i].bwg_id,
			tc[i].bwg_percent,
			tc[i].up_to_tc_bitmap,
			bwg[i]);
	}

	printf("\nGETTING PERMANENT MAC: ");
	get_perm_hwaddr(ifname, mac, san_mac);
	for (i = 0; i < 5; i++)
		printf("%02x:", mac[i]);
	printf("%02x\n", mac[i]);

	printf("\nGETTING SAN MAC: ");
	for (i = 0; i < 5; i++)
		printf("%02x:", san_mac[i]);
	printf("%02x\n", san_mac[i]);

	printf("\nGETTING DCB CAPABILITIES\n");
	get_cap(ifname, &cap[0]);

	printf("\nGET NUMBER OF PG TCS\n");
	if (!get_numtcs(ifname, DCB_NUMTCS_ATTR_PG, &numtcs))
		printf("num = %d\n", numtcs);
	else	printf("not found\n");

	printf("\nGET NUMBER OF PFC TCS\n");
	if (!get_numtcs(ifname, DCB_NUMTCS_ATTR_PFC, &numtcs))
		printf("num = %d\n", numtcs);
	else	printf("not found\n");

	if (!read_only) {
		printf("\nTEST SET NUMBER OF PG TCS\n");
		if (!set_numtcs(ifname, DCB_NUMTCS_ATTR_PG, numtcs))
			printf("set passed\n");
		else	printf("error\n");

		printf("\nTEST SET NUMBER OF PFC TCS\n");
		if (!set_numtcs(ifname, DCB_NUMTCS_ATTR_PFC, numtcs))
			printf("set passed\n");
		else	printf("error\n\n");

/*	printf("set_pfc_cfg = %d\n", set_pfc_cfg(ifname, pfc)); */
/*	printf("set_rx_pg = %d\n", set_pg(ifname, tc, bwg, DCB_CMD_PGRX_SCFG));*/
/*	printf("set_hw_all = %d\n", set_hw_all(ifname)); */

		err = set_hw_bcn(ifname, &bcn_set_data, 1);
		printf("set_bcn_cfg result is %d.\n", err);

		/*set_hw_all(ifname);*/
	}

	printf("\nGETTING BCN:\n");
	if (!get_bcn(ifname, &bcn_data)) {
		for (i = 0; i < 8; i++) {
			printf("BCN RP %d: %d\n", i,
			       bcn_data.up_settings[i].rp_admin);
		}
		printf("\nBCN RP ALPHA: %f\n", bcn_data.rp_alpha);
		printf("BCN RP BETA : %f\n", bcn_data.rp_beta);
		printf("BCN RP GD   : %f\n", bcn_data.rp_gd);
		printf("BCN RP GI   : %f\n", bcn_data.rp_gi);
		printf("BCN RP TMAX : %d\n", bcn_data.rp_tmax);
		printf("BCN RP RI   : %d\n", bcn_data.rp_ri);
		printf("BCN RP TD   : %d\n", bcn_data.rp_td);
		printf("BCN RP RMIN : %d\n", bcn_data.rp_rmin);
		printf("BCN RP W    : %d\n", bcn_data.rp_w);
		printf("BCN RP RD   : %d\n", bcn_data.rp_rd);
		printf("BCN RP RU   : %d\n", bcn_data.rp_ru);
		printf("BCN RP WRTT : %d\n", bcn_data.rp_wrtt);
	} else	printf("not found\n");

#ifdef DCB_APP_DRV_IF_SUPPORTED
	if (!read_only) {
		printf("\nSETTING APP:\n");
		if (set_hw_app0(ifname, &app_data)) {
			printf("Fail to set app data.\n");
			goto err_main;
		}
	}

	printf("\nGETTING APP:\n");
	if (!get_app_cfg(ifname, &app_data)) {
		printf("APP ID TYPE: ");
		if (app_data.dcb_app_idtype)
			printf(" \t DCB_APP_IDTYPE_ETHTYPE.\n");
		else
			printf(" \t DCB_APP_IDTYPE_PORTNUM.\n");

		printf(" APP ID: 0x%0x.\n", app_data.dcb_app_id);
		printf(" APP PRIORITY: 0x%0x.\n", app_data.dcb_app_priority);
	}
	else {
		printf("GETTING APP FAILED!.\n");
	}
#endif /* DCB_APP_DRV_IF_SUPPORTED */

	if (!read_only) {
		struct ieee_ets ets = {
			.willing = 0, .ets_cap = 0x1, .cbs = 0,
			.tc_tx_bw = {25, 25, 25, 25, 0, 0, 0, 0},
			.tc_rx_bw = {0, 0, 0, 0, 25, 25, 25, 25},
			.tc_tsa = {1, 2, 3, 4, 1, 2, 3, 4},
			.prio_tc = {1, 2, 3, 4, 1, 2, 3, 4}
		};
		struct ieee_pfc pfc = {
			.pfc_cap = 0xf1, .pfc_en = 0, .mbc = 0, .delay = 0x32
		};
		struct dcb_app app = {
			.selector = 0, .priority = 4, .protocol = 0x8906
		};

		printf("\nSETTING ETS:\n");
		set_ieee(ifname, &ets, &pfc, &app);
	}

	get_ieee(ifname);

err_main:
	close(nl_sd);
	return err;
}
예제 #21
0
파일: ai_client.c 프로젝트: rpcraig/rftg
/*
 * Server has asked us to make a choice.
 *
 * Ask AI and return result.
 */
static void handle_choose(char *ptr)
{
    player *p_ptr;
    char msg[1024];
    int pos, type, num, num_special;
    int list[MAX_DECK], special[MAX_DECK];
    int arg1, arg2, arg3;
    int i;

    /* Get player pointer */
    p_ptr = &real_game.p[player_us];

    /* Read choice log position expected */
    pos = get_integer(&ptr);

    /* Check for further along in log than we are */
    if (pos > p_ptr->choice_pos)
    {
        /* Adjust current position */
        p_ptr->choice_size = p_ptr->choice_pos = pos;
    }

    /* Check for request for choice we have already made */
    else if (pos < p_ptr->choice_pos)
    {
        /* XXX Do nothing */
        return;
    }

    /* Read choice type */
    type = get_integer(&ptr);

    /* Read number of items in list */
    num = get_integer(&ptr);

    /* Loop over items in list */
    for (i = 0; i < num; i++)
    {
        /* Read list item */
        list[i] = get_integer(&ptr);
    }

    /* Read number of special items in list */
    num_special = get_integer(&ptr);

    /* Loop over special items */
    for (i = 0; i < num_special; i++)
    {
        /* Read special item */
        special[i] = get_integer(&ptr);
    }

    /* Read extra arguments */
    arg1 = get_integer(&ptr);
    arg2 = get_integer(&ptr);
    arg3 = get_integer(&ptr);

    /* Ask AI for decision */
    ai_func.make_choice(&real_game, player_us, type, list, &num,
                        special, &num_special, arg1, arg2, arg3);

    /* Start reply */
    ptr = msg;

    /* Begin message */
    start_msg(&ptr, MSG_CHOOSE);

    /* Put choice log position */
    put_integer(p_ptr->choice_pos, &ptr);

    /* Copy entries from choice log */
    for (i = p_ptr->choice_pos; i < p_ptr->choice_size; i++)
    {
        /* Copy entry */
        put_integer(p_ptr->choice_log[i], &ptr);
    }

    /* Move current position to end of choice log */
    p_ptr->choice_pos = p_ptr->choice_size;

    /* Finish message */
    finish_msg(msg, ptr);

    /* Send reply */
    send_msg(0, msg);
}
예제 #22
0
파일: nltest.c 프로젝트: openSUSE/lldpad
static int get_pg(char *ifname, struct tc_config *tc, __u8 *bwg, int cmd)
{
	struct nlmsghdr *nlh;
	struct dcbmsg *d;
	struct rtattr *class_parent, *param_parent, *rta_child;
	__u8 *p = (__u8 *)tc;
	int i, j;

	nlh = start_msg(RTM_GETDCB, cmd);
	if (NULL==nlh)
		return -EIO;

	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
	class_parent = add_rta(nlh, DCB_ATTR_PG_CFG, NULL, 0);
	param_parent = add_rta(nlh, DCB_PG_ATTR_TC_ALL, NULL, 0);
	rta_child = add_rta(nlh, DCB_TC_ATTR_PARAM_ALL, NULL, 0);
	param_parent->rta_len += NLMSG_ALIGN(rta_child->rta_len);
	class_parent->rta_len += NLMSG_ALIGN(param_parent->rta_len);

	rta_child = add_rta(nlh, DCB_PG_ATTR_BW_ID_ALL, NULL, 0);
	class_parent->rta_len += NLMSG_ALIGN(rta_child->rta_len);
	if (send_msg(nlh))
		return -EIO;

	nlh = get_msg();
	if (!nlh)
		return -EIO;

	d = (struct dcbmsg *)NLMSG_DATA(nlh);
	class_parent = (struct rtattr *)(((char *)d) +
		NLMSG_ALIGN(sizeof(struct dcbmsg)));

	if (d->cmd != cmd) {
		printf("Hmm, this is not the message we were expecting.\n");
		return -EIO;
	}
	if (class_parent->rta_type != DCB_ATTR_PG_CFG) {
		/* Do we really want to code up an attribute parser?? */
		printf("A full libnetlink (with genl and attribute support) "
		       "would sure be nice.\n");
		return -EIO;
	}
	param_parent = NLA_DATA(class_parent);
	class_parent = (struct rtattr *)((char *)class_parent +
					 NLMSG_ALIGN(class_parent->rta_len));

	for (i = 0; class_parent > param_parent; i++) {
		if (param_parent->rta_type >= DCB_PG_ATTR_TC_0 &&
			param_parent->rta_type < DCB_PG_ATTR_TC_MAX) {
			rta_child = NLA_DATA(param_parent);
			param_parent = (struct rtattr *)((char *)param_parent +
			      NLMSG_ALIGN(param_parent->rta_len));

			for (j = 0; param_parent > rta_child; j++) {
				if (j == DCB_TC_ATTR_PARAM_MAX -
					DCB_TC_ATTR_PARAM_UNDEFINED + 1) {
					printf("parameter array out of "
						"range: %d\n", j);
					break;
				}
				*p = *(__u8 *)NLA_DATA(rta_child);
				rta_child =
					(struct rtattr *)((char *)rta_child +
					NLMSG_ALIGN(rta_child->rta_len));
				p++;
			}
			if (param_parent != rta_child) {
				printf("param_parent and rta_child pointers "
					"are off\n");
			}
		} else if (param_parent->rta_type >= DCB_PG_ATTR_BW_ID_0 &&
			param_parent->rta_type < DCB_PG_ATTR_BW_ID_MAX) {
			j = param_parent->rta_type - DCB_PG_ATTR_BW_ID_0;
			bwg[j] = *(__u8 *)NLA_DATA(param_parent);
			param_parent = (struct rtattr *)((char *)param_parent +
				NLMSG_ALIGN(param_parent->rta_len));
		}
		else
			printf("unknown param_parent type = %d\n",
				param_parent->rta_type);

	}

	if (class_parent != param_parent)
		printf("class_parent and param_parent pointers are off\n");

	return 0;
}