/* Extracts an integer sub-field from an int with a given mask  */
guint zbee_get_bit_field(guint input, guint mask)
/* Extracts an integer sub-field from an int with a given mask  */
guint zbee_get_bit_field(guint input, guint mask)
{
    if (mask == 0) return 0;
    while (!(mask & 0x1)) {
        input >>= 1;
        mask >>=1;
    }
    return (input & mask);
}