Ejemplo n.º 1
0
void internalRequestSendCallback(int responseCode, const char* responseMessage, const char* friendsGotRequestIDs)
{
    EziFacebookDelegate* tempFBDelegate;
    tempFBDelegate = EziSocialObject::sharedObject()->getFacebookDelegate();
    
    if (tempFBDelegate)
    {
        tempFBDelegate->fbSendRequestCallback(responseCode, responseMessage, getArrayFromString(friendsGotRequestIDs));
    }
}
Ejemplo n.º 2
0
//Parse packet function for another interface
void parse_packet_p(u_char *user, struct pcap_pkthdr *packethdr, u_char *packetptr)
{
    struct ip* iphdr;
    struct icmphdr* icmphdr;
    struct tcphdr* tcphdr;
    struct udphdr* udphdr;
    char iphdrInfo[256], srcip[256], dstip[256];
    unsigned short id, seq;
    int i;
    int decision_p;
    int decision_t = -1;
    int proto;
    void *other_p;
    int sport,dport;

    struct ethhdr *eth = (struct ethhdr *)packetptr;

    // Skip the datalink layer header and get the IP header fields.
    packetptr += linkhdrlen;
    iphdr = (struct ip*)packetptr;
    strcpy(srcip, inet_ntoa(iphdr->ip_src));
    strcpy(dstip, inet_ntoa(iphdr->ip_dst));
    sprintf(iphdrInfo, "ID:%d TOS:0x%x, TTL:%d IpLen:%d DgLen:%d",
            ntohs(iphdr->ip_id), iphdr->ip_tos, iphdr->ip_ttl,
            4*iphdr->ip_hl, ntohs(iphdr->ip_len));

    // Advance to the transport layer header then parse and display
    // the fields based on the type of hearder: tcp, udp or icmp.
    packetptr += 4*iphdr->ip_hl;
    updateARP(srcip);
    //printf("2 %s %s\n",srcip,dstip);

    if(!isIPInSubnet(dstip,NET_IN,SUB_IN)  || iphdr->ip_v == 6)
    {
        return;
    }

    switch (iphdr->ip_p)
    {
    case IPPROTO_TCP:
        tcphdr = (struct tcphdr*)packetptr;
        decision_t = updateState(iphdr,tcphdr,IPPROTO_TCP,2,-1);
        other_p = tcphdr;
        proto = IPPROTO_TCP;
        sport = ntohs(tcphdr->source);
        dport = ntohs(tcphdr->dest);
        break;

    case IPPROTO_UDP:
        udphdr = (struct udphdr*)packetptr;
        decision_t = updateState(iphdr,udphdr,IPPROTO_UDP,2,-1);
        other_p = udphdr;
        proto = IPPROTO_UDP;
        sport = ntohs(udphdr->source);
        dport = ntohs(udphdr->dest);
        break;

    case IPPROTO_ICMP:
        icmphdr = (struct icmphdr*)packetptr;
        memcpy(&id, (u_char*)icmphdr+4, 2);
        memcpy(&seq, (u_char*)icmphdr+6, 2);
        decision_t = updateState(iphdr,icmphdr,IPPROTO_ICMP,2,-1);
        other_p = icmphdr;
        proto = IPPROTO_ICMP;
        sport = -1;
        dport = -1;
        break;
    }

    if(decision_t == -1)
    {
        if(debugging)
            printf("Drop!\n");
        return;
    }

    if(decision_t == 0)
    {
        decision_p = matchWithRules(srcip,dstip,sport,dport,proto);
        if(decision_p == 0)
        {
            if(debugging)
                printf("Drop!\n");
            return;
        }
        else if(decision_p == -1)
        {
            if(debugging)
                printf("Reject!\n");
            if(iphdr->ip_p == IPPROTO_TCP)
            {
                SendTCPRst(dstip,srcip,dport,sport,ntohl(tcphdr->seq));
            }
            else
            {
                SendICMPError(dstip,srcip);
            }
            return;
        }
        insert_in_table(iphdr,other_p,proto,-1);
    }

    getArrayFromString(MAC_IN);
    for(i=0; i<6; i++)
    {
        eth->h_source[i] = mac_t[i];
    }

    get_Mac_ARP(dstip,INT_IN);

    if(debugging)
        printf("2 %s\n",arp_ans);

    getArrayFromString(arp_ans);
    for(i=0; i<6; i++)
    {
        eth->h_dest[i] = mac_t[i];
    }
    if(debugging)
        printf("2 %d\n",pcap_inject(in_handle,eth,packethdr->len));
    else
        pcap_inject(in_handle,eth,packethdr->len);
}