Changeset 89

Show
Ignore:
Timestamp:
11/02/06 15:57:21 (2 years ago)
Author:
dragorn
Message:

Added string errors to wlan-ng and madwifi-ng injectors

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/mwnginject.c

    r87 r89  
    5555 
    5656        if (madwifing_devtype(in_tx, ARPHDR_PRISMAVS) != 0) { 
    57                 printf("Error setting capture header type.\n"); 
    5857                return -1; 
    5958        } 
    6059 
    6160        if (wtinj_open(in_tx) != 0) { 
    62                 printf("Error opening interface.\n"); 
    6361                return -1; 
    6462        } 
     
    7977        fp = fopen(athdevpath, "w"); 
    8078        if (!fp) { 
    81                 fprintf(stderr, "Unable to open proc device \"%s\", ", 
    82                         athdevpath); 
    83                 perror("fopen"); 
     79                snprintf(in_tx->errstr, TX80211_STATUS_MAX, "Error setting madwifi-ng " 
     80                                 "capture header type, unable to open proc device \"%s\"", 
     81                                 athdevpath); 
    8482                return -1; 
    8583        } 
     
    8785        ret = fprintf(fp, "%s\n", ARPHDR_PRISMAVS); 
    8886        if (ret < 0) { 
    89                 fprintf(stderr, "Unable to write to proc device \"%s\", ", 
    90                         athdevpath); 
    91                 perror("fprintf"); 
     87                snprintf(in_tx->errstr, TX80211_STATUS_MAX, "Error setting madwifi-ng " 
     88                                 "capture header type, unable to write to proc device \"%s\"", 
     89                                 athdevpath); 
    9290                return ret; 
    9391        } 
     
    116114        pkt = malloc(len); 
    117115        if (pkt == NULL) { 
    118                 fprintf(stderr, "Unable to allocate memory buffer for send " 
    119                         "function.\n"); 
     116                snprintf(in_tx->errstr, TX80211_STATUS_MAX, "Unable to allocate memory buffer " 
     117                                 "for send function"); 
    120118                return -1; 
    121119        } 
  • trunk/wginject.c

    r86 r89  
    9191        if (!(wginj->raw_fd > 0)) { 
    9292                /* file descriptor is not open */ 
     93                snprintf(wginj->errstr, TX80211_STATUS_MAX, "wlan-ng raw inject file descriptor " 
     94                                 "not open"); 
    9395                return -1; 
    9496        } 
     
    9698        frame = malloc(sizeof(*frame) + payloadlen); 
    9799        if (frame == NULL) { 
     100                snprintf(wginj->errstr, TX80211_STATUS_MAX, "wlan-ng send unable to allocate " 
     101                                 "memory buffer"); 
    98102                return -3; 
    99103        } 
     
    135139        err = ioctl(wginj->raw_fd, SIOCGIFINDEX, &if_req); 
    136140        if (err < 0) { 
     141                snprintf(wginj->errstr, TX80211_STATUS_MAX, "wlan-ng unable to find interface " 
     142                                 "index (SIOCGIFINDEX): %s", strerror(errno)); 
    137143                close(wginj->raw_fd); 
    138144                return -2; 
     
    145151        err = bind(wginj->raw_fd, (struct sockaddr *)&sa_ll, sizeof sa_ll); 
    146152        if (err != 0) { 
     153                snprintf(wginj->errstr, TX80211_STATUS_MAX, "wlan-ng unable to bind() socket: %s", 
     154                                 strerror(errno)); 
    147155                close(wginj->raw_fd); 
    148156                return -3;