/* Do not send an error message in response to an error message */ static inline int can_respond(struct sk_buff *skb) { const struct phonethdr *ph; const struct phonetmsg *pm; u8 submsg_id; if (!pskb_may_pull(skb, 3)) return 0; ph = pn_hdr(skb); if (ph->pn_res == PN_PREFIX && !pskb_may_pull(skb, 5)) return 0; if (ph->pn_res == PN_COMMGR) /* indications */ return 0; ph = pn_hdr(skb); /* re-acquires the pointer */ pm = pn_msg(skb); if (pm->pn_msg_id != PN_COMMON_MESSAGE) return 1; submsg_id = (ph->pn_res == PN_PREFIX) ? pm->pn_e_submsg_id : pm->pn_submsg_id; if (submsg_id != PN_COMM_ISA_ENTITY_NOT_REACHABLE_RESP && pm->pn_e_submsg_id != PN_COMM_SERVICE_NOT_IDENTIFIED_RESP) return 1; return 0; }
void message::encode(std::vector<char> &s) const { impl().flush(); size_t sz = std::max(s.capacity(), size_t(512)); while (true) { s.resize(sz); assert(!s.empty()); int err = pn_message_encode(pn_msg(), const_cast<char*>(&s[0]), &sz); if (err) { if (err != PN_OVERFLOW) check(err); } else { s.resize(sz); return; } sz *= 2; } }
static int send_obj_unreachable(struct sk_buff *rskb) { const struct phonethdr *oph = pn_hdr(rskb); const struct phonetmsg *opm = pn_msg(rskb); struct phonetmsg resp; memset(&resp, 0, sizeof(resp)); resp.pn_trans_id = opm->pn_trans_id; resp.pn_msg_id = PN_COMMON_MESSAGE; if (oph->pn_res == PN_PREFIX) { resp.pn_e_res_id = opm->pn_e_res_id; resp.pn_e_submsg_id = PN_COMM_ISA_ENTITY_NOT_REACHABLE_RESP; resp.pn_e_orig_msg_id = opm->pn_msg_id; resp.pn_e_status = 0; } else { resp.pn_submsg_id = PN_COMM_ISA_ENTITY_NOT_REACHABLE_RESP; res
void message::durable(bool b) { pn_message_set_durable(pn_msg(), b); }
bool message::durable() const { return pn_message_is_durable(pn_msg()); }
message_id message::correlation_id() const { return pn_message_get_correlation_id(pn_msg()); }
int32_t message::group_sequence() const { return pn_message_get_group_sequence(pn_msg()); }
uint32_t message::delivery_count() const { return pn_message_get_delivery_count(pn_msg()); }
bool message::first_acquirer() const { return pn_message_is_first_acquirer(pn_msg()); }
uint8_t message::priority() const { return pn_message_get_priority(pn_msg()); }
void message::reply_to_group_id(const std::string &s) { check(pn_message_set_reply_to_group_id(pn_msg(), s.c_str())); }
timestamp message::creation_time() const { return timestamp(pn_message_get_creation_time(pn_msg())); }
void message::creation_time(timestamp t) { pn_message_set_creation_time(pn_msg(), t.milliseconds()); }
timestamp message::expiry_time() const { return timestamp(pn_message_get_expiry_time(pn_msg())); }
void message::expiry_time(timestamp t) { pn_message_set_expiry_time(pn_msg(), t.milliseconds()); }
std::string message::content_encoding() const { const char* s = pn_message_get_content_encoding(pn_msg()); return s ? std::string(s) : std::string(); }
void message::content_encoding(const std::string &s) { check(pn_message_set_content_encoding(pn_msg(), s.c_str())); }
duration message::ttl() const { return duration(pn_message_get_ttl(pn_msg())); }
void message::ttl(duration d) { pn_message_set_ttl(pn_msg(), d.milliseconds()); }
std::string message::reply_to_group_id() const { const char* s = pn_message_get_reply_to_group_id(pn_msg()); return s ? std::string(s) : std::string(); }
void message::priority(uint8_t d) { pn_message_set_priority(pn_msg(), d); }
bool message::inferred() const { return pn_message_is_inferred(pn_msg()); }
void message::first_acquirer(bool b) { pn_message_set_first_acquirer(pn_msg(), b); }
void message::inferred(bool b) { pn_message_set_inferred(pn_msg(), b); }
void message::delivery_count(uint32_t d) { pn_message_set_delivery_count(pn_msg(), d); }
std::string message::subject() const { const char* s = pn_message_get_subject(pn_msg()); return s ? std::string(s) : std::string(); }
void message::group_sequence(int32_t d) { pn_message_set_group_sequence(pn_msg(), d); }
void message::correlation_id(const message_id& id) { value(pn_message_correlation_id(pn_msg())) = id; }
void message::decode(const std::vector<char> &s) { if (s.empty()) throw error("message decode: no data"); impl().clear(); check(pn_message_decode(pn_msg(), &s[0], s.size())); }
void message::subject(const std::string &s) { check(pn_message_set_subject(pn_msg(), s.c_str())); }