File: netiface.cpp

package info (click to toggle)
yrmcds 1.0.4-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 924 kB
  • ctags: 1,346
  • sloc: cpp: 9,634; sh: 133; makefile: 97
file content (29 lines) | stat: -rw-r--r-- 764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <cybozu/ip_address.hpp>

#include <iostream>

int main(int argc, char** argv) {
    if( argc < 2 ) {
        std::cout << "Usage: netiface ADDRESS" << std::endl;
        return 0;
    }
    cybozu::ip_address a(argv[1]);
    if( a.is_v4() ) {
        std::cout << "v4!" << std::endl;
    } else if( a.is_v6() ) {
        std::cout << "v6!" << std::endl;
    }
    cybozu::ip_address b("127.0.0.1");
    if( a == b ) {
        std::cout << a.str() << " == 127.0.0.1" << std::endl;
    } else {
        std::cout << a.str() << " != 127.0.0.1" << std::endl;
    }

    if( has_ip_address(a) ) {
        std::cout << a.str() << " is assigned." << std::endl;
    } else {
        std::cout << a.str() << " is not assigned." << std::endl;
    }
    return 0;
}