Commit 15f1e5f8 authored by johan's avatar johan

move ZRTP management from oRTP to Mediastreamer2 using transport modifier

parent 49796063
......@@ -296,31 +296,6 @@ else
SRTP_LIBS=
fi
dnl check for libzrtp support (RFC 6189: Media Path Key Agreement for Unicast Secure RTP)
AC_ARG_ENABLE(zrtp,
[AS_HELP_STRING([--enable-zrtp], [Turn on or off compilation of zrtp (default=no)])],
[case "${enableval}" in
yes) zrtp=true ;;
no) zrtp=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-zrtp) ;;
esac],
[zrtp=false]
)
if test "$zrtp" = "true" ; then
PKG_CHECK_MODULES(LIBBZRTP, libbzrtp >= 0.0.0)
if test "$have_srtp" = "no" ; then
AC_MSG_ERROR("ZRTP requires SRTP")
fi
AC_DEFINE(HAVE_zrtp, 1, [Defined when zrtp support is compiled])
else
echo "ZRTP compilation is disabled."
fi
AM_CONDITIONAL(LIBBZRTP,test x$zrtp != xfalse)
if test $debug_enabled = "yes"; then
ORTP_DEFS="$ORTP_DEFS -DORTP_DEBUG_MODE"
CFLAGS=`echo $CFLAGS | sed 's/-O.//'`
......@@ -394,8 +369,8 @@ fi
AC_SUBST(SSL_LIBS)
ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LIBS $PTHREAD_LDFLAGS $RT_LIBS $SRTP_LIBS $SSL_LIBS $LIBBZRTP_LIBS"
ORTPDEPS_CFLAGS="$ORTPDEPS_CFLAGS $PTHREAD_CFLAGS $ORTP_DEFS $SRTP_CFLAGS $LIBBZRTP_CFLAGS"
ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LIBS $PTHREAD_LDFLAGS $RT_LIBS $SRTP_LIBS $SSL_LIBS"
ORTPDEPS_CFLAGS="$ORTPDEPS_CFLAGS $PTHREAD_CFLAGS $ORTP_DEFS $SRTP_CFLAGS"
CFLAGS="$CFLAGS $ORTP_DEFS"
echo "$ORTPDEPS_CFLAGS" > ortp.defs
......
......@@ -5,7 +5,7 @@ ortp_includedir=$(includedir)/ortp
ortp_include_HEADERS=str_utils.h rtpsession.h rtp.h port.h logging.h \
ortp.h telephonyevents.h sessionset.h payloadtype.h rtpprofile.h rtpsignaltable.h \
rtcp.h \
event.h stun.h stun_udp.h ortp_srtp.h zrtp.h \
event.h stun.h stun_udp.h ortp_srtp.h \
b64.h
EXTRA_DIST=$(ortp_include_HEADERS)
......@@ -469,6 +469,7 @@ ORTP_PUBLIC void rtp_session_set_ssrc_changed_threshold(RtpSession *session, int
/*low level recv and send functions */
ORTP_PUBLIC mblk_t * rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts);
ORTP_PUBLIC mblk_t * rtp_session_create_packet(RtpSession *session,int header_size, const uint8_t *payload, int payload_size);
ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size);
ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, int payload_size, void (*freefn)(void*));
ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, int size, void (*freefn)(void*) );
ORTP_PUBLIC int rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t userts);
......@@ -586,6 +587,7 @@ ORTP_PUBLIC void rtp_session_set_reuseaddr(RtpSession *session, bool_t yes);
* @param[in] modifiers_count number of #RtpModifier object given in the variadic list. Must be 0 if none are given.
* @returns 0 if successful, -1 otherwise
**/
ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet(RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags);
ORTP_PUBLIC int meta_rtp_transport_new(RtpTransport **t, bool_t is_rtp, RtpTransport *endpoint, unsigned modifiers_count, ...);
ORTP_PUBLIC void meta_rtp_transport_destroy(RtpTransport *tp);
ORTP_PUBLIC void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *tpm);
......
/*
The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
Copyright (C) 2011 Belledonne Communications
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ortp_zrtp_h
#define ortp_zrtp_h
#include <ortp/rtpsession.h>
#ifdef __cplusplus
extern "C"{
#endif
typedef struct OrtpZrtpParams {
const char *zid_file; // File where to store secrets and other information
const char *uri; /* the sip URI of correspondant */
} OrtpZrtpParams;
typedef struct _OrtpZrtpContext OrtpZrtpContext ;
ORTP_PUBLIC bool_t ortp_zrtp_available(void);
/**
* @deprecated Use ortp_zrtp_transport_modifier_new() instead. Using #srtp_transport_new will prevent usage of multiple
* encryptions and/or custom packets transmission.
*/
ORTP_PUBLIC OrtpZrtpContext* ortp_zrtp_context_new(RtpSession *s, OrtpZrtpParams *params);
ORTP_PUBLIC void ortp_zrtp_context_destroy(OrtpZrtpContext *ctx);
/**
* can be used to give more time for establishing zrtp session
* */
ORTP_PUBLIC void ortp_zrtp_reset_transmition_timer(OrtpZrtpContext* ctx, RtpSession *s);
ORTP_PUBLIC OrtpZrtpContext* ortp_zrtp_multistream_new(OrtpZrtpContext* activeContext, RtpSession *s, OrtpZrtpParams *params);
ORTP_PUBLIC void ortp_zrtp_sas_verified(OrtpZrtpContext* ctx);
ORTP_PUBLIC void ortp_zrtp_sas_reset_verified(OrtpZrtpContext* ctx);
ORTP_PUBLIC int ortp_zrtp_transport_modifier_new(OrtpZrtpContext* ctx, RtpTransportModifier **rtpt, RtpTransportModifier **rtcpt );
ORTP_PUBLIC void ortp_zrtp_transport_modifier_destroy(RtpTransportModifier *tp);
#ifdef __cplusplus
}
#endif
#endif
......@@ -45,15 +45,9 @@ libortp_la_SOURCES= str_utils.c \
stun.c stun_udp.c \
ortp_srtp.c \
b64.c \
zrtp.c \
netsim.c
if LIBBZRTP
AM_CFLAGS+= $(LIBBZRTP_CFLAGS)
AM_LDFLAGS+= $(LIBBZRTP_LDFLAGS)
endif
libortp_la_LIBADD= $(PTHREAD_LIBS) $(RT_LIBS) -lm $(SRTP_LIBS) $(SSL_LIBS) $(LIBBZRTP_LIBS)
libortp_la_LIBADD= $(PTHREAD_LIBS) $(RT_LIBS) -lm $(SRTP_LIBS) $(SSL_LIBS)
libortp_la_LDFLAGS= -version-info $(LIBORTP_SO_VERSION) -no-undefined
......
......@@ -787,6 +787,21 @@ mblk_t * rtp_session_create_packet(RtpSession *session,int header_size, const ui
return mp;
}
/**
* Create a packet already including headers
*/
mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size) {
mblk_t *mp;
mp=allocb(packet_size,BPRI_MED);
if (packet_size){
memcpy(mp->b_wptr,packet,packet_size);
mp->b_wptr+=packet_size;
}
return mp;
}
/**
* Creates a new rtp packet using the given payload buffer (no copy). The header will be allocated separetely.
* In the header, ssrc and payload_type according to the session's
......@@ -2010,6 +2025,56 @@ int meta_rtp_transport_sendto(RtpTransport *t, mblk_t *msg , int flags, const s
return ret;
}
/**
* allow a modifier to inject a packet wich will be treated by successive modifiers
*/
int meta_rtp_transport_modifier_inject_packet(RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags) {
int prev_ret,ret;
OList *elem;
struct sockaddr *to;
socklen_t tolen;
bool_t packetInjected = FALSE;
MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
if (!m->has_set_session){
meta_rtp_set_session(t->session,m);
}
/* get back socket from transport session */
to=(struct sockaddr*)&t->session->rtp.gs.rem_addr;
tolen=t->session->rtp.gs.rem_addrlen;
prev_ret=msgdsize(msg);
for (elem=m->modifiers;elem!=NULL;elem=o_list_next(elem)){
/* run modifiers only after packet injection, the modifier given in parameter is not applied */
if (packetInjected == TRUE) {
RtpTransportModifier *rtm=(RtpTransportModifier*)elem->data;
ret = rtm->t_process_on_send(rtm,msg);
if (ret<0){
// something went wrong in the modifier (failed to encrypt for instance)
return ret;
}
msg->b_wptr+=(ret-prev_ret);
prev_ret=ret;
}
/* check if we must inject the packet */
if (elem->data == tpm) {
packetInjected = TRUE;
}
}
if (m->endpoint!=NULL){
ret=m->endpoint->t_sendto(m->endpoint,msg,flags,to,tolen);
}else{
ret=sendto(m->is_rtp?t->session->rtp.gs.socket:t->session->rtcp.gs.socket,(void*)msg->b_rptr,msgdsize(msg),flags,to,tolen);
}
return ret;
}
int meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen) {
int ret,prev_ret;
MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment