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

Function LibAliasInit

freebsd/netinet/libalias/alias_db.c:2401–2482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2399}
2400
2401struct libalias *
2402LibAliasInit(struct libalias *la)
2403{
2404 int i;
2405#ifndef _KERNEL
2406 struct timeval tv;
2407#endif
2408
2409 if (la == NULL) {
2410#ifdef _KERNEL
2411#undef malloc /* XXX: ugly */
2412 la = malloc(sizeof *la, M_ALIAS, M_WAITOK | M_ZERO);
2413#else
2414 la = calloc(sizeof *la, 1);
2415 if (la == NULL)
2416 return (la);
2417#endif
2418
2419#ifndef _KERNEL /* kernel cleans up on module unload */
2420 if (LIST_EMPTY(&instancehead))
2421 atexit(finishoff);
2422#endif
2423 LIST_INSERT_HEAD(&instancehead, la, instancelist);
2424
2425#ifdef _KERNEL
2426 la->timeStamp = time_uptime;
2427 la->lastCleanupTime = time_uptime;
2428#else
2429 gettimeofday(&tv, NULL);
2430 la->timeStamp = tv.tv_sec;
2431 la->lastCleanupTime = tv.tv_sec;
2432#endif
2433
2434 for (i = 0; i < LINK_TABLE_OUT_SIZE; i++)
2435 LIST_INIT(&la->linkTableOut[i]);
2436 for (i = 0; i < LINK_TABLE_IN_SIZE; i++)
2437 LIST_INIT(&la->linkTableIn[i]);
2438#ifdef _KERNEL
2439 AliasSctpInit(la);
2440#endif
2441 LIBALIAS_LOCK_INIT(la);
2442 LIBALIAS_LOCK(la);
2443 } else {
2444 LIBALIAS_LOCK(la);
2445 la->deleteAllLinks = 1;
2446 CleanupAliasData(la);
2447 la->deleteAllLinks = 0;
2448#ifdef _KERNEL
2449 AliasSctpTerm(la);
2450 AliasSctpInit(la);
2451#endif
2452 }
2453
2454 la->aliasAddress.s_addr = INADDR_ANY;
2455 la->targetAddress.s_addr = INADDR_ANY;
2456
2457 la->icmpLinkCount = 0;
2458 la->udpLinkCount = 0;

Callers 2

nat44_configFunction · 0.85
ng_nat_constructorFunction · 0.85

Calls 6

mallocFunction · 0.85
callocFunction · 0.85
AliasSctpInitFunction · 0.85
CleanupAliasDataFunction · 0.85
AliasSctpTermFunction · 0.85
LibAliasRefreshModulesFunction · 0.85

Tested by

no test coverage detected