ip-address

xod/net/ip-address

Assembles an IP address from 4 octets
ip-address
@/ip-address
Assembles an IP address from 4 octets
IN1byte
1st octet
IN2byte
3rd octet
IN3byte
2nd octet
IN4byte
4th octet
ip-address
IN1
IN2
IN3
IN4
OUT
OUT@/ip-address
IP address

C++ implementation

node {
    meta {
      // because most other IPAdress classes can cast from/to uint32_t
      using Type = uint32_t;
    }

    void evaluate(Context ctx) {
        uint32_t octet1 = getValue<input_IN1>(ctx);
        uint32_t octet2 = getValue<input_IN2>(ctx);
        uint32_t octet3 = getValue<input_IN3>(ctx);
        uint32_t octet4 = getValue<input_IN4>(ctx);

        Type ip = octet4 << 24 | octet3 << 16 | octet2 << 8 | octet1;
        emitValue<output_OUT>(ctx, ip);
    }
}