Continued working on retrieving IP address from message

master
Aadhavan Srinivasan 2 years ago
parent eefe9fbf1b
commit 67466ade6e

@ -66,6 +66,14 @@ int main() {
} else {
if (dest_address[i] == NULL) {
dest_address[i] = fetch_address(buffer);
if (dest_address[i] == NULL) {
printf("Invalid message format\n");
exit(241);
}
if (check_ip_ver(dest_address[i]) == -1) {
printf("Invalid address: %s\n",dest_address[i]);
exit(242);
}
}

@ -4,14 +4,12 @@
char* fetch_address(char* message) {
char* token = malloc (sizeof(char) * strlen(message));
token = strtok(message," ");
token = strtok(message," \n");
if (strcmp(token,"TO:") == 0) {
token = strtok(NULL,"");
}
if (check_ip_ver(token) == -1) {
return NULL;
token = strtok(NULL," \n");
} else {
return token;
return NULL;
}
return token;
}

Loading…
Cancel
Save