static int
nbt_alias_handler(PNATState pData, int type)
#endif /*VBOX*/
{
    int error;
#ifdef VBOX
    if (handlers == NULL)
        handlers = RTMemAllocZ(4 * sizeof(struct proto_handler));
    handlers[0].pri = 130;
    handlers[0].dir = IN|OUT;
    handlers[0].proto = UDP;
    handlers[0].fingerprint = &fingerprint1;
    handlers[0].protohandler = &protohandler1;


    handlers[1].pri = 140;
    handlers[1].dir = IN;
    handlers[1].proto = UDP;
    handlers[1].fingerprint = &fingerprint2;
    handlers[1].protohandler = &protohandler2in;


    handlers[2].pri = 140;
    handlers[2].dir = OUT;
    handlers[2].proto = UDP;
    handlers[2].fingerprint = &fingerprint2;
    handlers[2].protohandler = &protohandler2out;

    handlers[3].pri = EOH;
#endif /*VBOX*/

    switch (type) {
    case MOD_LOAD:
        error = 0;
#ifdef VBOX
        LibAliasAttachHandlers(pData, handlers);
#else
        LibAliasAttachHandlers(handlers);
#endif
        break;
    case MOD_UNLOAD:
        error = 0;
#ifdef VBOX
        LibAliasDetachHandlers(pData, handlers);
        RTMemFree(handlers);
        handlers = NULL;
#else
        LibAliasDetachHandlers(handlers);
#endif
        break;
    default:
        error = EINVAL;
    }
    return (error);
}
Exemple #2
0
static int
ftp_alias_handler(PNATState pData, int type)
#endif
{
    int error;
#ifdef VBOX
    if (handlers == NULL)
        handlers = RTMemAllocZ(2 * sizeof(struct proto_handler));
    handlers[0].pri = 80;
    handlers[0].dir = OUT;
    handlers[0].proto = TCP;
    handlers[0].fingerprint = &fingerprint;
    handlers[0].protohandler = &protohandler;
    handlers[1].pri = EOH;
#endif /* VBOX */

    switch (type) {
    case MOD_LOAD:
        error = 0;
#ifdef VBOX
        LibAliasAttachHandlers(pData, handlers);
#else
        LibAliasAttachHandlers(handlers);
#endif
        break;
    case MOD_UNLOAD:
        error = 0;
#ifdef VBOX
        LibAliasDetachHandlers(pData, handlers);
        RTMemFree(handlers);
        handlers = NULL;
#else
        LibAliasDetachHandlers(handlers);
#endif
        break;
    default:
        error = EINVAL;
    }
    return (error);
}
Exemple #3
0
int
LibAliasLoadModule(char *path)
{
#ifndef VBOX
    struct dll *t;
    void *handle;
    struct proto_handler *m;
        const char *error;
    moduledata_t *p;

        handle = dlopen (path, RTLD_LAZY);
        if (!handle) {
        fprintf(stderr, "%s\n", dlerror());
        return (EINVAL);
        }

    p = dlsym(handle, "alias_mod");
        if ((error = dlerror()) != NULL)  {
        fprintf(stderr, "%s\n", dlerror());
        return (EINVAL);
        }

    t = malloc(sizeof(struct dll));
    if (t == NULL)
        return (ENOMEM);
    strncpy(t->name, p->name, DLL_LEN);
    t->handle = handle;
    if (attach_dll(t) == EEXIST) {
        free(t);
        fprintf(stderr, "dll conflict\n");
        return (EEXIST);
    }

        m = dlsym(t->handle, "handlers");
        if ((error = dlerror()) != NULL)  {
        fprintf(stderr, "%s\n", error);
        return (EINVAL);
    }

    LibAliasAttachHandlers(m);
#else /* !VBOX */
    NOREF(path);
#endif /* VBOX */
    return (0);
}
Exemple #4
0
static int
mod_handler(module_t mod, int type, void *data)
{
    int error;

    switch (type) {
    case MOD_LOAD:
        error = 0;
        LibAliasAttachHandlers(handlers);
        break;
    case MOD_UNLOAD:
        error = 0;
        LibAliasDetachHandlers(handlers);
        break;
    default:
        error = EINVAL;
    }
    return (error);
}