Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

isize_t msg_iovec ( msg_t msg,
msg_iovec_t  vec[],
isize_t  veclen 
) [related]

Fill an I/O vector with message contents.

Calculate number of entries in the I/O vector required to send a message msg. It also fills in the I/O vector array, if it is provided by the caller and it is large enough.

msgpointer to message object
vecI/O vector (may be NULL)
veclenlength of I/O vector in vec
Number of entries of I/O vector required by msg, or 0 upon an error.
The caller should check that the I/O vector vec has enough entries. If the vec is too short, it should allocate big enough vector and re-invoke msg_iovec().
See also:
msg_recv_iovec(), su_vsend()

Definition at line 2069 of file msg_parser.c.

Referenced by tport_log_msg(), and tport_send_msg().

  size_t len = 0, n = 0;
  char const *p = NULL;
  msg_header_t *h;

  size_t total = 0;

  if (veclen <= 0)
    veclen = 0;

  for (h = msg->m_chain; h; h = h->sh_succ) {
    if (h->sh_data != p) {
      p = h->sh_data; len = h->sh_len;

      if (p == NULL)
      return 0;

      if (vec && n != veclen)
      /* new iovec entry */
      vec[n].mv_base = (void *)p, vec[n].mv_len = (su_ioveclen_t)len;
      vec = NULL;

      p += len; n++;
    else {
      /* extend old entry */
      len = h->sh_len;
      if (vec)
      vec[n-1].mv_len += (su_ioveclen_t)len;
      p += len;

    total += len;

  msg->m_size = total;

  return n;

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index