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

Function LibAliasLoadModule

freebsd/netinet/libalias/alias.c:1693–1733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1691}
1692
1693int
1694LibAliasLoadModule(char *path)
1695{
1696 struct dll *t;
1697 void *handle;
1698 struct proto_handler *m;
1699 const char *error;
1700 moduledata_t *p;
1701
1702 handle = dlopen (path, RTLD_LAZY);
1703 if (!handle) {
1704 fprintf(stderr, "%s\n", dlerror());
1705 return (EINVAL);
1706 }
1707
1708 p = dlsym(handle, "alias_mod");
1709 if ((error = dlerror()) != NULL) {
1710 fprintf(stderr, "%s\n", dlerror());
1711 return (EINVAL);
1712 }
1713
1714 t = malloc(sizeof(struct dll));
1715 if (t == NULL)
1716 return (ENOMEM);
1717 strncpy(t->name, p->name, DLL_LEN);
1718 t->handle = handle;
1719 if (attach_dll(t) == EEXIST) {
1720 free(t);
1721 fprintf(stderr, "dll conflict\n");
1722 return (EEXIST);
1723 }
1724
1725 m = dlsym(t->handle, "handlers");
1726 if ((error = dlerror()) != NULL) {
1727 fprintf(stderr, "%s\n", error);
1728 return (EINVAL);
1729 }
1730
1731 LibAliasAttachHandlers(m);
1732 return (0);
1733}
1734
1735int
1736LibAliasUnLoadAllModule(void)

Callers 1

LibAliasRefreshModulesFunction · 0.85

Calls 5

mallocFunction · 0.85
strncpyFunction · 0.85
attach_dllFunction · 0.85
LibAliasAttachHandlersFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected