Somewhat guessing, but maybe use dissectortable.get("ip.proto") to get the table of dissectors registered with ip, then use dissectortable::try() to call the appropriate entry from that table with the protocol value you have for the next header.