1

I want something like INET[6]_ADDRSTRLEN but containing the maximum value of the prefix length, i.e. 32 for v4 and 128 for v6.

Obviously I can #define my own versions, but wondered if I was just ignorant of the correct header. I've looked in <arpa/inet.h> and similar but not found anything.

3
  • Perhaps sizeof(in_addr_t) and sizeof(s6_addr) * 8 ? Commented Aug 21, 2017 at 16:41
  • 1
    @AjayBrahmakshatriya: For the sake of symmetry I'd propose: 8 * sizeof (struct in_addr) and 8 * sizeof (struct in6_addr)) Commented Aug 21, 2017 at 16:57
  • @AjayBrahmakshatriya: I'm not sure that's clearer for the case that I'm using it for. I'm basically setting a default value of 32 or 128, depending on the address family. I think something like #define INET_MAX_PREFIX_LEN 32 and #define INET6_MAX_PREFIX_LEN 128 would be clearest, if they don't already exist. Commented Aug 21, 2017 at 16:58

1 Answer 1

1

<netinet/in.h> could be what you are searching

netinet/in.h

Sign up to request clarification or add additional context in comments.

4 Comments

This does not provide an answer to the question, but would have better suited as comment.
I agree but I can't comment for now, should I delete ?
Comment now, then delete. ;-)
I need 50rep to comment :'(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.