I think there is a bug in the smpp_pdu_pack() function when packing optional parameters.
The tag_id and opt_len are not converted from host to network byte ordering as they should be for a byte oriented wire encoding. The corresponding unpack function works fine.
