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

Function get_extra_parms

tools/ipfw/dummynet.c:224–353  ·  view source on GitHub ↗

Get AQM or scheduler extra parameters */

Source from the content-addressed store, hash-verified

222
223/* Get AQM or scheduler extra parameters */
224static void
225get_extra_parms(uint32_t nr, char *out, int subtype)
226{
227 struct dn_extra_parms *ep;
228 int ret;
229 char strt1[15], strt2[15], strt3[15];
230 u_int l;
231
232 /* prepare the request */
233 l = sizeof(struct dn_extra_parms);
234 ep = safe_calloc(1, l);
235 memset(ep, 0, sizeof(*ep));
236 *out = '\0';
237
238 oid_fill(&ep->oid, l, DN_CMD_GET, DN_API_VERSION);
239 ep->oid.len = l;
240 ep->oid.subtype = subtype;
241 ep->nr = nr;
242
243 ret = do_cmd(-IP_DUMMYNET3, ep, (uintptr_t)&l);
244 if (ret) {
245 free(ep);
246 errx(EX_DATAERR, "Error getting extra parameters\n");
247 }
248
249 switch (subtype) {
250 case DN_AQM_PARAMS:
251 if( !strcasecmp(ep->name, "codel")) {
252 us_to_time(ep->par[0], strt1);
253 us_to_time(ep->par[1], strt2);
254 l = sprintf(out, " AQM CoDel target %s interval %s",
255 strt1, strt2);
256 if (ep->par[2] & CODEL_ECN_ENABLED)
257 l = sprintf(out + l, " ECN");
258 else
259 l += sprintf(out + l, " NoECN");
260 } else if( !strcasecmp(ep->name, "pie")) {
261 us_to_time(ep->par[0], strt1);
262 us_to_time(ep->par[1], strt2);
263 us_to_time(ep->par[2], strt3);
264 l = sprintf(out, " AQM type PIE target %s tupdate %s alpha "
265 "%g beta %g max_burst %s max_ecnth %.3g",
266 strt1,
267 strt2,
268 ep->par[4] / (float) PIE_SCALE,
269 ep->par[5] / (float) PIE_SCALE,
270 strt3,
271 ep->par[3] / (float) PIE_SCALE
272 );
273
274 if (ep->par[6] & PIE_ECN_ENABLED)
275 l += sprintf(out + l, " ECN");
276 else
277 l += sprintf(out + l, " NoECN");
278 if (ep->par[6] & PIE_CAPDROP_ENABLED)
279 l += sprintf(out + l, " CapDrop");
280 else
281 l += sprintf(out + l, " NoCapDrop");

Callers 2

print_flowset_parmsFunction · 0.85
list_pipesFunction · 0.85

Calls 8

memsetFunction · 0.85
strcasecmpFunction · 0.85
us_to_timeFunction · 0.85
sprintfFunction · 0.85
safe_callocFunction · 0.70
oid_fillFunction · 0.70
do_cmdFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected