struct ip_masq_app * ip_masq_bind_app(struct ip_masq *ms)
{
        struct ip_masq_app * mapp;

        if (ms->protocol != IPPROTO_TCP && ms->protocol != IPPROTO_UDP)
                return NULL;

        mapp = ip_masq_app_get(ms->protocol, ms->dport);

#if 0000
/* #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW */
        if (mapp == NULL)
                mapp = ip_masq_app_get(ms->protocol, ms->sport);
/* #endif */
#endif

        if (mapp == NULL)
                /*
                 * paolo 24/10/2000 
                 */
                mapp = ip_masq_app_get(ms->protocol, ms->mport);

        if (mapp != NULL) {
                /*
                 *      don't allow binding if already bound
                 */

                if (ms->app != NULL) {
                        IP_MASQ_ERR("ip_masq_bind_app() called for already bound object.\n");
                        return ms->app;
                }

                ms->app = mapp;
                if (mapp->masq_init_1) mapp->masq_init_1(mapp, ms);
                ip_masq_app_bind_chg(mapp, +1);
        }
        return mapp;
}


