Changeset 1361

Show
Ignore:
Timestamp:
08/24/07 21:42:59 (1 year ago)
Author:
till
Message:

- ... i really like inet_ntoa() ...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeytrap/trunk/src/dynsrv.c

    r1360 r1361  
    116116                                port_mode = port_flags_udp[htons(port_l)]->mode; 
    117117                } 
    118  
    119                 ip_l_str = strdup(inet_ntoa(ip_l)); 
    120                 ip_r_str = strdup(inet_ntoa(ip_r)); 
    121118 
    122119#ifndef USE_IPQ_MON 
     
    195192                                if (FD_ISSET(sigpipe[0], &rfds) && (check_sigpipe() == -1)) exit(EXIT_FAILURE); 
    196193                                if (FD_ISSET(listen_fd, &rfds)) { 
    197                                 logmsg(LOG_INFO, 1, "   %s  Handling %s connection request from %s:%d to %s:%d.\n", 
    198                                         portstr, PROTO(proto), inet_ntoa(ip_r), ntohs(port_r), inet_ntoa(ip_l), ntohs(port_l)); 
     194                                        if ((ip_l_str = strdup(inet_ntoa(ip_l))) == NULL) { 
     195                                                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     196                                                exit(EXIT_FAILURE); 
     197                                        } 
     198                                        if ((ip_r_str = strdup(inet_ntoa(ip_r))) == NULL) { 
     199                                                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     200                                                exit(EXIT_FAILURE); 
     201                                        } 
     202                                        logmsg(LOG_INFO, 1, "   %s  Handling %s connection request from %s:%d to %s:%d.\n", 
     203                                                portstr, PROTO(proto), ip_r_str, ntohs(port_r), ip_l_str, ntohs(port_l)); 
     204                                        free(ip_r_str); 
     205                                        free(ip_l_str); 
    199206 
    200207                                        /* initialize attack record */ 
  • honeytrap/trunk/src/ipqmon.c

    r1360 r1361  
    4242        fd_set                  rfds; 
    4343        struct timeval          mainloop_timeout; 
     44        char                    *srcip, *dstip; 
    4445        unsigned char           buf[BUFSIZE]; 
    4546        struct ip_header        *ip; 
     
    128129 
    129130                                        /* Got a connection request, start dynamic server and pass packet processing back to the kernel */ 
     131                                        if ((srcip = strdup(inet_ntoa(ip->ip_src))) == NULL) { 
     132                                                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     133                                                exit(EXIT_FAILURE); 
     134                                        } 
     135                                        if ((dstip = strdup(inet_ntoa(ip->ip_dst))) == NULL) { 
     136                                                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     137                                                exit(EXIT_FAILURE); 
     138                                        } 
    130139                                        logmsg(LOG_NOISY, 1, "%s:%d requesting %s connection on %s:%d.\n", 
    131                                                 inet_ntoa(ip->ip_src), sport, PROTO(ip->ip_p), inet_ntoa(ip->ip_dst), dport); 
     140                                                srcip, sport, PROTO(ip->ip_p), dstip, dport); 
     141                                        free(srcip); 
     142                                        free(dstip); 
     143 
    132144                                        switch (port_mode) { 
    133145                                        case PORTCONF_NONE: 
  • honeytrap/trunk/src/nfqmon.c

    r1360 r1361  
    8484        } 
    8585 
     86        if ((srcip = strdup(inet_ntoa(ip->ip_src))) == NULL) { 
     87                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     88                exit(EXIT_FAILURE); 
     89        } 
     90        if ((dstip = strdup(inet_ntoa(ip->ip_dst))) == NULL) { 
     91                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     92                exit(EXIT_FAILURE); 
     93        } 
    8694        logmsg(LOG_NOISY, 1, "%s:%d requesting %s connection on %s:%d.\n", 
    87                 inet_ntoa(ip->ip_src), sport, PROTO(ip->ip_p), inet_ntoa(ip->ip_dst), dport); 
     95                srcip, sport, PROTO(ip->ip_p), dstip, dport); 
     96        free(srcip); 
     97        free(dstip); 
     98 
    8899        switch (port_mode) { 
    89100        case PORTCONF_NONE: 
     
    125136        } 
    126137 
    127         if ((srcip = strdup(inet_ntoa(ip->ip_src))) == NULL) { 
    128                 logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
    129                 exit(EXIT_FAILURE); 
    130         } 
    131         if ((dstip = strdup(inet_ntoa(ip->ip_dst))) == NULL) { 
    132                 logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
    133                 exit(EXIT_FAILURE); 
    134         } 
    135138        start_dynamic_server(ip->ip_src, htons(sport), ip->ip_dst, htons(dport), ip->ip_p); 
    136139         
  • honeytrap/trunk/src/pcapmon.c

    r1360 r1361  
    7171        uint16_t        sport, dport; 
    7272        u_int8_t        port_mode; 
     73        char            *srcip, *dstip; 
    7374 
    7475        sport           = 0; 
     
    9394        } 
    9495 
    95         if (ip->ip_p == UDP) logmsg(LOG_NOISY, 1, "%s:%d requesting udp connection on %s:%d.\n", 
    96                         inet_ntoa(ip->ip_src), sport, inet_ntoa(ip->ip_dst), dport); 
    97         else if (ip->ip_p == TCP) logmsg(LOG_NOISY, 1, "%s:%d requesting udp connection on %s:%d.\n", 
    98                         inet_ntoa(ip->ip_dst), dport, inet_ntoa(ip->ip_src), sport); 
     96        if ((srcip = strdup(inet_ntoa(ip->ip_src))) == NULL) { 
     97                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     98                exit(EXIT_FAILURE); 
     99        } 
     100        if ((dstip = strdup(inet_ntoa(ip->ip_dst))) == NULL) { 
     101                logmsg(LOG_ERR, 1, "Error - Unable to allocate memory: %m.\n"); 
     102                exit(EXIT_FAILURE); 
     103        } 
     104        if (ip->ip_p == UDP) 
     105                logmsg(LOG_NOISY, 1, "%s:%d requesting udp connection on %s:%d.\n", 
     106                srcip, sport, dstip, dport); 
     107        else if (ip->ip_p == TCP) 
     108                logmsg(LOG_NOISY, 1, "%s:%d requesting tcp connection on %s:%d.\n", 
     109                dstip, dport, srcip, sport); 
     110        free(srcip); 
     111        free(dstip); 
     112 
    99113        switch (port_mode) { 
    100114        case PORTCONF_NONE: