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

Function process_extra_parms

tools/ipfw/dummynet.c:1017–1245  ·  view source on GitHub ↗

Parse AQM/extra scheduler parameters */

Source from the content-addressed store, hash-verified

1015
1016/* Parse AQM/extra scheduler parameters */
1017static int
1018process_extra_parms(int *ac, char **av, struct dn_extra_parms *ep,
1019 uint16_t type)
1020{
1021 int i;
1022
1023 /* use kernel defaults */
1024 for (i=0; i<DN_MAX_EXTRA_PARM; i++)
1025 ep->par[i] = -1;
1026
1027 switch(type) {
1028 case TOK_CODEL:
1029 case TOK_FQ_CODEL:
1030 /* Codel
1031 * 0- target, 1- interval, 2- flags,
1032 * FQ_CODEL
1033 * 3- quantum, 4- limit, 5- flows
1034 */
1035 if (type==TOK_CODEL)
1036 ep->par[2] = 0;
1037 else
1038 ep->par[2] = CODEL_ECN_ENABLED;
1039
1040 while (*ac > 0) {
1041 int tok = match_token(aqm_params, *av);
1042 (*ac)--; av++;
1043 switch(tok) {
1044 case TOK_TARGET:
1045 if (*ac <= 0 || time_to_us(av[0]) < 0)
1046 errx(EX_DATAERR, "target needs time\n");
1047
1048 ep->par[0] = time_to_us(av[0]);
1049 (*ac)--; av++;
1050 break;
1051
1052 case TOK_INTERVAL:
1053 if (*ac <= 0 || time_to_us(av[0]) < 0)
1054 errx(EX_DATAERR, "interval needs time\n");
1055
1056 ep->par[1] = time_to_us(av[0]);
1057 (*ac)--; av++;
1058 break;
1059
1060 case TOK_ECN:
1061 ep->par[2] = CODEL_ECN_ENABLED;
1062 break;
1063 case TOK_NO_ECN:
1064 ep->par[2] &= ~CODEL_ECN_ENABLED;
1065 break;
1066 /* Config fq_codel parameters */
1067 case TOK_QUANTUM:
1068 if (type != TOK_FQ_CODEL)
1069 errx(EX_DATAERR, "quantum is not for codel\n");
1070 if (*ac <= 0 || !is_valid_number(av[0]))
1071 errx(EX_DATAERR, "quantum needs number\n");
1072
1073 ep->par[3]= atoi(av[0]);
1074 (*ac)--; av++;

Callers 1

ipfw_config_pipeFunction · 0.85

Calls 4

match_tokenFunction · 0.85
time_to_usFunction · 0.85
is_valid_numberFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected