msg.c File Reference


Detailed Description

Message object implementation.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>
Date:
Created: Thu Jun 8 19:28:55 2000 ppessi

#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#include <errno.h>
#include <assert.h>
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/su.h>
#include "msg_internal.h"
#include "sofia-sip/msg_parser.h"
#include "sofia-sip/msg_mclass.h"

Include dependency graph for msg.c:

Functions

msg_tmsg_create (msg_mclass_t const *mc, int flags)
 Create a message.
msg_tmsg_ref_create (msg_t *msg)
 Increment a message reference count.
void msg_set_parent (msg_t *kid, msg_t *dad)
 Set a message parent.
void msg_ref_destroy (msg_t *ref)
 Destroy a reference to a message.
void msg_destroy (msg_t *msg)
 Deinitialize and free a message.
msg_pub_tmsg_object (msg_t const *msg)
 Retrieve public message structure.
msg_pub_tmsg_public (msg_t const *msg, void *tag)
 Retrieve public message structure of given type.
msg_mclass_t const * msg_mclass (msg_t const *msg)
 Retrieve message class.
void msg_addr_zero (msg_t *msg)
 Zero the message address.
su_sockaddr_t * msg_addr (msg_t *msg)
 Get pointer to socket address structure.
int msg_get_address (msg_t *msg, su_sockaddr_t *su, socklen_t *return_len)
 Get message address.
int msg_set_address (msg_t *msg, su_sockaddr_t const *su, socklen_t sulen)
 Set message address.
su_addrinfo_t * msg_addrinfo (msg_t *msg)
 Get addrinfo structure.
void msg_addr_copy (msg_t *dst, msg_t const *src)
 Copy message address.
unsigned msg_extract_errors (msg_t const *msg)
 Get error classification flags.
int msg_errno (msg_t const *msg)
 Get error number associated with message.
void msg_set_errno (msg_t *msg, int err)
 Set error number associated with message.


Function Documentation

su_sockaddr_t* msg_addr ( msg_t msg  ) 

Get pointer to socket address structure.

Deprecated:
Use msg_get_address() or msg_set_address() instead.

void msg_addr_copy ( msg_t dst,
msg_t const *  src 
)

Copy message address.

Copy the addrinfo and socket address structures from src to the dst message object.

Parameters:
dst pointer to destination message object
src pointer to source message object
See also:
msg_addrinfo(), msg_get_address(), msg_set_address(), msg_addr_zero().

void msg_addr_zero ( msg_t msg  ) 

Zero the message address.

Zero the address and addressinfo structures associated with the message.

See also:
msg_addrinfo(), msg_set_address(), msg_get_address(), msg_addr_copy().

su_addrinfo_t* msg_addrinfo ( msg_t msg  ) 

Get addrinfo structure.

Get pointer to the addrinfo structure associated with the message.

Parameters:
msg pointer to msg object
Return values:
pointer to addrinfo structure
NULL if msg is NULL
See also:
msg_get_address(), msg_set_address(), msg_addr_zero(), msg_addr_copy().

msg_t* msg_create ( msg_mclass_t const *  mc,
int  flags 
)

Create a message.

Parameters:
mc message class
flags message control flags

void msg_destroy ( msg_t msg  ) 

Deinitialize and free a message.

Parameters:
msg message to be destroyed

int msg_errno ( msg_t const *  msg  ) 

Get error number associated with message.

Parameters:
msg pointer to msg object

unsigned msg_extract_errors ( msg_t const *  msg  ) 

Get error classification flags.

If the message parser fails to parse certain headers in the message, it sets the corresponding extract error flags. The flags corresponding to each header are stored in the message parser (msg_mclass_t) structure. They are set when the header is added to the parser table.

The SIP flags are defined in <sofia-sip/sip_headers.h>. For well-known SIP headers, the flags for each header are listed in a separate text file (sip_bad_mask) read by msg_parser.awk.

The flags can be used directly by NTA (the mask triggering 400 response is set with NTATAG_BAD_REQ_MASK(), the mask triggering response messages to be dropped is set with NTATAG_BAD_RESP_MASK()). Alternatively the application can check them based on the method or required SIP features.

See also:
msg_mclass_insert_with_mask(), NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK().

int msg_get_address ( msg_t msg,
su_sockaddr_t *  su,
socklen_t *  return_len 
)

Get message address.

Copy the socket address associated with the message to the supplied socket address struture.

Parameters:
msg pointer to msg object
su pointer to socket address structure
return_len return parameter value for length of socket address structure
See also:
msg_addrinfo(), msg_set_address(), msg_addr_zero(), msg_addr_copy().

msg_mclass_t const* msg_mclass ( msg_t const *  msg  ) 

Retrieve message class.

Get a pointer to the message class object (factory object for the message).

Parameters:
msg pointer to msg object
Returns:
A pointer to the message class, or NULL if none.

msg_pub_t* msg_object ( msg_t const *  msg  ) 

Retrieve public message structure.

Get a pointer to the public message structure.

Parameters:
msg pointer to msg object
Returns:
A pointer to the public message structure, or NULL if none.

msg_pub_t* msg_public ( msg_t const *  msg,
void *  tag 
)

Retrieve public message structure of given type.

Get a pointer to the public message structure of the given protocol.

Parameters:
msg pointer to msg object
tag tag of public message structure
Returns:
A pointer to the public message structure, or NULL if there is none or the message is not for desired protocol.

msg_t* msg_ref_create ( msg_t msg  ) 

Increment a message reference count.

Creates a reference to a message. The referenced message is not freed until all the references have been destroyed.

Parameters:
msg message of which a reference is created
Returns:
A pointer to a message.

void msg_ref_destroy ( msg_t ref  ) 

Destroy a reference to a message.

Parameters:
ref pointer to msg object
Deprecated:
Use msg_destroy() instead.

int msg_set_address ( msg_t msg,
su_sockaddr_t const *  su,
socklen_t  sulen 
)

Set message address.

Copy the supplied socket address to the socket address structure associated with the message.

Parameters:
msg pointer to msg object
su pointer to socket address structure
sulen length of socket address structure
See also:
msg_addrinfo(), msg_get_address(), msg_addr_zero(), msg_addr_copy().

void msg_set_errno ( msg_t msg,
int  err 
)

Set error number associated with message.

Parameters:
msg pointer to msg object
err error value (as defined in <sofia-sip/su_errno.h>).

void msg_set_parent ( msg_t kid,
msg_t dad 
)

Set a message parent.

Set a parent for a message. The parent message is not destroyed until all its kids have been destroyed - each kid keeps a reference to its parent message.

Parameters:
kid child message
dad parent message


Sofia-SIP 1.12.6work - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.