Skip to contentSkip to conversation

configuring traffic control without tc (struct tcmsg)

LARTC Leandro Stasi 1 participant 1 message May 31, 2002

lore
Share & tools
lore
#0 lore raw

Hi

I need some help/doc with the rtnetlink struct tcmsg prameters.

I'm trying to configure traffic control kernel fuctions from inside a program, and I don't want to use tc.

I try to make a function to del the root qdisc from a device but I couldn't complete it.

So far I know this:
I have to open a netlink socket with PF_NETLINK and NETLINK_ROUTE. Send a nlmsghdr struct. (which I know the param)
Send a tcmsg struct (which I don't know the parm)

struct mensages

  {
    struct nlmsghdr nh;
    struct tcmsg tc;
    char attrbuf [512];

};

void delroot (struct root *ptroot)
{

struct mensages reg;
int rtnetlink_socket;
struct rtattr *rta;

  rtnetlink_socket=socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE);

  memset(&reg,0,sizeof(reg));

  reg.nh.nlmsg_len=NLMSG_LENGHT(sizeof(struct ifinfomsg));
  reg.nh.nlmsg_flags=NLM_F_REQUEST;
  reg.nh.nlmsq_type=RTML_NEWLINK;
  reg.tc.tcm_family¯_UNSPEC;
  reg.tc.tcm_index=INTERFACE_INDEX;
  reg.tc.tcm_handle=?????;

  rta=(struct rtattr*)( ((char *) &reg)+NLMSG_ALING(n->nlmsg_len) );

  rta->rta_type=???????;
  rta->rta_len=sizeof(unsigned int);

  reg.nh.nlmsg_len=NLMSG_ALING(reg.nh.nlmsg_len) + R_LENGTH(sizeof(???));

memcpy(RTA_DAtA(rta),???????,sizeof(?????));

send(rtnetlink_socket,&reg,reg.nh.nlmsg_len);
}

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/