#!/usr/bin/env awk
#
# MPLS label 'idx'
#
# Dependencies:
#   - basicStats
#
# Example:
#   - tawk '{ print _mplsi(2) }' file

@include "_validate_col"

function _mplsi(idx,        _m) {
    _validate_col(MPLSLabel_ToS_S_TTL, "MPLSLabel_ToS_S_TTL")
    if (idx < 1 || idx > 10) {
        print "MPLS label number must be comprised between 1 and 10"
        exit(1)
    }
    if ($MPLSLabel_ToS_S_TTL == "MPLSLabel_ToS_S_TTL") return "MPLS lbl " idx
    _m = splitr($MPLSLabel_ToS_S_TTL, idx)
    if (length(_m) == 0) return "0-0-0"
    # TODO the value in the middle should be the experimental bit only
    return splitc(_m, 1) "-" splitc(_m, 2) "-" splitc(_m, 3)
}
