{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *event = NULL;
- char key[1024] = "";
-
+
switch (nat_globals.nat_type) {
case SWITCH_NAT_TYPE_PMP:
status = switch_nat_add_mapping_pmp(port, proto, external_port);
break;
case SWITCH_NAT_TYPE_UPNP:
- if ((status = switch_nat_add_mapping_upnp(port, proto)) && status == SWITCH_STATUS_SUCCESS) {
+ if ((status = switch_nat_add_mapping_upnp(port, proto)) == SWITCH_STATUS_SUCCESS) {
if (external_port) {
*external_port = port;
- }
+ }
}
break;
default:
if (publish && status == SWITCH_STATUS_SUCCESS) {
switch_event_create(&event, SWITCH_EVENT_NAT);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "op", "add");
- switch_snprintf(key, sizeof(key), "%d", port);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "port", key);
- switch_snprintf(key, sizeof(key), "%d", proto);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", key);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "port", "%d", port);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%d", proto);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sticky", (sticky ? "true" : "false"));
switch_event_fire(&event);
}
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *event = NULL;
- char key[1024] = "";
switch (nat_globals.nat_type) {
case SWITCH_NAT_TYPE_PMP:
if (status == SWITCH_STATUS_SUCCESS) {
switch_event_create(&event, SWITCH_EVENT_NAT);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "op", "del");
- switch_snprintf(key, sizeof(key), "%d", port);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "port", key);
- switch_snprintf(key, sizeof(key), "%d", proto);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", key);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "port", "%d", port);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%d", proto);
switch_event_fire(&event);
}