ip-to-octets

xod/net/ip-to-octets

Splits an IP address into 4 octets
ip-to-octets
@/ip-to-octets
Splits an IP address into 4 octets
IN@/ip-address
The IP address
ip-to-octets
OUT1
OUT2
OUT3
OUT4
IN
OUT4byte
4th octet
OUT3byte
2nd octet
OUT2byte
3rd octet
OUT1byte
1st octet

C++ implementation

node {
    void evaluate(Context ctx) {
        auto ip = getValue<input_IN>(ctx);

        auto octets = reinterpret_cast<uint8_t*>(&ip);

        emitValue<output_OUT1>(ctx, octets[0]);
        emitValue<output_OUT2>(ctx, octets[1]);
        emitValue<output_OUT3>(ctx, octets[2]);
        emitValue<output_OUT4>(ctx, octets[3]);
    }
}