1

When you enter route in the command line, for flags it prints out U, UG, etc. In the file for route it stores flags as a number 0001, 0003 etc. How are the numbers for flags in the file /proc/net/route converted to the letters for flags that are printed out using route?

2

Net-tools sources are here. Decoding flags in lib/inet_gr.c:

    /* Decode the flags. */
    flags[0] = '\0';
    if (iflags & RTF_UP)
        strcat(flags, "U");
    if (iflags & RTF_GATEWAY)
        strcat(flags, "G");
    ...

And flags are defined in lib/net-support.h. Example:

    #define RTF_UP          0x0001          /* route usable                 */
    #define RTF_GATEWAY     0x0002          /* destination is a gateway     */
    #define RTF_HOST        0x0004          /* host entry (net otherwise)   */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.