Skip to content

Commit

Permalink
llpriority
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowman committed Apr 16, 2021
1 parent cd13521 commit 37f01b9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion commands.c
Expand Up @@ -489,7 +489,8 @@ struct intlist Intlist[] = {
{ "group", "Interface group", CMPL0 0, 0, intgroup },
{ "rdomain", "Interface routing domain", CMPL0 0, 0, intrdomain },
{ "rtlabel", "Interface route labels", CMPL0 0, 0, intrtlabel },
{ "priority", "Interface priority", CMPL0 0, 0, intmetric },
{ "priority", "Data packet priority", CMPL0 0, 0, intmetric },
{ "llpriority", "Link Level packet priority", CMPL0 0, 0, intmetric },
{ "mtu", "Set Maximum Transmission Unit", CMPL0 0, 0, intmtu },
{ "metric", "Set routing metric", CMPL0 0, 0, intmetric },
{ "link", "Set link level options", CMPL0 0, 0, intlink },
Expand Down
4 changes: 4 additions & 0 deletions conf.c
Expand Up @@ -881,6 +881,10 @@ void conf_ifmetrics(FILE *output, int ifs, struct if_data if_data,
if(ifrpriority.ifr_metric)
fprintf(output, " priority %u\n",
ifrpriority.ifr_metric);
if (ioctl(ifs, SIOCGIFLLPRIO, (caddr_t)&ifrpriority) == 0)
if(ifrpriority.ifr_llprio)
fprintf(output, " llpriority %u\n",
ifrpriority.ifr_llprio);

if (get_nwinfo(ifname, tmpc, TMPSIZ, NWID) != 0) {
fprintf(output, " nwid %s\n", tmpc);
Expand Down
1 change: 1 addition & 0 deletions externs.h
Expand Up @@ -394,6 +394,7 @@ int intmpelabel(char *, int, int, char **);
int intrdomain(char *, int, int, char **);
int intdhcrelay(char *, int, int, char **);
int intmetric(char *, int, int, char **);
int intllprio(char *, int, int, char **);
int intrtd(char *, int, int, char **);
int intvlan(char *, int, int, char **);
int intflags(char *, int, int, char **);
Expand Down
46 changes: 46 additions & 0 deletions if.c
Expand Up @@ -1487,6 +1487,52 @@ intmetric(char *ifname, int ifs, int argc, char **argv)
return(0);
}

int
intllprio(char *ifname, int ifs, int argc, char **argv)
{
struct ifreq ifr;
int set;
const char *errmsg = NULL;

if (NO_ARG(argv[0])) {
set = 0;
argc--;
argv++;
} else
set = 1;

if ((!set && argc > 1) || (set && argc != 1)) {
printf("%% llpriority <priority>\n");
printf("%% no llpriority [priority]\n");
return(0);
}

if (set) {
int num;

num = strtonum(argv[0], 0, 15, &errmsg);
if (errmsg) {
printf("%% Invalid llpriority %s: %s\n", argv[0],
errmsg);
return(0);
}
ifr.ifr_llprio = num;
} else {
ifr.ifr_llprio = 0;
}

if (errmsg) {
printf("%% Invalid llpriority %s: %s\n", argv[0], errmsg);
return(0);
}

strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(ifs, SIOCSIFLLPRIO, (caddr_t)&ifr) < 0)
printf("%% intllprio: SIOCSIFLLPRIO: %s\n", strerror(errno));

return(0);
}

int
intvlan(char *ifname, int ifs, int argc, char **argv)
{
Expand Down

0 comments on commit 37f01b9

Please sign in to comment.