Question: I'm working on a network programming course in C. I have a few issues with my current code and am looking for help. The requirements

I'm working on a network programming course in C. I have a few issues with my current code and am looking for help. The requirements and my current code are below.

Write a new function named inet_pton_loose that handles these scenarios: If the address family is AF_INET and inet_pton returns 0, call inet_aton and see if it succeeds.

Similarly, if the address family is AF_INET6 and inet_pton returns 0, call inet_aton and if it succeeds, return the IPv4-mapped IPv6 address.

#include "inet_pton_loose.h"

/* used by inet_aton */ #include #include #include #include

int inet_aton(const char *, struct in_addr *);

/* used by inet_pton and inet_aton */ #include

int inet_pton_version( int ipVersion, const char *ipAddrs, void *dst ) { int vlaue = -20;

switch (ipVersion) { case AF_INET: { if (inet_pton(ipVersion, ipAddrs, dst) == 0){ struct in_addr in_val; if (inet_aton(ipAddrs, &in_val) == 0){ return (0); } else{ return (0); } } else{ return (1); } break; } case AF_INET6: { if (inet_pton(ipVersion, ipAddrs, dst) == 0){ struct in_addr in_val; if (inet_aton(ipAddrs, &in_val) == 0){ return (0); } else{ return (0); } } else{ return (1); } break; } default: return status; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!