|
|
|
@ -21,10 +21,10 @@
|
|
|
|
|
#include <linux/netfilter_ipv4.h>
|
|
|
|
|
#include <linux/netfilter_ipv6.h>
|
|
|
|
|
#include <linux/netfilter/x_tables.h>
|
|
|
|
|
#ifndef __MP_EXTERNAL
|
|
|
|
|
#include <linux/netfilter/xt_MEDIAPROXY.h>
|
|
|
|
|
#ifndef __RE_EXTERNAL
|
|
|
|
|
#include <linux/netfilter/xt_RTPENGINE.h>
|
|
|
|
|
#else
|
|
|
|
|
#include "xt_MEDIAPROXY.h"
|
|
|
|
|
#include "xt_RTPENGINE.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
@ -33,7 +33,7 @@ MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_ID 64 /* - 1 */
|
|
|
|
|
#define MAX_SKB_TAIL_ROOM (sizeof(((struct mediaproxy_srtp *) 0)->mki) + 20)
|
|
|
|
|
#define MAX_SKB_TAIL_ROOM (sizeof(((struct rtpengine_srtp *) 0)->mki) + 20)
|
|
|
|
|
|
|
|
|
|
#define MIPF "%i:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x:%u"
|
|
|
|
|
#define MIPP(x) (x).family, \
|
|
|
|
@ -70,10 +70,10 @@ MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct mp_hmac;
|
|
|
|
|
struct mp_cipher;
|
|
|
|
|
struct re_hmac;
|
|
|
|
|
struct re_cipher;
|
|
|
|
|
struct rtp_parsed;
|
|
|
|
|
struct mp_crypto_context;
|
|
|
|
|
struct re_crypto_context;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -81,7 +81,7 @@ struct mp_crypto_context;
|
|
|
|
|
static struct proc_dir_entry *my_proc_root;
|
|
|
|
|
static struct proc_dir_entry *proc_list;
|
|
|
|
|
static struct proc_dir_entry *proc_control;
|
|
|
|
|
static struct mediaproxy_table *table[MAX_ID];
|
|
|
|
|
static struct rtpengine_table *table[MAX_ID];
|
|
|
|
|
static rwlock_t table_lock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,13 +115,13 @@ static void proc_main_list_stop(struct seq_file *, void *);
|
|
|
|
|
static void *proc_main_list_next(struct seq_file *, void *, loff_t *);
|
|
|
|
|
static int proc_main_list_show(struct seq_file *, void *);
|
|
|
|
|
|
|
|
|
|
static void table_push(struct mediaproxy_table *);
|
|
|
|
|
static struct mediaproxy_target *get_target(struct mediaproxy_table *, u_int16_t);
|
|
|
|
|
static void table_push(struct rtpengine_table *);
|
|
|
|
|
static struct rtpengine_target *get_target(struct rtpengine_table *, u_int16_t);
|
|
|
|
|
|
|
|
|
|
static int aes_f8_session_key_init(struct mp_crypto_context *, struct mediaproxy_srtp *);
|
|
|
|
|
static int srtp_encrypt_aes_cm(struct mp_crypto_context *, struct mediaproxy_srtp *,
|
|
|
|
|
static int aes_f8_session_key_init(struct re_crypto_context *, struct rtpengine_srtp *);
|
|
|
|
|
static int srtp_encrypt_aes_cm(struct re_crypto_context *, struct rtpengine_srtp *,
|
|
|
|
|
struct rtp_parsed *, u_int64_t);
|
|
|
|
|
static int srtp_encrypt_aes_f8(struct mp_crypto_context *, struct mediaproxy_srtp *,
|
|
|
|
|
static int srtp_encrypt_aes_f8(struct re_crypto_context *, struct rtpengine_srtp *,
|
|
|
|
|
struct rtp_parsed *, u_int64_t);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -129,7 +129,7 @@ static int srtp_encrypt_aes_f8(struct mp_crypto_context *, struct mediaproxy_srt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct mp_crypto_context {
|
|
|
|
|
struct re_crypto_context {
|
|
|
|
|
spinlock_t lock; /* protects roc and last_index */
|
|
|
|
|
unsigned char session_key[16];
|
|
|
|
|
unsigned char session_salt[14];
|
|
|
|
@ -137,33 +137,33 @@ struct mp_crypto_context {
|
|
|
|
|
u_int32_t roc;
|
|
|
|
|
struct crypto_cipher *tfm[2];
|
|
|
|
|
struct crypto_shash *shash;
|
|
|
|
|
const struct mp_cipher *cipher;
|
|
|
|
|
const struct mp_hmac *hmac;
|
|
|
|
|
const struct re_cipher *cipher;
|
|
|
|
|
const struct re_hmac *hmac;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mediaproxy_target {
|
|
|
|
|
struct rtpengine_target {
|
|
|
|
|
atomic_t refcnt;
|
|
|
|
|
u_int32_t table;
|
|
|
|
|
struct mediaproxy_target_info target;
|
|
|
|
|
struct rtpengine_target_info target;
|
|
|
|
|
|
|
|
|
|
spinlock_t stats_lock;
|
|
|
|
|
struct mediaproxy_stats stats;
|
|
|
|
|
struct rtpengine_stats stats;
|
|
|
|
|
|
|
|
|
|
struct mp_crypto_context decrypt;
|
|
|
|
|
struct mp_crypto_context encrypt;
|
|
|
|
|
struct re_crypto_context decrypt;
|
|
|
|
|
struct re_crypto_context encrypt;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mp_bitfield {
|
|
|
|
|
struct re_bitfield {
|
|
|
|
|
unsigned long b[256 / (sizeof(unsigned long) * 8)];
|
|
|
|
|
unsigned int used;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mp_bucket {
|
|
|
|
|
struct mp_bitfield targets;
|
|
|
|
|
struct mediaproxy_target *target[256];
|
|
|
|
|
struct re_bucket {
|
|
|
|
|
struct re_bitfield targets;
|
|
|
|
|
struct rtpengine_target *target[256];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mediaproxy_table {
|
|
|
|
|
struct rtpengine_table {
|
|
|
|
|
atomic_t refcnt;
|
|
|
|
|
rwlock_t target_lock;
|
|
|
|
|
pid_t pid;
|
|
|
|
@ -175,25 +175,25 @@ struct mediaproxy_table {
|
|
|
|
|
struct proc_dir_entry *list;
|
|
|
|
|
struct proc_dir_entry *blist;
|
|
|
|
|
|
|
|
|
|
struct mp_bitfield buckets;
|
|
|
|
|
struct mp_bucket *bucket[256];
|
|
|
|
|
struct re_bitfield buckets;
|
|
|
|
|
struct re_bucket *bucket[256];
|
|
|
|
|
|
|
|
|
|
unsigned int targets;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mp_cipher {
|
|
|
|
|
enum mediaproxy_cipher id;
|
|
|
|
|
struct re_cipher {
|
|
|
|
|
enum rtpengine_cipher id;
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *tfm_name;
|
|
|
|
|
int (*decrypt)(struct mp_crypto_context *, struct mediaproxy_srtp *,
|
|
|
|
|
int (*decrypt)(struct re_crypto_context *, struct rtpengine_srtp *,
|
|
|
|
|
struct rtp_parsed *, u_int64_t);
|
|
|
|
|
int (*encrypt)(struct mp_crypto_context *, struct mediaproxy_srtp *,
|
|
|
|
|
int (*encrypt)(struct re_crypto_context *, struct rtpengine_srtp *,
|
|
|
|
|
struct rtp_parsed *, u_int64_t);
|
|
|
|
|
int (*session_key_init)(struct mp_crypto_context *, struct mediaproxy_srtp *);
|
|
|
|
|
int (*session_key_init)(struct re_crypto_context *, struct rtpengine_srtp *);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mp_hmac {
|
|
|
|
|
enum mediaproxy_hmac id;
|
|
|
|
|
struct re_hmac {
|
|
|
|
|
enum rtpengine_hmac id;
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *tfm_name;
|
|
|
|
|
};
|
|
|
|
@ -278,24 +278,24 @@ static const struct seq_operations proc_main_list_seq_ops = {
|
|
|
|
|
.show = proc_main_list_show,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct mp_cipher mp_ciphers[] = {
|
|
|
|
|
[MPC_INVALID] = {
|
|
|
|
|
.id = MPC_INVALID,
|
|
|
|
|
static const struct re_cipher re_ciphers[] = {
|
|
|
|
|
[REC_INVALID] = {
|
|
|
|
|
.id = REC_INVALID,
|
|
|
|
|
.name = NULL,
|
|
|
|
|
},
|
|
|
|
|
[MPC_NULL] = {
|
|
|
|
|
.id = MPC_NULL,
|
|
|
|
|
[REC_NULL] = {
|
|
|
|
|
.id = REC_NULL,
|
|
|
|
|
.name = "NULL",
|
|
|
|
|
},
|
|
|
|
|
[MPC_AES_CM] = {
|
|
|
|
|
.id = MPC_AES_CM,
|
|
|
|
|
[REC_AES_CM] = {
|
|
|
|
|
.id = REC_AES_CM,
|
|
|
|
|
.name = "AES-CM",
|
|
|
|
|
.tfm_name = "aes",
|
|
|
|
|
.decrypt = srtp_encrypt_aes_cm,
|
|
|
|
|
.encrypt = srtp_encrypt_aes_cm,
|
|
|
|
|
},
|
|
|
|
|
[MPC_AES_F8] = {
|
|
|
|
|
.id = MPC_AES_F8,
|
|
|
|
|
[REC_AES_F8] = {
|
|
|
|
|
.id = REC_AES_F8,
|
|
|
|
|
.name = "AES-F8",
|
|
|
|
|
.tfm_name = "aes",
|
|
|
|
|
.decrypt = srtp_encrypt_aes_f8,
|
|
|
|
@ -304,23 +304,23 @@ static const struct mp_cipher mp_ciphers[] = {
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct mp_hmac mp_hmacs[] = {
|
|
|
|
|
[MPH_INVALID] = {
|
|
|
|
|
.id = MPH_INVALID,
|
|
|
|
|
static const struct re_hmac re_hmacs[] = {
|
|
|
|
|
[REH_INVALID] = {
|
|
|
|
|
.id = REH_INVALID,
|
|
|
|
|
.name = NULL,
|
|
|
|
|
},
|
|
|
|
|
[MPH_NULL] = {
|
|
|
|
|
.id = MPH_NULL,
|
|
|
|
|
[REH_NULL] = {
|
|
|
|
|
.id = REH_NULL,
|
|
|
|
|
.name = "NULL",
|
|
|
|
|
},
|
|
|
|
|
[MPH_HMAC_SHA1] = {
|
|
|
|
|
.id = MPH_HMAC_SHA1,
|
|
|
|
|
[REH_HMAC_SHA1] = {
|
|
|
|
|
.id = REH_HMAC_SHA1,
|
|
|
|
|
.name = "HMAC-SHA1",
|
|
|
|
|
.tfm_name = "hmac(sha1)",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char *mp_msm_strings[] = {
|
|
|
|
|
static const char *re_msm_strings[] = {
|
|
|
|
|
[MSM_IGNORE] = "",
|
|
|
|
|
[MSM_DROP] = "drop",
|
|
|
|
|
[MSM_PROPAGATE] = "propagate",
|
|
|
|
@ -330,8 +330,8 @@ static const char *mp_msm_strings[] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct mediaproxy_table *new_table(void) {
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
static struct rtpengine_table *new_table(void) {
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
|
|
|
|
|
DBG("Creating new table\n");
|
|
|
|
|
|
|
|
|
@ -356,7 +356,7 @@ static struct mediaproxy_table *new_table(void) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void table_hold(struct mediaproxy_table *t) {
|
|
|
|
|
static void table_hold(struct rtpengine_table *t) {
|
|
|
|
|
atomic_inc(&t->refcnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -364,7 +364,7 @@ static void table_hold(struct mediaproxy_table *t) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int table_create_proc(struct mediaproxy_table *t, u_int32_t id) {
|
|
|
|
|
static int table_create_proc(struct rtpengine_table *t, u_int32_t id) {
|
|
|
|
|
char num[10];
|
|
|
|
|
|
|
|
|
|
sprintf(num, "%u", id);
|
|
|
|
@ -403,8 +403,8 @@ static int table_create_proc(struct mediaproxy_table *t, u_int32_t id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct mediaproxy_table *new_table_link(u_int32_t id) {
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
static struct rtpengine_table *new_table_link(u_int32_t id) {
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
if (id >= MAX_ID)
|
|
|
|
@ -412,7 +412,7 @@ static struct mediaproxy_table *new_table_link(u_int32_t id) {
|
|
|
|
|
|
|
|
|
|
t = new_table();
|
|
|
|
|
if (!t) {
|
|
|
|
|
printk(KERN_WARNING "xt_MEDIAPROXY out of memory\n");
|
|
|
|
|
printk(KERN_WARNING "xt_RTPENGINE out of memory\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -420,7 +420,7 @@ static struct mediaproxy_table *new_table_link(u_int32_t id) {
|
|
|
|
|
if (table[id]) {
|
|
|
|
|
write_unlock_irqrestore(&table_lock, flags);
|
|
|
|
|
table_push(t);
|
|
|
|
|
printk(KERN_WARNING "xt_MEDIAPROXY duplicate ID %u\n", id);
|
|
|
|
|
printk(KERN_WARNING "xt_RTPENGINE duplicate ID %u\n", id);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -430,7 +430,7 @@ static struct mediaproxy_table *new_table_link(u_int32_t id) {
|
|
|
|
|
write_unlock_irqrestore(&table_lock, flags);
|
|
|
|
|
|
|
|
|
|
if (table_create_proc(t, id))
|
|
|
|
|
printk(KERN_WARNING "xt_MEDIAPROXY failed to create /proc entry for ID %u\n", id);
|
|
|
|
|
printk(KERN_WARNING "xt_RTPENGINE failed to create /proc entry for ID %u\n", id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
@ -440,7 +440,7 @@ static struct mediaproxy_table *new_table_link(u_int32_t id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void free_crypto_context(struct mp_crypto_context *c) {
|
|
|
|
|
static void free_crypto_context(struct re_crypto_context *c) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(c->tfm); i++) {
|
|
|
|
@ -451,7 +451,7 @@ static void free_crypto_context(struct mp_crypto_context *c) {
|
|
|
|
|
crypto_free_shash(c->shash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void target_push(struct mediaproxy_target *t) {
|
|
|
|
|
static void target_push(struct rtpengine_target *t) {
|
|
|
|
|
if (!t)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -471,7 +471,7 @@ static void target_push(struct mediaproxy_target *t) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void target_hold(struct mediaproxy_target *t) {
|
|
|
|
|
static void target_hold(struct rtpengine_target *t) {
|
|
|
|
|
atomic_inc(&t->refcnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -496,9 +496,9 @@ static void clear_proc(struct proc_dir_entry **e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void table_push(struct mediaproxy_table *t) {
|
|
|
|
|
static void table_push(struct rtpengine_table *t) {
|
|
|
|
|
int i, j;
|
|
|
|
|
struct mp_bucket *b;
|
|
|
|
|
struct re_bucket *b;
|
|
|
|
|
|
|
|
|
|
if (!t)
|
|
|
|
|
return;
|
|
|
|
@ -539,7 +539,7 @@ static void table_push(struct mediaproxy_table *t) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int unlink_table(struct mediaproxy_table *t) {
|
|
|
|
|
static int unlink_table(struct rtpengine_table *t) {
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
if (t->id >= MAX_ID)
|
|
|
|
@ -574,8 +574,8 @@ static int unlink_table(struct mediaproxy_table *t) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct mediaproxy_table *get_table(u_int32_t id) {
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
static struct rtpengine_table *get_table(u_int32_t id) {
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
if (id >= MAX_ID)
|
|
|
|
@ -596,7 +596,7 @@ static struct mediaproxy_table *get_table(u_int32_t id) {
|
|
|
|
|
static ssize_t proc_status(struct file *f, char __user *b, size_t l, loff_t *o) {
|
|
|
|
|
struct inode *inode;
|
|
|
|
|
char buf[256];
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
int len = 0;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
u_int32_t id;
|
|
|
|
@ -651,7 +651,7 @@ static void proc_main_list_stop(struct seq_file *f, void *v) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void *proc_main_list_next(struct seq_file *f, void *v, loff_t *o) { /* v is invalid */
|
|
|
|
|
struct mediaproxy_table *t = NULL;
|
|
|
|
|
struct rtpengine_table *t = NULL;
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
|
|
|
|
|
if (*o < 0)
|
|
|
|
@ -671,7 +671,7 @@ static void *proc_main_list_next(struct seq_file *f, void *v, loff_t *o) { /* v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int proc_main_list_show(struct seq_file *f, void *v) {
|
|
|
|
|
struct mediaproxy_table *g = v;
|
|
|
|
|
struct rtpengine_table *g = v;
|
|
|
|
|
|
|
|
|
|
seq_printf(f, "%u\n", g->id);
|
|
|
|
|
table_push(g);
|
|
|
|
@ -695,7 +695,7 @@ static inline unsigned int bitfield_slot(unsigned char i) {
|
|
|
|
|
static inline unsigned int bitfield_bit(unsigned char i) {
|
|
|
|
|
return i % (sizeof(unsigned long) * 8);
|
|
|
|
|
}
|
|
|
|
|
static inline void bitfield_set(struct mp_bitfield *bf, unsigned char i) {
|
|
|
|
|
static inline void bitfield_set(struct re_bitfield *bf, unsigned char i) {
|
|
|
|
|
unsigned int b, m;
|
|
|
|
|
unsigned long k;
|
|
|
|
|
|
|
|
|
@ -707,7 +707,7 @@ static inline void bitfield_set(struct mp_bitfield *bf, unsigned char i) {
|
|
|
|
|
bf->b[b] |= k;
|
|
|
|
|
bf->used++;
|
|
|
|
|
}
|
|
|
|
|
static inline void bitfield_clear(struct mp_bitfield *bf, unsigned char i) {
|
|
|
|
|
static inline void bitfield_clear(struct re_bitfield *bf, unsigned char i) {
|
|
|
|
|
unsigned int b, m;
|
|
|
|
|
unsigned long k;
|
|
|
|
|
|
|
|
|
@ -719,12 +719,12 @@ static inline void bitfield_clear(struct mp_bitfield *bf, unsigned char i) {
|
|
|
|
|
bf->b[b] &= ~k;
|
|
|
|
|
bf->used--;
|
|
|
|
|
}
|
|
|
|
|
static inline struct mediaproxy_target *find_next_target(struct mediaproxy_table *t, int *port) {
|
|
|
|
|
static inline struct rtpengine_target *find_next_target(struct rtpengine_table *t, int *port) {
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
struct mp_bucket *b;
|
|
|
|
|
struct re_bucket *b;
|
|
|
|
|
unsigned char hi, lo;
|
|
|
|
|
unsigned int hi_b, lo_b;
|
|
|
|
|
struct mediaproxy_target *g;
|
|
|
|
|
struct rtpengine_target *g;
|
|
|
|
|
|
|
|
|
|
if (*port < 0 || *port > 0xffff)
|
|
|
|
|
return NULL;
|
|
|
|
@ -784,7 +784,7 @@ next:
|
|
|
|
|
|
|
|
|
|
static int proc_blist_open(struct inode *i, struct file *f) {
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
|
|
|
|
|
id = (u_int32_t) (unsigned long) PDE_DATA(i);
|
|
|
|
|
t = get_table(id);
|
|
|
|
@ -798,7 +798,7 @@ static int proc_blist_open(struct inode *i, struct file *f) {
|
|
|
|
|
|
|
|
|
|
static int proc_blist_close(struct inode *i, struct file *f) {
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
|
|
|
|
|
id = (u_int32_t) (unsigned long) PDE_DATA(i);
|
|
|
|
|
t = get_table(id);
|
|
|
|
@ -813,10 +813,10 @@ static int proc_blist_close(struct inode *i, struct file *f) {
|
|
|
|
|
static ssize_t proc_blist_read(struct file *f, char __user *b, size_t l, loff_t *o) {
|
|
|
|
|
struct inode *inode;
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct mediaproxy_list_entry op;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
struct rtpengine_list_entry op;
|
|
|
|
|
int err;
|
|
|
|
|
struct mediaproxy_target *g;
|
|
|
|
|
struct rtpengine_target *g;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
int port;
|
|
|
|
|
|
|
|
|
@ -875,7 +875,7 @@ static int proc_list_open(struct inode *i, struct file *f) {
|
|
|
|
|
int err;
|
|
|
|
|
struct seq_file *p;
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
|
|
|
|
|
id = (u_int32_t) (unsigned long) PDE_DATA(i);
|
|
|
|
|
t = get_table(id);
|
|
|
|
@ -905,8 +905,8 @@ static void proc_list_stop(struct seq_file *f, void *v) {
|
|
|
|
|
|
|
|
|
|
static void *proc_list_next(struct seq_file *f, void *v, loff_t *o) { /* v is invalid */
|
|
|
|
|
u_int32_t id = (u_int32_t) (unsigned long) f->private;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct mediaproxy_target *g;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
struct rtpengine_target *g;
|
|
|
|
|
int port;
|
|
|
|
|
|
|
|
|
|
port = (int) *o;
|
|
|
|
@ -923,7 +923,7 @@ static void *proc_list_next(struct seq_file *f, void *v, loff_t *o) { /* v is in
|
|
|
|
|
return g;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void proc_list_addr_print(struct seq_file *f, const char *s, const struct mp_address *a) {
|
|
|
|
|
static void proc_list_addr_print(struct seq_file *f, const char *s, const struct re_address *a) {
|
|
|
|
|
if (!a->family)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -945,12 +945,12 @@ static void proc_list_addr_print(struct seq_file *f, const char *s, const struct
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void proc_list_crypto_print(struct seq_file *f, struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, const char *label)
|
|
|
|
|
static void proc_list_crypto_print(struct seq_file *f, struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, const char *label)
|
|
|
|
|
{
|
|
|
|
|
int hdr = 0;
|
|
|
|
|
|
|
|
|
|
if (c->cipher && c->cipher->id != MPC_NULL) {
|
|
|
|
|
if (c->cipher && c->cipher->id != REC_NULL) {
|
|
|
|
|
if (!hdr++)
|
|
|
|
|
seq_printf(f, " SRTP %s parameters:\n", label);
|
|
|
|
|
seq_printf(f, " cipher: %s\n", c->cipher->name ? : "<invalid>");
|
|
|
|
@ -960,7 +960,7 @@ static void proc_list_crypto_print(struct seq_file *f, struct mp_crypto_context
|
|
|
|
|
s->mki[0], s->mki[1], s->mki[2], s->mki[3],
|
|
|
|
|
s->mki[4], s->mki[5], s->mki[6], s->mki[7]);
|
|
|
|
|
}
|
|
|
|
|
if (c->hmac && c->hmac->id != MPH_NULL) {
|
|
|
|
|
if (c->hmac && c->hmac->id != REH_NULL) {
|
|
|
|
|
if (!hdr++)
|
|
|
|
|
seq_printf(f, " SRTP %s parameters:\n", label);
|
|
|
|
|
seq_printf(f, " HMAC: %s\n", c->hmac->name ? : "<invalid>");
|
|
|
|
@ -969,7 +969,7 @@ static void proc_list_crypto_print(struct seq_file *f, struct mp_crypto_context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int proc_list_show(struct seq_file *f, void *v) {
|
|
|
|
|
struct mediaproxy_target *g = v;
|
|
|
|
|
struct rtpengine_target *g = v;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
seq_printf(f, "port %5u:\n", g->target.target_port);
|
|
|
|
@ -977,8 +977,8 @@ static int proc_list_show(struct seq_file *f, void *v) {
|
|
|
|
|
proc_list_addr_print(f, "dst", &g->target.dst_addr);
|
|
|
|
|
proc_list_addr_print(f, "mirror", &g->target.mirror_addr);
|
|
|
|
|
proc_list_addr_print(f, "expect", &g->target.expected_src);
|
|
|
|
|
if (g->target.src_mismatch > 0 && g->target.src_mismatch <= ARRAY_SIZE(mp_msm_strings))
|
|
|
|
|
seq_printf(f, " src mismatch action: %s\n", mp_msm_strings[g->target.src_mismatch]);
|
|
|
|
|
if (g->target.src_mismatch > 0 && g->target.src_mismatch <= ARRAY_SIZE(re_msm_strings))
|
|
|
|
|
seq_printf(f, " src mismatch action: %s\n", re_msm_strings[g->target.src_mismatch]);
|
|
|
|
|
spin_lock_irqsave(&g->stats_lock, flags);
|
|
|
|
|
seq_printf(f, " stats: %20llu bytes, %20llu packets, %20llu errors\n",
|
|
|
|
|
g->stats.bytes, g->stats.packets, g->stats.errors);
|
|
|
|
@ -999,10 +999,10 @@ static int proc_list_show(struct seq_file *f, void *v) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int table_del_target(struct mediaproxy_table *t, u_int16_t port) {
|
|
|
|
|
static int table_del_target(struct rtpengine_table *t, u_int16_t port) {
|
|
|
|
|
unsigned char hi, lo;
|
|
|
|
|
struct mp_bucket *b;
|
|
|
|
|
struct mediaproxy_target *g = NULL;
|
|
|
|
|
struct re_bucket *b;
|
|
|
|
|
struct rtpengine_target *g = NULL;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
if (!port)
|
|
|
|
@ -1045,15 +1045,15 @@ out:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int is_valid_address(struct mp_address *mpa) {
|
|
|
|
|
switch (mpa->family) {
|
|
|
|
|
static int is_valid_address(struct re_address *rea) {
|
|
|
|
|
switch (rea->family) {
|
|
|
|
|
case AF_INET:
|
|
|
|
|
if (!mpa->u.ipv4)
|
|
|
|
|
if (!rea->u.ipv4)
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AF_INET6:
|
|
|
|
|
if (!mpa->u.u32[0] && !mpa->u.u32[1] && !mpa->u.u32[2] && !mpa->u.u32[3])
|
|
|
|
|
if (!rea->u.u32[0] && !rea->u.u32[1] && !rea->u.u32[2] && !rea->u.u32[3])
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -1061,7 +1061,7 @@ static int is_valid_address(struct mp_address *mpa) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mpa->port)
|
|
|
|
|
if (!rea->port)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
@ -1070,14 +1070,14 @@ static int is_valid_address(struct mp_address *mpa) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int validate_srtp(struct mediaproxy_srtp *s) {
|
|
|
|
|
if (s->cipher <= MPC_INVALID)
|
|
|
|
|
static int validate_srtp(struct rtpengine_srtp *s) {
|
|
|
|
|
if (s->cipher <= REC_INVALID)
|
|
|
|
|
return -1;
|
|
|
|
|
if (s->cipher >= __MPC_LAST)
|
|
|
|
|
if (s->cipher >= __REC_LAST)
|
|
|
|
|
return -1;
|
|
|
|
|
if (s->hmac <= MPH_INVALID)
|
|
|
|
|
if (s->hmac <= REH_INVALID)
|
|
|
|
|
return -1;
|
|
|
|
|
if (s->hmac >= __MPH_LAST)
|
|
|
|
|
if (s->hmac >= __REH_LAST)
|
|
|
|
|
return -1;
|
|
|
|
|
if (s->auth_tag_len > 20)
|
|
|
|
|
return -1;
|
|
|
|
@ -1234,7 +1234,7 @@ static int prf_n(unsigned char *out, int len, const unsigned char *key, const un
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int gen_session_key(unsigned char *out, int len, struct mediaproxy_srtp *s, unsigned char label) {
|
|
|
|
|
static int gen_session_key(unsigned char *out, int len, struct rtpengine_srtp *s, unsigned char label) {
|
|
|
|
|
unsigned char key_id[7];
|
|
|
|
|
unsigned char x[14];
|
|
|
|
|
int i, ret;
|
|
|
|
@ -1256,7 +1256,7 @@ static int gen_session_key(unsigned char *out, int len, struct mediaproxy_srtp *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int aes_f8_session_key_init(struct mp_crypto_context *c, struct mediaproxy_srtp *s) {
|
|
|
|
|
static int aes_f8_session_key_init(struct re_crypto_context *c, struct rtpengine_srtp *s) {
|
|
|
|
|
unsigned char m[16];
|
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
|
@ -1281,11 +1281,11 @@ error:
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int gen_session_keys(struct mp_crypto_context *c, struct mediaproxy_srtp *s) {
|
|
|
|
|
static int gen_session_keys(struct re_crypto_context *c, struct rtpengine_srtp *s) {
|
|
|
|
|
int ret;
|
|
|
|
|
const char *err;
|
|
|
|
|
|
|
|
|
|
if (s->cipher == MPC_NULL && s->hmac == MPH_NULL)
|
|
|
|
|
if (s->cipher == REC_NULL && s->hmac == REH_NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
err = "failed to generate session key";
|
|
|
|
|
ret = gen_session_key(c->session_key, 16, s, 0x00);
|
|
|
|
@ -1363,16 +1363,16 @@ error:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void crypto_context_init(struct mp_crypto_context *c, struct mediaproxy_srtp *s) {
|
|
|
|
|
c->cipher = &mp_ciphers[s->cipher];
|
|
|
|
|
c->hmac = &mp_hmacs[s->hmac];
|
|
|
|
|
static void crypto_context_init(struct re_crypto_context *c, struct rtpengine_srtp *s) {
|
|
|
|
|
c->cipher = &re_ciphers[s->cipher];
|
|
|
|
|
c->hmac = &re_hmacs[s->hmac];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int table_new_target(struct mediaproxy_table *t, struct mediaproxy_target_info *i, int update) {
|
|
|
|
|
static int table_new_target(struct rtpengine_table *t, struct rtpengine_target_info *i, int update) {
|
|
|
|
|
unsigned char hi, lo;
|
|
|
|
|
struct mediaproxy_target *g;
|
|
|
|
|
struct mp_bucket *b, *ba = NULL;
|
|
|
|
|
struct mediaproxy_target *og = NULL;
|
|
|
|
|
struct rtpengine_target *g;
|
|
|
|
|
struct re_bucket *b, *ba = NULL;
|
|
|
|
|
struct rtpengine_target *og = NULL;
|
|
|
|
|
int err;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
@ -1489,9 +1489,9 @@ fail1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct mediaproxy_target *get_target(struct mediaproxy_table *t, u_int16_t port) {
|
|
|
|
|
static struct rtpengine_target *get_target(struct rtpengine_table *t, u_int16_t port) {
|
|
|
|
|
unsigned char hi, lo;
|
|
|
|
|
struct mediaproxy_target *r;
|
|
|
|
|
struct rtpengine_target *r;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
if (!t)
|
|
|
|
@ -1530,7 +1530,7 @@ static ssize_t proc_main_control_write(struct file *file, const char __user *buf
|
|
|
|
|
char b[30];
|
|
|
|
|
unsigned long id;
|
|
|
|
|
char *endp;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
if (buflen < 6 || buflen > 20)
|
|
|
|
@ -1578,7 +1578,7 @@ static ssize_t proc_main_control_write(struct file *file, const char __user *buf
|
|
|
|
|
|
|
|
|
|
static int proc_control_open(struct inode *inode, struct file *file) {
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
id = (u_int32_t) (unsigned long) PDE_DATA(inode);
|
|
|
|
@ -1601,7 +1601,7 @@ static int proc_control_open(struct inode *inode, struct file *file) {
|
|
|
|
|
|
|
|
|
|
static int proc_control_close(struct inode *inode, struct file *file) {
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
id = (u_int32_t) (unsigned long) PDE_DATA(inode);
|
|
|
|
@ -1621,8 +1621,8 @@ static int proc_control_close(struct inode *inode, struct file *file) {
|
|
|
|
|
static ssize_t proc_control_write(struct file *file, const char __user *buf, size_t buflen, loff_t *off) {
|
|
|
|
|
struct inode *inode;
|
|
|
|
|
u_int32_t id;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct mediaproxy_message msg;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
struct rtpengine_message msg;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
if (buflen != sizeof(msg))
|
|
|
|
@ -1662,7 +1662,7 @@ static ssize_t proc_control_write(struct file *file, const char __user *buf, siz
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
printk(KERN_WARNING "xt_MEDIAPROXY unimplemented op %u\n", msg.cmd);
|
|
|
|
|
printk(KERN_WARNING "xt_RTPENGINE unimplemented op %u\n", msg.cmd);
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
@ -1680,7 +1680,7 @@ err:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int send_proxy_packet4(struct sk_buff *skb, struct mp_address *src, struct mp_address *dst, unsigned char tos) {
|
|
|
|
|
static int send_proxy_packet4(struct sk_buff *skb, struct re_address *src, struct re_address *dst, unsigned char tos) {
|
|
|
|
|
struct iphdr *ih;
|
|
|
|
|
struct udphdr *uh;
|
|
|
|
|
unsigned int datalen;
|
|
|
|
@ -1736,7 +1736,7 @@ drop:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int send_proxy_packet6(struct sk_buff *skb, struct mp_address *src, struct mp_address *dst, unsigned char tos) {
|
|
|
|
|
static int send_proxy_packet6(struct sk_buff *skb, struct re_address *src, struct re_address *dst, unsigned char tos) {
|
|
|
|
|
struct ipv6hdr *ih;
|
|
|
|
|
struct udphdr *uh;
|
|
|
|
|
unsigned int datalen;
|
|
|
|
@ -1791,7 +1791,7 @@ drop:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int send_proxy_packet(struct sk_buff *skb, struct mp_address *src, struct mp_address *dst, unsigned char tos) {
|
|
|
|
|
static int send_proxy_packet(struct sk_buff *skb, struct re_address *src, struct re_address *dst, unsigned char tos) {
|
|
|
|
|
if (src->family != dst->family)
|
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
|
@ -1859,8 +1859,8 @@ error:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XXX shared code */
|
|
|
|
|
static u_int64_t packet_index(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_header *rtp)
|
|
|
|
|
static u_int64_t packet_index(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_header *rtp)
|
|
|
|
|
{
|
|
|
|
|
u_int16_t seq;
|
|
|
|
|
u_int64_t index;
|
|
|
|
@ -1900,8 +1900,8 @@ static u_int64_t packet_index(struct mp_crypto_context *c,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int srtp_hash(unsigned char *hmac,
|
|
|
|
|
struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
u_int32_t roc;
|
|
|
|
@ -1944,7 +1944,7 @@ error:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XXX shared code */
|
|
|
|
|
static void rtp_append_mki(struct rtp_parsed *r, struct mediaproxy_srtp *c) {
|
|
|
|
|
static void rtp_append_mki(struct rtp_parsed *r, struct rtpengine_srtp *c) {
|
|
|
|
|
unsigned char *p;
|
|
|
|
|
|
|
|
|
|
if (!c->mki_len)
|
|
|
|
@ -1955,15 +1955,15 @@ static void rtp_append_mki(struct rtp_parsed *r, struct mediaproxy_srtp *c) {
|
|
|
|
|
r->payload_len += c->mki_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int srtp_authenticate(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
static int srtp_authenticate(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
unsigned char hmac[20];
|
|
|
|
|
|
|
|
|
|
if (!r->header)
|
|
|
|
|
return 0;
|
|
|
|
|
if (s->hmac == MPH_NULL)
|
|
|
|
|
if (s->hmac == REH_NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!c->hmac)
|
|
|
|
|
return 0;
|
|
|
|
@ -1981,14 +1981,14 @@ static int srtp_authenticate(struct mp_crypto_context *c,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int srtp_auth_validate(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
static int srtp_auth_validate(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
unsigned char *auth_tag;
|
|
|
|
|
unsigned char hmac[20];
|
|
|
|
|
|
|
|
|
|
if (s->hmac == MPH_NULL)
|
|
|
|
|
if (s->hmac == REH_NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!c->hmac)
|
|
|
|
|
return 0;
|
|
|
|
@ -2025,8 +2025,8 @@ static int srtp_auth_validate(struct mp_crypto_context *c,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX shared code */
|
|
|
|
|
static int srtp_encrypt_aes_cm(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
static int srtp_encrypt_aes_cm(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
unsigned char iv[16];
|
|
|
|
@ -2049,8 +2049,8 @@ static int srtp_encrypt_aes_cm(struct mp_crypto_context *c,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int srtp_encrypt_aes_f8(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
static int srtp_encrypt_aes_f8(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
unsigned char iv[16];
|
|
|
|
@ -2067,8 +2067,8 @@ static int srtp_encrypt_aes_f8(struct mp_crypto_context *c,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline int srtp_encrypt(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
static inline int srtp_encrypt(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
if (!r->header)
|
|
|
|
@ -2078,8 +2078,8 @@ static inline int srtp_encrypt(struct mp_crypto_context *c,
|
|
|
|
|
return c->cipher->encrypt(c, s, r, pkt_idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int srtp_decrypt(struct mp_crypto_context *c,
|
|
|
|
|
struct mediaproxy_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
static inline int srtp_decrypt(struct re_crypto_context *c,
|
|
|
|
|
struct rtpengine_srtp *s, struct rtp_parsed *r,
|
|
|
|
|
u_int64_t pkt_idx)
|
|
|
|
|
{
|
|
|
|
|
if (!c->cipher->decrypt)
|
|
|
|
@ -2105,9 +2105,9 @@ static inline int is_dtls(struct sk_buff *skb) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned int mediaproxy46(struct sk_buff *skb, struct mediaproxy_table *t, struct mp_address *src) {
|
|
|
|
|
static unsigned int rtpengine46(struct sk_buff *skb, struct rtpengine_table *t, struct re_address *src) {
|
|
|
|
|
struct udphdr *uh;
|
|
|
|
|
struct mediaproxy_target *g;
|
|
|
|
|
struct rtpengine_target *g;
|
|
|
|
|
struct sk_buff *skb2;
|
|
|
|
|
int err;
|
|
|
|
|
unsigned int datalen;
|
|
|
|
@ -2245,15 +2245,15 @@ skip2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
|
|
|
|
static unsigned int mediaproxy4(struct sk_buff *oskb, const struct xt_target_param *par) {
|
|
|
|
|
static unsigned int rtpengine4(struct sk_buff *oskb, const struct xt_target_param *par) {
|
|
|
|
|
#else
|
|
|
|
|
static unsigned int mediaproxy4(struct sk_buff *oskb, const struct xt_action_param *par) {
|
|
|
|
|
static unsigned int rtpengine4(struct sk_buff *oskb, const struct xt_action_param *par) {
|
|
|
|
|
#endif
|
|
|
|
|
const struct xt_mediaproxy_info *pinfo = par->targinfo;
|
|
|
|
|
const struct xt_rtpengine_info *pinfo = par->targinfo;
|
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
struct iphdr *ih;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct mp_address src;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
struct re_address src;
|
|
|
|
|
|
|
|
|
|
t = get_table(pinfo->id);
|
|
|
|
|
if (!t)
|
|
|
|
@ -2273,7 +2273,7 @@ static unsigned int mediaproxy4(struct sk_buff *oskb, const struct xt_action_par
|
|
|
|
|
src.family = AF_INET;
|
|
|
|
|
src.u.ipv4 = ih->saddr;
|
|
|
|
|
|
|
|
|
|
return mediaproxy46(skb, t, &src);
|
|
|
|
|
return rtpengine46(skb, t, &src);
|
|
|
|
|
|
|
|
|
|
skip2:
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
@ -2287,15 +2287,15 @@ skip:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
|
|
|
|
static unsigned int mediaproxy6(struct sk_buff *oskb, const struct xt_target_param *par) {
|
|
|
|
|
static unsigned int rtpengine6(struct sk_buff *oskb, const struct xt_target_param *par) {
|
|
|
|
|
#else
|
|
|
|
|
static unsigned int mediaproxy6(struct sk_buff *oskb, const struct xt_action_param *par) {
|
|
|
|
|
static unsigned int rtpengine6(struct sk_buff *oskb, const struct xt_action_param *par) {
|
|
|
|
|
#endif
|
|
|
|
|
const struct xt_mediaproxy_info *pinfo = par->targinfo;
|
|
|
|
|
const struct xt_rtpengine_info *pinfo = par->targinfo;
|
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
struct ipv6hdr *ih;
|
|
|
|
|
struct mediaproxy_table *t;
|
|
|
|
|
struct mp_address src;
|
|
|
|
|
struct rtpengine_table *t;
|
|
|
|
|
struct re_address src;
|
|
|
|
|
|
|
|
|
|
t = get_table(pinfo->id);
|
|
|
|
|
if (!t)
|
|
|
|
@ -2315,7 +2315,7 @@ static unsigned int mediaproxy6(struct sk_buff *oskb, const struct xt_action_par
|
|
|
|
|
src.family = AF_INET6;
|
|
|
|
|
memcpy(&src.u.ipv6, &ih->saddr, sizeof(src.u.ipv6));
|
|
|
|
|
|
|
|
|
|
return mediaproxy46(skb, t, &src);
|
|
|
|
|
return rtpengine46(skb, t, &src);
|
|
|
|
|
|
|
|
|
|
skip2:
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
@ -2338,14 +2338,14 @@ static bool check(const struct xt_tgchk_param *par) {
|
|
|
|
|
#define CHECK_SCC 0
|
|
|
|
|
static int check(const struct xt_tgchk_param *par) {
|
|
|
|
|
#endif
|
|
|
|
|
const struct xt_mediaproxy_info *pinfo = par->targinfo;
|
|
|
|
|
const struct xt_rtpengine_info *pinfo = par->targinfo;
|
|
|
|
|
|
|
|
|
|
if (!my_proc_root) {
|
|
|
|
|
printk(KERN_WARNING "xt_MEDIAPROXY check() without proc_root\n");
|
|
|
|
|
printk(KERN_WARNING "xt_RTPENGINE check() without proc_root\n");
|
|
|
|
|
return CHECK_ERR;
|
|
|
|
|
}
|
|
|
|
|
if (pinfo->id >= MAX_ID) {
|
|
|
|
|
printk(KERN_WARNING "xt_MEDIAPROXY ID too high (%u >= %u)\n", pinfo->id, MAX_ID);
|
|
|
|
|
printk(KERN_WARNING "xt_RTPENGINE ID too high (%u >= %u)\n", pinfo->id, MAX_ID);
|
|
|
|
|
return CHECK_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2355,22 +2355,22 @@ static int check(const struct xt_tgchk_param *par) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct xt_target xt_mediaproxy_regs[] = {
|
|
|
|
|
static struct xt_target xt_rtpengine_regs[] = {
|
|
|
|
|
{
|
|
|
|
|
.name = "MEDIAPROXY",
|
|
|
|
|
.name = "RTPENGINE",
|
|
|
|
|
.family = NFPROTO_IPV4,
|
|
|
|
|
.target = mediaproxy4,
|
|
|
|
|
.targetsize = sizeof(struct xt_mediaproxy_info),
|
|
|
|
|
.target = rtpengine4,
|
|
|
|
|
.targetsize = sizeof(struct xt_rtpengine_info),
|
|
|
|
|
.table = "filter",
|
|
|
|
|
.hooks = (1 << NF_INET_LOCAL_IN),
|
|
|
|
|
.checkentry = check,
|
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.name = "MEDIAPROXY",
|
|
|
|
|
.name = "RTPENGINE",
|
|
|
|
|
.family = NFPROTO_IPV6,
|
|
|
|
|
.target = mediaproxy6,
|
|
|
|
|
.targetsize = sizeof(struct xt_mediaproxy_info),
|
|
|
|
|
.target = rtpengine6,
|
|
|
|
|
.targetsize = sizeof(struct xt_rtpengine_info),
|
|
|
|
|
.table = "filter",
|
|
|
|
|
.hooks = (1 << NF_INET_LOCAL_IN),
|
|
|
|
|
.checkentry = check,
|
|
|
|
@ -2382,13 +2382,13 @@ static int __init init(void) {
|
|
|
|
|
int ret;
|
|
|
|
|
const char *err;
|
|
|
|
|
|
|
|
|
|
printk(KERN_NOTICE "Registering xt_MEDIAPROXY module - version %s\n", MEDIAPROXY_VERSION);
|
|
|
|
|
printk(KERN_NOTICE "Registering xt_RTPENGINE module - version %s\n", RTPENGINE_VERSION);
|
|
|
|
|
|
|
|
|
|
rwlock_init(&table_lock);
|
|
|
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
|
err = "could not register /proc/ entries";
|
|
|
|
|
my_proc_root = proc_mkdir("mediaproxy", NULL);
|
|
|
|
|
my_proc_root = proc_mkdir("rtpengine", NULL);
|
|
|
|
|
if (!my_proc_root)
|
|
|
|
|
goto fail;
|
|
|
|
|
/* my_proc_root->owner = THIS_MODULE; */
|
|
|
|
@ -2403,7 +2403,7 @@ static int __init init(void) {
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
err = "could not register xtables target";
|
|
|
|
|
ret = xt_register_targets(xt_mediaproxy_regs, ARRAY_SIZE(xt_mediaproxy_regs));
|
|
|
|
|
ret = xt_register_targets(xt_rtpengine_regs, ARRAY_SIZE(xt_rtpengine_regs));
|
|
|
|
|
if (ret)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
@ -2414,14 +2414,14 @@ fail:
|
|
|
|
|
clear_proc(&proc_list);
|
|
|
|
|
clear_proc(&my_proc_root);
|
|
|
|
|
|
|
|
|
|
printk(KERN_ERR "Failed to load xt_MEDIAPROXY module: %s\n", err);
|
|
|
|
|
printk(KERN_ERR "Failed to load xt_RTPENGINE module: %s\n", err);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void __exit fini(void) {
|
|
|
|
|
printk(KERN_NOTICE "Unregistering xt_MEDIAPROXY module\n");
|
|
|
|
|
xt_unregister_targets(xt_mediaproxy_regs, ARRAY_SIZE(xt_mediaproxy_regs));
|
|
|
|
|
printk(KERN_NOTICE "Unregistering xt_RTPENGINE module\n");
|
|
|
|
|
xt_unregister_targets(xt_rtpengine_regs, ARRAY_SIZE(xt_rtpengine_regs));
|
|
|
|
|
|
|
|
|
|
clear_proc(&proc_control);
|
|
|
|
|
clear_proc(&proc_list);
|