Exemplo n.º 1
0
static int 
protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
{
	
	AliasHandleCUSeeMeOut(la, pip, ah->lnk);
	return (0);
}
Exemplo n.º 2
0
static int
UdpAliasOut(struct ip *pip)
{
    struct udphdr *ud;
    struct alias_link *link;

/* Return if proxy-only mode is enabled */
    if (packetAliasMode & PKT_ALIAS_PROXY_ONLY)
        return PKT_ALIAS_OK;

    ud = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));

    link = FindUdpTcpOut(pip->ip_src, pip->ip_dst,
                         ud->uh_sport, ud->uh_dport,
                         IPPROTO_UDP, 1);
    if (link != NULL)
    {
        u_short alias_port;
        struct in_addr alias_address;

        alias_address = GetAliasAddress(link);
        alias_port = GetAliasPort(link);

/* Special processing for IP encoding protocols */
	if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
	    AliasHandleCUSeeMeOut(pip, link);
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
	else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
	      || ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
	    AliasHandleUdpNbt(pip, link, &alias_address, alias_port);
	else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
	      || ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
	    AliasHandleUdpNbtNS(pip, link, &pip->ip_src, &ud->uh_sport,
				&alias_address, &alias_port);
/*
 * We don't know in advance what TID the TFTP server will choose,
 * so we create a wilcard link (destination port is unspecified)
 * that will match any TID from a given destination.
 */
	else if (ntohs(ud->uh_dport) == TFTP_PORT_NUMBER)
	    FindRtspOut(pip->ip_src, pip->ip_dst,
			ud->uh_sport, alias_port, IPPROTO_UDP);

/* If UDP checksum is not zero, adjust since source port is */
/* being aliased and source address is being altered        */
        if (ud->uh_sum != 0)
        {
            int accumulate;
            u_short *sptr;

            accumulate  = ud->uh_sport;
            accumulate -= alias_port;
            sptr = (u_short *) &(pip->ip_src);
            accumulate += *sptr++;
            accumulate += *sptr;
            sptr = (u_short *) &alias_address;
            accumulate -= *sptr++;
            accumulate -= *sptr;
            ADJUST_CHECKSUM(accumulate, ud->uh_sum);
        }

/* Put alias port in UDP header */
        ud->uh_sport = alias_port;

/* Change source address */
        DifferentialChecksum(&pip->ip_sum,
                             (u_short *) &alias_address,
                             (u_short *) &pip->ip_src,
                             2);
        pip->ip_src = alias_address;

        return(PKT_ALIAS_OK);
    }
    return(PKT_ALIAS_IGNORED);
}