* Fill the body of the command with the list of DiffServ codepoints. */
| 1052 | * Fill the body of the command with the list of DiffServ codepoints. |
| 1053 | */ |
| 1054 | static void |
| 1055 | fill_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 | |
| 1096 | static struct _s_x icmpcodes[] = { |
| 1097 | { "net", ICMP_UNREACH_NET }, |
no test coverage detected