MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fill_dscp

Function fill_dscp

tools/ipfw/ipfw2.c:1054–1094  ·  view source on GitHub ↗

* Fill the body of the command with the list of DiffServ codepoints. */

Source from the content-addressed store, hash-verified

1052 * Fill the body of the command with the list of DiffServ codepoints.
1053 */
1054static void
1055fill_dscp(ipfw_insn *cmd, char *av, int cblen)
1056{
1057 uint32_t *low, *high;
1058 char *s = av, *a;
1059 int code;
1060
1061 cmd->opcode = O_DSCP;
1062 cmd->len |= F_INSN_SIZE(ipfw_insn_u32) + 1;
1063
1064 CHECK_CMDLEN;
1065
1066 low = (uint32_t *)(cmd + 1);
1067 high = low + 1;
1068
1069 *low = 0;
1070 *high = 0;
1071
1072 while (s != NULL) {
1073 a = strchr(s, ',');
1074
1075 if (a != NULL)
1076 *a++ = '\0';
1077
1078 if (isalpha(*s)) {
1079 if ((code = match_token(f_ipdscp, s)) == -1)
1080 errx(EX_DATAERR, "Unknown DSCP code");
1081 } else {
1082 code = strtoul(s, NULL, 10);
1083 if (code < 0 || code > 63)
1084 errx(EX_DATAERR, "Invalid DSCP value");
1085 }
1086
1087 if (code >= 32)
1088 *high |= 1 << (code - 32);
1089 else
1090 *low |= 1 << code;
1091
1092 s = a;
1093 }
1094}
1095
1096static struct _s_x icmpcodes[] = {
1097 { "net", ICMP_UNREACH_NET },

Callers 1

compile_ruleFunction · 0.85

Calls 4

strchrFunction · 0.85
isalphaFunction · 0.85
match_tokenFunction · 0.85
strtoulFunction · 0.85

Tested by

no test coverage detected