Browse Source

get rid of the useless ROC and keep variable naming consistent

git.mgm/mediaproxy-ng/github/master
Richard Fuchs 13 years ago
parent
commit
f75bc44685
4 changed files with 14 additions and 17 deletions
  1. +5
    -5
      daemon/call.c
  2. +1
    -3
      daemon/crypto.h
  3. +2
    -2
      daemon/rtcp.c
  4. +6
    -7
      daemon/rtp.c

+ 5
- 5
daemon/call.c View File

@ -359,7 +359,7 @@ static int __k_srtp_crypt(struct mediaproxy_srtp *s, struct crypto_context *c) {
.hmac = c->crypto_suite->kernel_hmac,
.mki = c->mki,
.mki_len = c->mki_len,
.last_index = c->s_l,
.last_index = c->last_index,
.auth_tag_len = c->crypto_suite->srtp_auth_tag,
};
memcpy(s->master_key, c->master_key, c->crypto_suite->master_key_len);
@ -1071,13 +1071,13 @@ static void callmaster_timer(void *ptr) {
update = 0;
if (sr->other->crypto.out.crypto_suite
&& ke->target.encrypt.last_index - sr->other->crypto.out.s_l > 0x4000) {
sr->other->crypto.out.s_l = ke->target.encrypt.last_index;
&& ke->target.encrypt.last_index - sr->other->crypto.out.last_index > 0x4000) {
sr->other->crypto.out.last_index = ke->target.encrypt.last_index;
update = 1;
}
if (sr->crypto.in.crypto_suite
&& ke->target.decrypt.last_index - sr->crypto.in.s_l > 0x4000) {
sr->crypto.in.s_l = ke->target.decrypt.last_index;
&& ke->target.decrypt.last_index - sr->crypto.in.last_index > 0x4000) {
sr->crypto.in.last_index = ke->target.decrypt.last_index;
update = 1;
}


+ 1
- 3
daemon/crypto.h View File

@ -55,9 +55,7 @@ struct crypto_context {
unsigned int mki_len;
unsigned int tag;
/* from rfc 3711 */
u_int32_t roc;
u_int64_t s_l;
u_int64_t last_index;
/* XXX replay list */
/* <from, to>? */


+ 2
- 2
daemon/rtcp.c View File

@ -395,11 +395,11 @@ int rtcp_avp2savp(str *s, struct crypto_context *c) {
if (check_session_keys(c))
return -1;
if (crypto_encrypt_rtcp(c, rtcp, &payload, c->s_l))
if (crypto_encrypt_rtcp(c, rtcp, &payload, c->last_index))
return -1;
idx = (void *) s->s + s->len;
*idx = htonl(0x80000000ULL | c->s_l++);
*idx = htonl(0x80000000ULL | c->last_index++);
s->len += sizeof(*idx);
to_auth = *s;


+ 6
- 7
daemon/rtp.c View File

@ -96,15 +96,15 @@ static u_int64_t packet_index(struct crypto_context *c, struct rtp_header *rtp)
seq = ntohs(rtp->seq_num);
/* rfc 3711 section 3.3.1 */
if (G_UNLIKELY(!c->s_l))
c->s_l = seq;
if (G_UNLIKELY(!c->last_index))
c->last_index = seq;
/* rfc 3711 appendix A, modified, and sections 3.3 and 3.3.1 */
index = ((u_int64_t) c->roc << 16) | seq;
diff = index - c->s_l;
index = (c->last_index & 0xffffffff0000ULL) | seq;
diff = index - c->last_index;
if (diff >= 0) {
if (diff < 0x8000)
c->s_l = index;
c->last_index = index;
else if (index >= 0x10000)
index -= 0x10000;
}
@ -113,8 +113,7 @@ static u_int64_t packet_index(struct crypto_context *c, struct rtp_header *rtp)
;
else {
index += 0x10000;
c->roc++;
c->s_l = index;
c->last_index = index;
}
}


Loading…
Cancel
Save