// [[Rcpp::export]] CharacterVector get_payload_for(Rcpp::XPtr< std::vector<Crafter::Packet*> > pcap, int packet_num) { std::vector<Packet*> pck_cont = *pcap; RawLayer* raw = pck_cont[packet_num-1]->GetLayer<RawLayer>(); if (raw) { return(raw->GetStringPayload()); } else { return(NA_STRING); } }
/*** * Get/Set the payload data for this layer * @function data * @tparam[opt] string data * @treturn string data * */ int l_raw_ref::l_data(lua_State *l) { char const *payload = NULL; size_t payload_len = 0; RawLayer *o = l_raw_ref::extract(l, 1); if (lua_gettop(l) > 1) { _get_byte_string(&payload, &payload_len, l, 2); o->SetPayload((byte *)payload, payload_len); } else l_data_type<std::string>(o->GetStringPayload()).push(l); return 1; }