|
|
|
@ -1723,24 +1723,6 @@ static struct re_dest_addr *find_dest_addr(const struct re_dest_addr_hash *h, co |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// retrieve and return the current stats for a target |
|
|
|
static int table_get_target_stats(struct rtpengine_table *t, const struct re_address *local, |
|
|
|
struct rtpengine_stats_info *i) |
|
|
|
{ |
|
|
|
struct rtpengine_target *g; |
|
|
|
|
|
|
|
g = get_target(t, local); |
|
|
|
if (!g) |
|
|
|
return -ENOENT; |
|
|
|
|
|
|
|
target_put(g); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// removes a target from the table and returns it |
|
|
|
static struct rtpengine_target *table_steal_target(struct rtpengine_table *t, const struct re_address *local) { |
|
|
|
unsigned char hi, lo; |
|
|
|
@ -1793,9 +1775,7 @@ out: |
|
|
|
|
|
|
|
|
|
|
|
// removes target from table and returns the stats before releasing the target |
|
|
|
static int table_del_target_stats(struct rtpengine_table *t, const struct re_address *local, |
|
|
|
struct rtpengine_stats_info *i, int reset) |
|
|
|
{ |
|
|
|
static int table_del_target(struct rtpengine_table *t, const struct re_address *local) { |
|
|
|
struct rtpengine_target *g = table_steal_target(t, local); |
|
|
|
|
|
|
|
if (IS_ERR(g)) |
|
|
|
@ -3667,35 +3647,28 @@ out: |
|
|
|
static const size_t min_req_sizes[__REMG_LAST] = { |
|
|
|
[REMG_INIT] = sizeof(struct rtpengine_command_init), |
|
|
|
[REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), |
|
|
|
[REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats), |
|
|
|
[REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target), |
|
|
|
[REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination), |
|
|
|
[REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), |
|
|
|
[REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), |
|
|
|
[REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), |
|
|
|
[REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), |
|
|
|
[REMG_PACKET] = sizeof(struct rtpengine_command_packet), |
|
|
|
[REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats), |
|
|
|
[REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet), |
|
|
|
|
|
|
|
}; |
|
|
|
static const size_t max_req_sizes[__REMG_LAST] = { |
|
|
|
[REMG_INIT] = sizeof(struct rtpengine_command_init), |
|
|
|
[REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), |
|
|
|
[REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats), |
|
|
|
[REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target), |
|
|
|
[REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination), |
|
|
|
[REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), |
|
|
|
[REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), |
|
|
|
[REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), |
|
|
|
[REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), |
|
|
|
[REMG_PACKET] = sizeof(struct rtpengine_command_packet) + 65535, |
|
|
|
[REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats), |
|
|
|
[REMG_SEND_RTCP] = sizeof(struct rtpengine_command_send_packet) + 65535, |
|
|
|
}; |
|
|
|
static const size_t input_req_sizes[__REMG_LAST] = { |
|
|
|
[REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats) - sizeof(struct rtpengine_stats_info), |
|
|
|
[REMG_DEL_TARGET_STATS] = sizeof(struct rtpengine_command_del_target_stats) |
|
|
|
- sizeof(struct rtpengine_stats_info), |
|
|
|
}; |
|
|
|
|
|
|
|
static int rtpengine_init_table(struct rtpengine_table *t, struct rtpengine_init_info *init) { |
|
|
|
int i; |
|
|
|
@ -3722,20 +3695,17 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub |
|
|
|
int err; |
|
|
|
enum rtpengine_command cmd; |
|
|
|
char scratchbuf[512]; |
|
|
|
size_t readlen, writelen, writeoffset; |
|
|
|
|
|
|
|
union { |
|
|
|
struct rtpengine_command_init *init; |
|
|
|
struct rtpengine_command_add_target *add_target; |
|
|
|
struct rtpengine_command_del_target *del_target; |
|
|
|
struct rtpengine_command_del_target_stats *del_target_stats; |
|
|
|
struct rtpengine_command_destination *destination; |
|
|
|
struct rtpengine_command_add_call *add_call; |
|
|
|
struct rtpengine_command_del_call *del_call; |
|
|
|
struct rtpengine_command_add_stream *add_stream; |
|
|
|
struct rtpengine_command_del_stream *del_stream; |
|
|
|
struct rtpengine_command_packet *packet; |
|
|
|
struct rtpengine_command_stats *stats; |
|
|
|
struct rtpengine_command_send_packet *send_packet; |
|
|
|
|
|
|
|
char *storage; |
|
|
|
@ -3779,18 +3749,8 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub |
|
|
|
goto err_free; |
|
|
|
|
|
|
|
// copy in the entire request |
|
|
|
readlen = input_req_sizes[cmd]; |
|
|
|
if (!readlen) { |
|
|
|
readlen = buflen; |
|
|
|
writelen = buflen; |
|
|
|
writeoffset = 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
writelen = buflen - readlen; |
|
|
|
writeoffset = readlen; |
|
|
|
} |
|
|
|
err = -EFAULT; |
|
|
|
if (copy_from_user(msg.storage, ubuf, readlen)) |
|
|
|
if (copy_from_user(msg.storage, ubuf, buflen)) |
|
|
|
goto err_table_free; |
|
|
|
|
|
|
|
// execute command |
|
|
|
@ -3805,23 +3765,14 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub |
|
|
|
err = table_new_target(t, &msg.add_target->target); |
|
|
|
break; |
|
|
|
|
|
|
|
case REMG_DEL_TARGET_STATS: |
|
|
|
err = -EINVAL; |
|
|
|
if (writeable) |
|
|
|
err = table_del_target_stats(t, &msg.del_target_stats->local, |
|
|
|
&msg.del_target_stats->stats, 0); |
|
|
|
case REMG_DEL_TARGET: |
|
|
|
err = table_del_target(t, &msg.del_target->local); |
|
|
|
break; |
|
|
|
|
|
|
|
case REMG_ADD_DESTINATION: |
|
|
|
err = table_add_destination(t, &msg.destination->destination); |
|
|
|
break; |
|
|
|
|
|
|
|
case REMG_GET_RESET_STATS: |
|
|
|
err = -EINVAL; |
|
|
|
if (writeable) |
|
|
|
err = table_get_target_stats(t, &msg.stats->local, &msg.stats->stats); |
|
|
|
break; |
|
|
|
|
|
|
|
case REMG_ADD_CALL: |
|
|
|
err = -EINVAL; |
|
|
|
if (writeable) |
|
|
|
@ -3863,7 +3814,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub |
|
|
|
|
|
|
|
if (writeable) { |
|
|
|
err = -EFAULT; |
|
|
|
if (copy_to_user(ubuf + writeoffset, msg.storage + writeoffset, writelen)) |
|
|
|
if (copy_to_user(ubuf, msg.storage, buflen)) |
|
|
|
goto err_free; |
|
|
|
} |
|
|
|
|
|
|
|
|