From bdecacc99eaa29d16516a0776c7482e985657654 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 22 Jan 2023 18:28:34 +0100 Subject: [PATCH] Changed logging of libosmocc to osmocom style --- src/libosmocc/endpoint.c | 102 +++++++++++++++++------------------ src/libosmocc/helper.c | 14 ++--- src/libosmocc/message.c | 62 ++++++++++----------- src/libosmocc/rtp.c | 42 +++++++-------- src/libosmocc/screen.c | 94 ++++++++++++++++---------------- src/libosmocc/sdp.c | 58 ++++++++++---------- src/libosmocc/session.c | 114 +++++++++++++++++++-------------------- src/libosmocc/socket.c | 40 +++++++------- 8 files changed, 263 insertions(+), 263 deletions(-) diff --git a/src/libosmocc/endpoint.c b/src/libosmocc/endpoint.c index 7d9c57f..e78b3ed 100644 --- a/src/libosmocc/endpoint.c +++ b/src/libosmocc/endpoint.c @@ -36,11 +36,11 @@ static osmo_cc_call_t *call_new(osmo_cc_endpoint_t *ep, uint32_t callref) call = calloc(1, sizeof(*call)); if (!call) { - PDEBUG(DCC, DEBUG_ERROR, "No memory for call process instance.\n"); + LOGP(DCC, LOGL_ERROR, "No memory for call process instance.\n"); abort(); } - PDEBUG(DCC, DEBUG_DEBUG, "Creating new call with callref %u.\n", callref); + LOGP(DCC, LOGL_DEBUG, "Creating new call with callref %u.\n", callref); call->ep = ep; call->callref = callref; @@ -59,7 +59,7 @@ static void call_delete(osmo_cc_call_t *call) { osmo_cc_call_t **cp; - PDEBUG(DCC, DEBUG_DEBUG, "Destroying call with callref %u.\n", call->callref); + LOGP(DCC, LOGL_DEBUG, "Destroying call with callref %u.\n", call->callref); /* detach from call process list */ cp = &call->ep->call_list; @@ -105,7 +105,7 @@ static const char *state_names[] = { static void new_call_state(osmo_cc_call_t *call, enum osmo_cc_state new_state) { - PDEBUG(DCC, DEBUG_DEBUG, "Changing call state with callref %u from %s to %s.\n", call->callref, state_names[call->state], state_names[new_state]); + LOGP(DCC, LOGL_DEBUG, "Changing call state with callref %u from %s to %s.\n", call->callref, state_names[call->state], state_names[new_state]); call->state = new_state; } @@ -160,12 +160,12 @@ static int split_address(const char *address, const char **host_p, uint16_t *por *host_p = osmo_cc_host_of_address(address); if (!(*host_p)) { - PDEBUG(DCC, DEBUG_ERROR, "Host IP in given address '%s' is invalid.\n", address); + LOGP(DCC, LOGL_ERROR, "Host IP in given address '%s' is invalid.\n", address); return -EINVAL; } portstring = osmo_cc_port_of_address(address); if (!portstring) { - PDEBUG(DCC, DEBUG_ERROR, "Port number in given address '%s' is not specified or invalid.\n", address); + LOGP(DCC, LOGL_ERROR, "Port number in given address '%s' is not specified or invalid.\n", address); return -EINVAL; } *port_p = atoi(portstring); @@ -220,7 +220,7 @@ static void forward_to_ul(osmo_cc_call_t *call, osmo_cc_msg_t *msg) if (address && msg->type == OSMO_CC_MSG_SETUP_IND) { rc = split_address(address, &host, &port); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "Given remote peer's address '%s' in setup message is invalid, rejecting call.\n", address); + LOGP(DCC, LOGL_ERROR, "Given remote peer's address '%s' in setup message is invalid, rejecting call.\n", address); reject: /* reject, due to error */ osmo_cc_free_msg(msg); @@ -229,21 +229,21 @@ reject: call_delete(call); return; } - PDEBUG(DCC, DEBUG_DEBUG, "Using host IP '%s' and port '%d' from setup message.\n", host, port); + LOGP(DCC, LOGL_DEBUG, "Using host IP '%s' and port '%d' from setup message.\n", host, port); } /* for attach message, use remote peer */ if (msg->type == OSMO_CC_MSG_ATTACH_IND) { host = call->ep->remote_host; port = call->ep->remote_port; - PDEBUG(DCC, DEBUG_DEBUG, "Using host IP '%s' and port '%d' from remote address for attach message.\n", host, port); + LOGP(DCC, LOGL_DEBUG, "Using host IP '%s' and port '%d' from remote address for attach message.\n", host, port); } /* if there is no remote peer in the setup message, use remote peer */ if (!address && msg->type == OSMO_CC_MSG_SETUP_IND && call->ep->remote_host) { host = call->ep->remote_host; port = call->ep->remote_port; - PDEBUG(DCC, DEBUG_DEBUG, "Using host IP '%s' and port '%d' from remote address for setup message.\n", host, port); + LOGP(DCC, LOGL_DEBUG, "Using host IP '%s' and port '%d' from remote address for setup message.\n", host, port); } /* if there is no remote peer set, try to use the interface name */ @@ -257,16 +257,16 @@ reject: /* check for incoming attachment */ att = osmo_cc_get_attached_interface(call->ep, interface); if (!att && !interface[0]) { - PDEBUG(DCC, DEBUG_ERROR, "No remote peer attached, rejecting call.\n"); + LOGP(DCC, LOGL_ERROR, "No remote peer attached, rejecting call.\n"); goto reject; } if (!att) { - PDEBUG(DCC, DEBUG_ERROR, "No remote peer attached for given interface '%s', rejecting call.\n", interface); + LOGP(DCC, LOGL_ERROR, "No remote peer attached for given interface '%s', rejecting call.\n", interface); goto reject; } host = att->attached_host; port = att->attached_port; - PDEBUG(DCC, DEBUG_DEBUG, "Using host IP '%s' and port '%d' from attached peer for setup message.\n", host, port); + LOGP(DCC, LOGL_DEBUG, "Using host IP '%s' and port '%d' from attached peer for setup message.\n", host, port); } /* add local interface name to setup message */ @@ -285,7 +285,7 @@ void send_attach_ind(void *data) osmo_cc_call_t *call; osmo_cc_msg_t *msg; - PDEBUG(DCC, DEBUG_DEBUG, "Trying to attach to remote peer \"%s\".\n", ep->remote_host); + LOGP(DCC, LOGL_DEBUG, "Trying to attach to remote peer \"%s\".\n", ep->remote_host); /* create new call for attachment */ call = osmo_cc_call_new(ep); @@ -306,7 +306,7 @@ void send_attach_ind(void *data) void attach_rsp(osmo_cc_call_t *call, osmo_cc_msg_t *msg) { - PDEBUG(DCC, DEBUG_INFO, "Attached to remote peer \"%s\".\n", call->ep->remote_address); + LOGP(DCC, LOGL_INFO, "Attached to remote peer \"%s\".\n", call->ep->remote_address); /* set state */ new_call_state(call, OSMO_CC_STATE_ATTACH_OUT); @@ -321,11 +321,11 @@ void attach_rel(osmo_cc_call_t *call, osmo_cc_msg_t *msg) if (call->state == OSMO_CC_STATE_ATTACH_SENT || call->state == OSMO_CC_STATE_ATTACH_OUT) { timer_start(&call->ep->attach_timer, OSMO_CC_ATTACH_TIMER); - PDEBUG(DCC, DEBUG_INFO, "Attachment to remote peer \"%s\" failed, retrying.\n", call->ep->remote_address); + LOGP(DCC, LOGL_INFO, "Attachment to remote peer \"%s\" failed, retrying.\n", call->ep->remote_address); } if (call->attached_name) - PDEBUG(DCC, DEBUG_INFO, "Peer with remote interface \"%s\" detached from us.\n", call->attached_name); + LOGP(DCC, LOGL_INFO, "Peer with remote interface \"%s\" detached from us.\n", call->attached_name); /* change state */ new_call_state(call, OSMO_CC_STATE_IDLE); @@ -356,12 +356,12 @@ void attach_req(osmo_cc_call_t *call, osmo_cc_msg_t *msg) if (rc < 0) address[0] = '\0'; if (!address[0]) { - PDEBUG(DCC, DEBUG_ERROR, "Attachment request from remote peer has no remote address set, rejecting.\n"); + LOGP(DCC, LOGL_ERROR, "Attachment request from remote peer has no remote address set, rejecting.\n"); rel: /* change to REL_REQ */ msg->type = OSMO_CC_MSG_REL_IND; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); /* message to socket */ forward_to_ul(call, msg); @@ -373,7 +373,7 @@ rel: } rc = split_address(address, &host, &port); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "Given remote peer's address '%s' in attach message is invalid, rejecting call.\n", address); + LOGP(DCC, LOGL_ERROR, "Given remote peer's address '%s' in attach message is invalid, rejecting call.\n", address); goto rel; } free((char *)call->attached_host); @@ -388,11 +388,11 @@ rel: call->attached_name = strdup(interface); } - PDEBUG(DCC, DEBUG_INFO, "Remote peer with socket address '%s' and port '%d' and interface '%s' attached to us.\n", call->attached_host, call->attached_port, call->attached_name); + LOGP(DCC, LOGL_INFO, "Remote peer with socket address '%s' and port '%d' and interface '%s' attached to us.\n", call->attached_host, call->attached_port, call->attached_name); /* changing to confirm message */ msg->type = OSMO_CC_MSG_ATTACH_CNF; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); /* message to socket */ forward_to_ul(call, msg); @@ -667,7 +667,7 @@ static void disc_collision_ind(osmo_cc_call_t *call, osmo_cc_msg_t *msg) /* change to REL_REQ */ msg->type = OSMO_CC_MSG_REL_REQ; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); /* to lower layer */ forward_to_ll(call, msg); @@ -688,7 +688,7 @@ static void disc_collision_req(osmo_cc_call_t *call, osmo_cc_msg_t *msg) if (call->lower_layer_released) { /* change to REL_REQ */ msg->type = OSMO_CC_MSG_REL_IND; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); /* to upper layer */ forward_to_ul(call, msg); @@ -726,7 +726,7 @@ static void rej_ind_disc(osmo_cc_call_t *call, osmo_cc_msg_t *msg) /* change to REL_IND */ msg->type = OSMO_CC_MSG_REL_IND; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); /* to upper layer */ forward_to_ul(call, msg); @@ -742,7 +742,7 @@ static void rej_req_disc(osmo_cc_call_t *call, osmo_cc_msg_t *msg) /* change to REL_REQ */ msg->type = OSMO_CC_MSG_REL_REQ; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); /* to lower layer */ forward_to_ll(call, msg); @@ -771,7 +771,7 @@ static void rel_ind_other(osmo_cc_call_t *call, osmo_cc_msg_t *msg) /* change to DISC_IND */ msg->type = OSMO_CC_MSG_DISC_IND; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); call->lower_layer_released = 1; /* to upper layer */ @@ -798,7 +798,7 @@ static void rel_req_other(osmo_cc_call_t *call, osmo_cc_msg_t *msg) /* change to DISC_REQ */ msg->type = OSMO_CC_MSG_DISC_REQ; - PDEBUG(DCC, DEBUG_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); + LOGP(DCC, LOGL_INFO, "Changing message to %s.\n", osmo_cc_msg_value2name(msg->type)); call->upper_layer_released = 1; /* to lower layer */ @@ -955,16 +955,16 @@ static void handle_msg(osmo_cc_call_t *call, osmo_cc_msg_t *msg) && ((1 << call->state) & statemachine_list[i].states)) break; if (i == STATEMACHINE_LEN) { - PDEBUG(DCC, DEBUG_INFO, "Message %s unhandled at state %s (callref %d)\n", + LOGP(DCC, LOGL_INFO, "Message %s unhandled at state %s (callref %d)\n", osmo_cc_msg_value2name(msg->type), state_names[call->state], call->callref); osmo_cc_free_msg(msg); return; } - PDEBUG(DCC, DEBUG_INFO, "Handle message %s at state %s (callref %d)\n", + LOGP(DCC, LOGL_INFO, "Handle message %s at state %s (callref %d)\n", osmo_cc_msg_value2name(msg->type), state_names[call->state], call->callref); - if (debuglevel <= DEBUG_INFO) - osmo_cc_debug_ie(msg, DEBUG_INFO); + if (debuglevel <= LOGL_INFO) + osmo_cc_debug_ie(msg, LOGL_INFO); statemachine_list[i].action(call, msg); } @@ -1041,7 +1041,7 @@ void osmo_cc_ll_msg(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg osmo_cc_call_t *call; if (!(msg->type & 1)) { - PDEBUG(DCC, DEBUG_ERROR, "Received message from lower layer that is not an _IND nor _CNF, please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Received message from lower layer that is not an _IND nor _CNF, please fix!\n"); osmo_cc_free_msg(msg); return; } @@ -1064,7 +1064,7 @@ void osmo_cc_ul_msg(void *priv, uint32_t callref, osmo_cc_msg_t *msg) osmo_cc_call_t *call; if ((msg->type & 1)) { - PDEBUG(DCC, DEBUG_ERROR, "Received message from socket that is not an _REQ nor _RSP, please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Received message from socket that is not an _REQ nor _RSP, please fix!\n"); osmo_cc_free_msg(msg); return; } @@ -1125,7 +1125,7 @@ static int osmo_cc_set_name(osmo_cc_endpoint_t *ep, const char *text) text++; } } else { - PDEBUG(DCC, DEBUG_ERROR, "Invalid name definition '%s'\n", text); + LOGP(DCC, LOGL_ERROR, "Invalid name definition '%s'\n", text); return -EINVAL; } @@ -1188,12 +1188,12 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text) text++; } if (!strcasecmp(text, "auto")) { - PDEBUG(DCC, DEBUG_DEBUG, "setting automatic remote peer selection\n"); + LOGP(DCC, LOGL_DEBUG, "setting automatic remote peer selection\n"); ep->remote_auto = 1; return 0; } if (!strcasecmp(text, "none")) { - PDEBUG(DCC, DEBUG_DEBUG, "disable automatic remote peer selection\n"); + LOGP(DCC, LOGL_DEBUG, "disable automatic remote peer selection\n"); ep->remote_auto = 0; return 0; } @@ -1202,7 +1202,7 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text) host_p = &ep->remote_host; port_p = &ep->remote_port; } else { - PDEBUG(DCC, DEBUG_ERROR, "Invalid local or remote address definition '%s'\n", text); + LOGP(DCC, LOGL_ERROR, "Invalid local or remote address definition '%s'\n", text); return -EINVAL; } @@ -1227,7 +1227,7 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text) enum osmo_cc_session_addrtype addrtype; addrtype = osmo_cc_address_type(*host_p); if (addrtype == osmo_cc_session_addrtype_unknown) { - PDEBUG(DCC, DEBUG_ERROR, "Given local address '%s' is invalid.\n", *host_p); + LOGP(DCC, LOGL_ERROR, "Given local address '%s' is invalid.\n", *host_p); return -EINVAL; } osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, addrtype, *host_p); @@ -1261,7 +1261,7 @@ static int osmo_cc_set_rtp(osmo_cc_endpoint_t *ep, const char *text) text += 9; ports = 1; } else { - PDEBUG(DCC, DEBUG_ERROR, "Invalid RTP definition '%s'\n", text); + LOGP(DCC, LOGL_ERROR, "Invalid RTP definition '%s'\n", text); return -EINVAL; } @@ -1276,7 +1276,7 @@ static int osmo_cc_set_rtp(osmo_cc_endpoint_t *ep, const char *text) enum osmo_cc_session_addrtype addrtype; addrtype = osmo_cc_address_type(text); if (addrtype == osmo_cc_session_addrtype_unknown) { - PDEBUG(DCC, DEBUG_ERROR, "Given RTP address '%s' is invalid.\n", text); + LOGP(DCC, LOGL_ERROR, "Given RTP address '%s' is invalid.\n", text); return -EINVAL; } osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, addrtype, text); @@ -1289,7 +1289,7 @@ static int osmo_cc_set_rtp(osmo_cc_endpoint_t *ep, const char *text) /* from port */ while (*text > ' ') { if (*text < '0' || *text > '9') { - PDEBUG(DCC, DEBUG_ERROR, "Given 'from' port in '%s' is invalid.\n", text); + LOGP(DCC, LOGL_ERROR, "Given 'from' port in '%s' is invalid.\n", text); return -EINVAL; } from = from * 10 + *text - '0'; @@ -1306,7 +1306,7 @@ static int osmo_cc_set_rtp(osmo_cc_endpoint_t *ep, const char *text) /* to port */ while (*text > ' ') { if (*text < '0' || *text > '9') { - PDEBUG(DCC, DEBUG_ERROR, "Given 'to' port in '%s' is invalid.\n", text); + LOGP(DCC, LOGL_ERROR, "Given 'to' port in '%s' is invalid.\n", text); return -EINVAL; } to = to * 10 + *text - '0'; @@ -1335,10 +1335,10 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u int rc; int i; - PDEBUG(DCC, DEBUG_DEBUG, "Creating new endpoint instance.\n"); + LOGP(DCC, LOGL_DEBUG, "Creating new endpoint instance.\n"); if (!!strcmp(version, OSMO_CC_VERSION)) { - PDEBUG(DCC, DEBUG_ERROR, "Application was compiled for different Osmo-CC version.\n"); + LOGP(DCC, LOGL_ERROR, "Application was compiled for different Osmo-CC version.\n"); return OSMO_CC_RC_VERSION_MISMATCH; } @@ -1392,7 +1392,7 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u return rc; } } else { - PDEBUG(DCC, DEBUG_ERROR, "Unknown osmo-cc argument \"%s\"\n", argv[i]); + LOGP(DCC, LOGL_ERROR, "Unknown osmo-cc argument \"%s\"\n", argv[i]); return -EINVAL; } } @@ -1408,7 +1408,7 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u port = ep->local_port; if (!host) { host = "127.0.0.1"; - PDEBUG(DCC, DEBUG_DEBUG, "No local peer set, using default \"%s\"\n", host); + LOGP(DCC, LOGL_DEBUG, "No local peer set, using default \"%s\"\n", host); } rc = osmo_cc_open_socket(&ep->os, host, port, ep, osmo_cc_ul_msg, serving_location); if (rc < 0) { @@ -1430,12 +1430,12 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u if (ep->remote_auto) { free((char *)ep->remote_host); ep->remote_host = strdup(ep->local_host); - PDEBUG(DCC, DEBUG_DEBUG, "Remote peer set to auto, using local peer's host \"%s\" for remote peer.\n", ep->remote_host); + LOGP(DCC, LOGL_DEBUG, "Remote peer set to auto, using local peer's host \"%s\" for remote peer.\n", ep->remote_host); if (rc == OSMO_CC_DEFAULT_PORT) ep->remote_port = OSMO_CC_DEFAULT_PORT + 1; else ep->remote_port = OSMO_CC_DEFAULT_PORT; - PDEBUG(DCC, DEBUG_DEBUG, " -> Using remote port %d.\n", ep->remote_port); + LOGP(DCC, LOGL_DEBUG, " -> Using remote port %d.\n", ep->remote_port); /* create address string */ free((char *)ep->remote_address); addrtype = osmo_cc_address_type(ep->remote_host); @@ -1460,7 +1460,7 @@ void osmo_cc_delete(osmo_cc_endpoint_t *ep) { osmo_cc_endpoint_t **epp; - PDEBUG(DCC, DEBUG_DEBUG, "Destroying endpoint instance.\n"); + LOGP(DCC, LOGL_DEBUG, "Destroying endpoint instance.\n"); /* detach from list >*/ epp = &osmo_cc_endpoint_list; @@ -1536,7 +1536,7 @@ const char *osmo_cc_host_of_address(const char *address) char *p; if (strlen(address) >= sizeof(host)) { - PDEBUG(DCC, DEBUG_ERROR, "String way too long!\n"); + LOGP(DCC, LOGL_ERROR, "String way too long!\n"); return NULL; } diff --git a/src/libosmocc/helper.c b/src/libosmocc/helper.c index e75b47a..f94d33c 100644 --- a/src/libosmocc/helper.c +++ b/src/libosmocc/helper.c @@ -63,24 +63,24 @@ const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *pr int i, selected_codec_i, telephone_event_i; if (*session_p) { - PDEBUG(DCC, DEBUG_ERROR, "Session already set, please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Session already set, please fix!\n"); abort(); } if (*codec_p) { - PDEBUG(DCC, DEBUG_ERROR, "Codec already set, please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Codec already set, please fix!\n"); abort(); } /* SDP IE */ rc = osmo_cc_get_ie_sdp(msg, 0, offer_sdp, sizeof(offer_sdp)); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "There is no SDP included in setup request.\n"); + LOGP(DCC, LOGL_ERROR, "There is no SDP included in setup request.\n"); return NULL; } *session_p = osmo_cc_session_receive_offer(conf, priv, offer_sdp); if (!*session_p) { - PDEBUG(DCC, DEBUG_ERROR, "Failed to parse SDP.\n"); + LOGP(DCC, LOGL_ERROR, "Failed to parse SDP.\n"); return NULL; } @@ -124,7 +124,7 @@ const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *pr break; } if (!selected_codec) { - PDEBUG(DCC, DEBUG_ERROR, "No codec found in setup message that we support.\n"); + LOGP(DCC, LOGL_ERROR, "No codec found in setup message that we support.\n"); osmo_cc_free_session(*session_p); *session_p = NULL; return NULL; @@ -154,7 +154,7 @@ int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **sessi int rc; if (!(*session_p)) { - PDEBUG(DCC, DEBUG_ERROR, "Session not set, please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Session not set, please fix!\n"); abort(); } @@ -185,7 +185,7 @@ int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **sessi } } if (!(*codec_p)) { - PDEBUG(DCC, DEBUG_ERROR, "No codec found in setup reply message that we support.\n"); + LOGP(DCC, LOGL_ERROR, "No codec found in setup reply message that we support.\n"); return -EIO; } diff --git a/src/libosmocc/message.c b/src/libosmocc/message.c index 6dc7a7f..1197f63 100644 --- a/src/libosmocc/message.c +++ b/src/libosmocc/message.c @@ -374,7 +374,7 @@ osmo_cc_msg_t *osmo_cc_new_msg(uint8_t msg_type) /* allocate message */ msg = calloc(1, sizeof(*msg) + 65535); if (!msg) { - PDEBUG(DCC, DEBUG_ERROR, "No memory\n"); + LOGP(DCC, LOGL_ERROR, "No memory\n"); abort(); } /* set message type and zero length */ @@ -453,14 +453,14 @@ void osmo_cc_debug_ie(osmo_cc_msg_t *msg, int level) ie = (osmo_cc_ie_t *)p; /* check for minimum IE length */ if (msg_len < sizeof(*ie)) { - PDEBUG(DCC, level, "****** Rest of message is too short for an IE: value=%s\n", debug_hex(p, msg_len)); + LOGP(DCC, level, "****** Rest of message is too short for an IE: value=%s\n", debug_hex(p, msg_len)); return; } /* get actual IE length */ len = ntohs(ie->length_networkorder); /* check if IE length does not exceed message */ if (msg_len < sizeof(*ie) + len) { - PDEBUG(DCC, level, "****** IE: type=0x%02x length=%d would exceed the rest length of message (%d bytes left)\n", ie->type, len, msg_len - (int)sizeof(*ie)); + LOGP(DCC, level, "****** IE: type=0x%02x length=%d would exceed the rest length of message (%d bytes left)\n", ie->type, len, msg_len - (int)sizeof(*ie)); return; } switch (ie->type) { @@ -468,109 +468,109 @@ void osmo_cc_debug_ie(osmo_cc_msg_t *msg, int level) rc = osmo_cc_get_ie_called(msg, ie_repeat[ie->type], &type, &plan, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s type=%d(%s) plan=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), string); + LOGP(DCC, level, " %s type=%d(%s) plan=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), string); break; case OSMO_CC_IE_CALLED_SUB: rc = osmo_cc_get_ie_called_sub(msg, ie_repeat[ie->type], &type, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s type=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), string); + LOGP(DCC, level, " %s type=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), string); break; case OSMO_CC_IE_CALLED_NAME: rc = osmo_cc_get_ie_called_name(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_CALLED_INTERFACE: rc = osmo_cc_get_ie_called_interface(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_COMPLETE: rc = osmo_cc_get_ie_complete(msg, ie_repeat[ie->type]); if (rc < 0) break; - PDEBUG(DCC, level, " %s\n", osmo_cc_ie_value2name(ie->type)); + LOGP(DCC, level, " %s\n", osmo_cc_ie_value2name(ie->type)); break; case OSMO_CC_IE_CALLING: rc = osmo_cc_get_ie_calling(msg, ie_repeat[ie->type], &type, &plan, &present, &screen, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s type=%d(%s) plan=%d(%s), presentation=%d(%s), screening=%d(%s), number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), present, osmo_cc_present_value2name(present), screen, osmo_cc_screen_value2name(screen), string); + LOGP(DCC, level, " %s type=%d(%s) plan=%d(%s), presentation=%d(%s), screening=%d(%s), number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), present, osmo_cc_present_value2name(present), screen, osmo_cc_screen_value2name(screen), string); break; case OSMO_CC_IE_CALLING_SUB: rc = osmo_cc_get_ie_calling_sub(msg, ie_repeat[ie->type], &type, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s type=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), string); + LOGP(DCC, level, " %s type=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), string); break; case OSMO_CC_IE_CALLING_NAME: rc = osmo_cc_get_ie_calling_name(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_CALLING_INTERFACE: rc = osmo_cc_get_ie_calling_interface(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s name='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_CALLING_NETWORK: rc = osmo_cc_get_ie_calling_network(msg, ie_repeat[ie->type], &type, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s type=%d(%s) id='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_network_value2name(type), string); + LOGP(DCC, level, " %s type=%d(%s) id='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_network_value2name(type), string); break; case OSMO_CC_IE_BEARER: rc = osmo_cc_get_ie_bearer(msg, ie_repeat[ie->type], &coding, &capability, &mode); if (rc < 0) break; - PDEBUG(DCC, level, " %s coding=%d(%s) capability=%d(%s) mode=%d(%s)\n", osmo_cc_ie_value2name(ie->type), coding, osmo_cc_coding_value2name(coding), capability, osmo_cc_capability_value2name(capability), mode, osmo_cc_mode_value2name(mode)); + LOGP(DCC, level, " %s coding=%d(%s) capability=%d(%s) mode=%d(%s)\n", osmo_cc_ie_value2name(ie->type), coding, osmo_cc_coding_value2name(coding), capability, osmo_cc_capability_value2name(capability), mode, osmo_cc_mode_value2name(mode)); break; case OSMO_CC_IE_REDIR: rc = osmo_cc_get_ie_redir(msg, ie_repeat[ie->type], &type, &plan, &present, &screen, &reason, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s type=%d(%s) plan=%d(%s) presentation=%d(%s) screening=%d(%s) reason=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), present, osmo_cc_present_value2name(present), screen, osmo_cc_screen_value2name(screen), reason, osmo_cc_redir_reason_value2name(reason), string); + LOGP(DCC, level, " %s type=%d(%s) plan=%d(%s) presentation=%d(%s) screening=%d(%s) reason=%d(%s) number='%s'\n", osmo_cc_ie_value2name(ie->type), type, osmo_cc_type_value2name(type), plan, osmo_cc_plan_value2name(plan), present, osmo_cc_present_value2name(present), screen, osmo_cc_screen_value2name(screen), reason, osmo_cc_redir_reason_value2name(reason), string); break; case OSMO_CC_IE_DTMF: rc = osmo_cc_get_ie_dtmf(msg, ie_repeat[ie->type], &duration_ms, &pause_ms, &dtmf_mode, string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s duration=%dms pause=%dms mode=%d(%s)\n", osmo_cc_ie_value2name(ie->type), duration_ms, pause_ms, dtmf_mode, osmo_cc_dtmf_mode_value2name(dtmf_mode)); + LOGP(DCC, level, " %s duration=%dms pause=%dms mode=%d(%s)\n", osmo_cc_ie_value2name(ie->type), duration_ms, pause_ms, dtmf_mode, osmo_cc_dtmf_mode_value2name(dtmf_mode)); break; case OSMO_CC_IE_KEYPAD: rc = osmo_cc_get_ie_keypad(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s digits='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s digits='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_PROGRESS: rc = osmo_cc_get_ie_progress(msg, ie_repeat[ie->type], &coding, &location, &progress); if (rc < 0) break; - PDEBUG(DCC, level, " %s coding=%d(%s) location=%d(%s) progress=%d(%s)\n", osmo_cc_ie_value2name(ie->type), coding, osmo_cc_coding_value2name(coding), location, osmo_cc_location_value2name(location), progress, osmo_cc_progress_value2name(progress)); + LOGP(DCC, level, " %s coding=%d(%s) location=%d(%s) progress=%d(%s)\n", osmo_cc_ie_value2name(ie->type), coding, osmo_cc_coding_value2name(coding), location, osmo_cc_location_value2name(location), progress, osmo_cc_progress_value2name(progress)); break; case OSMO_CC_IE_NOTIFY: rc = osmo_cc_get_ie_notify(msg, ie_repeat[ie->type], ¬ify); if (rc < 0) break; - PDEBUG(DCC, level, " %s indicator=%d(%s)\n", osmo_cc_ie_value2name(ie->type), notify, osmo_cc_notify_value2name(notify)); + LOGP(DCC, level, " %s indicator=%d(%s)\n", osmo_cc_ie_value2name(ie->type), notify, osmo_cc_notify_value2name(notify)); break; case OSMO_CC_IE_CAUSE: rc = osmo_cc_get_ie_cause(msg, ie_repeat[ie->type], &location, &isdn_cause, &sip_cause, &socket_cause); if (rc < 0) break; - PDEBUG(DCC, level, " %s location=%d(%s) isdn_cause=%d(%s) sip_cause=%d socket_cause=%d(%s)\n", osmo_cc_ie_value2name(ie->type), location, osmo_cc_location_value2name(location), isdn_cause, osmo_cc_isdn_cause_value2name(isdn_cause), sip_cause, socket_cause, osmo_cc_socket_cause_value2name(socket_cause)); + LOGP(DCC, level, " %s location=%d(%s) isdn_cause=%d(%s) sip_cause=%d socket_cause=%d(%s)\n", osmo_cc_ie_value2name(ie->type), location, osmo_cc_location_value2name(location), isdn_cause, osmo_cc_isdn_cause_value2name(isdn_cause), sip_cause, socket_cause, osmo_cc_socket_cause_value2name(socket_cause)); break; case OSMO_CC_IE_DISPLAY: rc = osmo_cc_get_ie_display(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s info='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s info='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_SDP: rc = osmo_cc_get_ie_sdp(msg, ie_repeat[ie->type], string, sizeof(string)); @@ -582,22 +582,22 @@ void osmo_cc_debug_ie(osmo_cc_msg_t *msg, int level) if (string[i] == '\n') string[i] = 'n'; } - PDEBUG(DCC, level, " %s payload=%s\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s payload=%s\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_SOCKET_ADDRESS: rc = osmo_cc_get_ie_socket_address(msg, ie_repeat[ie->type], string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s address='%s'\n", osmo_cc_ie_value2name(ie->type), string); + LOGP(DCC, level, " %s address='%s'\n", osmo_cc_ie_value2name(ie->type), string); break; case OSMO_CC_IE_PRIVATE: rc = osmo_cc_get_ie_private(msg, ie_repeat[ie->type], &unique, (uint8_t *)string, sizeof(string)); if (rc < 0) break; - PDEBUG(DCC, level, " %s unique=%u=0x%08x private=%s\n", osmo_cc_ie_value2name(ie->type), unique, unique, debug_hex((uint8_t *)string, rc)); + LOGP(DCC, level, " %s unique=%u=0x%08x private=%s\n", osmo_cc_ie_value2name(ie->type), unique, unique, debug_hex((uint8_t *)string, rc)); break; default: - PDEBUG(DCC, level, " %s type=0x%02x length=%d value=%s\n", osmo_cc_ie_value2name(ie->type), ie->type, len, debug_hex(ie->data, len)); + LOGP(DCC, level, " %s type=0x%02x length=%d value=%s\n", osmo_cc_ie_value2name(ie->type), ie->type, len, debug_hex(ie->data, len)); } ie_repeat[ie->type]++; p += sizeof(*ie) + len; @@ -625,16 +625,16 @@ int osmo_cc_get_ie_struct(osmo_cc_msg_t *msg, uint8_t ie_type, int ie_repeat, in ie = (osmo_cc_ie_t *)p; /* check for minimum IE length */ if (msg_len < sizeof(*ie)) { - PDEBUG(DCC, DEBUG_ERROR, "MSG short read\n"); - osmo_cc_debug_ie(msg, DEBUG_ERROR); + LOGP(DCC, LOGL_ERROR, "MSG short read\n"); + osmo_cc_debug_ie(msg, LOGL_ERROR); return -EINVAL; } /* get actual IE length */ len = ntohs(ie->length_networkorder); /* check if IE length does not exceed message */ if (msg_len < sizeof(*ie) + len) { - PDEBUG(DCC, DEBUG_ERROR, "MSG short read\n"); - osmo_cc_debug_ie(msg, DEBUG_ERROR); + LOGP(DCC, LOGL_ERROR, "MSG short read\n"); + osmo_cc_debug_ie(msg, LOGL_ERROR); return -EINVAL; } /* check if IE matches the one that is searched for */ @@ -652,7 +652,7 @@ int osmo_cc_get_ie_struct(osmo_cc_msg_t *msg, uint8_t ie_type, int ie_repeat, in } /* return IE and indicate how many bytes we have more than the given length*/ if (ntohs(ie->length_networkorder) < ie_len) { - PDEBUG(DCC, DEBUG_ERROR, "IE 0x%02d has length of %d, but we expect it to have at least %d!\n", ie_type, ntohs(ie->length_networkorder), ie_len); + LOGP(DCC, LOGL_ERROR, "IE 0x%02d has length of %d, but we expect it to have at least %d!\n", ie_type, ntohs(ie->length_networkorder), ie_len); return -EINVAL; } *ie_struct = ie; @@ -728,7 +728,7 @@ void *osmo_cc_add_ie(osmo_cc_msg_t *msg, uint8_t ie_type, int ie_len) msg_len = ntohs(msg->length_networkorder); new_msg_len = msg_len + sizeof(*ie) + ie_len; if (new_msg_len > 65535) { - PDEBUG(DCC, DEBUG_ERROR, "MSG overflow\n"); + LOGP(DCC, LOGL_ERROR, "MSG overflow\n"); return NULL; } msg->length_networkorder = htons(new_msg_len); diff --git a/src/libosmocc/rtp.c b/src/libosmocc/rtp.c index 406d330..613d12c 100644 --- a/src/libosmocc/rtp.c +++ b/src/libosmocc/rtp.c @@ -68,11 +68,11 @@ static int rtp_receive(int sock, uint8_t **payload_p, int *payload_len_p, uint8_ if (len < 0) { if (errno == EAGAIN) return -EAGAIN; - PDEBUG(DCC, DEBUG_DEBUG, "Read errno = %d (%s)\n", errno, strerror(errno)); + LOGP(DCC, LOGL_DEBUG, "Read errno = %d (%s)\n", errno, strerror(errno)); return -EIO; } if (len < 12) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame too short (len = %d).\n", len); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame too short (len = %d).\n", len); return -EINVAL; } @@ -87,20 +87,20 @@ static int rtp_receive(int sock, uint8_t **payload_p, int *payload_len_p, uint8_ *ssrc_p = ntohl(rtph->ssrc); if (version != RTP_VERSION) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP version %d not supported.\n", version); + LOGP(DCC, LOGL_NOTICE, "Received RTP version %d not supported.\n", version); return -EINVAL; } payload = data + sizeof(*rtph) + (csrc_count << 2); payload_len = len - sizeof(*rtph) - (csrc_count << 2); if (payload_len < 0) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame too short (len = %d, csrc count = %d).\n", len, csrc_count); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame too short (len = %d, csrc count = %d).\n", len, csrc_count); return -EINVAL; } if (extension) { if (payload_len < (int)sizeof(*rtpxh)) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame too short for extension header.\n"); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame too short for extension header.\n"); return -EINVAL; } rtpxh = (struct rtp_x_hdr *)payload; @@ -108,19 +108,19 @@ static int rtp_receive(int sock, uint8_t **payload_p, int *payload_len_p, uint8_ payload += x_len; payload_len -= x_len; if (payload_len < (int)sizeof(*rtpxh)) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame too short, extension header exceeds frame length.\n"); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame too short, extension header exceeds frame length.\n"); return -EINVAL; } } if (padding) { if (payload_len < 1) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame too short for padding length.\n"); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame too short for padding length.\n"); return -EINVAL; } payload_len -= payload[payload_len - 1]; if (payload_len < 0) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame padding is greater than payload.\n"); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame padding is greater than payload.\n"); return -EINVAL; } } @@ -142,7 +142,7 @@ static int rtcp_receive(int sock) if (len < 0) { if (errno == EAGAIN) return -EAGAIN; - PDEBUG(DCC, DEBUG_DEBUG, "Read errno = %d (%s)\n", errno, strerror(errno)); + LOGP(DCC, LOGL_DEBUG, "Read errno = %d (%s)\n", errno, strerror(errno)); return -EIO; } @@ -164,14 +164,14 @@ static void rtp_send(int sock, uint8_t *payload, int payload_len, uint8_t marker rtph->ssrc = htonl(ssrc); len += payload_len; if (len > (int)sizeof(data)) { - PDEBUG(DCC, DEBUG_NOTICE, "Buffer overflow, please fix!.\n"); + LOGP(DCC, LOGL_NOTICE, "Buffer overflow, please fix!.\n"); abort(); } memcpy(data + sizeof(*rtph), payload, payload_len); rc = write(sock, data, len); if (rc < 0) - PDEBUG(DCC, DEBUG_DEBUG, "Write errno = %d (%s)\n", errno, strerror(errno)); + LOGP(DCC, LOGL_DEBUG, "Write errno = %d (%s)\n", errno, strerror(errno)); } static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when); @@ -206,7 +206,7 @@ int osmo_cc_rtp_open(osmo_cc_session_media_t *media) rc = inet_pton(AF_INET, media->connection_data_local.address, &sa4->sin_addr); if (rc < 1) { pton_error: - PDEBUG(DCC, DEBUG_NOTICE, "Cannot bind to address '%s'.\n", media->connection_data_local.address); + LOGP(DCC, LOGL_NOTICE, "Cannot bind to address '%s'.\n", media->connection_data_local.address); return -EINVAL; } sport = &sa4->sin_port; @@ -224,7 +224,7 @@ pton_error: slen = sizeof(*sa6); break; case osmo_cc_session_addrtype_unknown: - PDEBUG(DCC, DEBUG_NOTICE, "Unsupported address type '%s'.\n", media->connection_data_local.addrtype_name); + LOGP(DCC, LOGL_NOTICE, "Unsupported address type '%s'.\n", media->connection_data_local.addrtype_name); return -EINVAL; } @@ -237,7 +237,7 @@ pton_error: rc = socket(domain, SOCK_DGRAM, IPPROTO_UDP); if (rc < 0) { socket_error: - PDEBUG(DCC, DEBUG_ERROR, "Cannot create socket (domain=%d, errno=%d(%s))\n", domain, errno, strerror(errno)); + LOGP(DCC, LOGL_ERROR, "Cannot create socket (domain=%d, errno=%d(%s))\n", domain, errno, strerror(errno)); osmo_cc_rtp_close(media); return -EIO; } @@ -263,7 +263,7 @@ bind_error: osmo_cc_rtp_close(media); conf->rtp_port_next = (conf->rtp_port_next + 2 > conf->rtp_port_to) ? conf->rtp_port_from : conf->rtp_port_next + 2; if (conf->rtp_port_next == start_port) { - PDEBUG(DCC, DEBUG_ERROR, "Cannot bind socket (errno=%d(%s))\n", errno, strerror(errno)); + LOGP(DCC, LOGL_ERROR, "Cannot bind socket (errno=%d(%s))\n", errno, strerror(errno)); return -EIO; } continue; @@ -284,7 +284,7 @@ bind_error: break; } - PDEBUG(DCC, DEBUG_DEBUG, "Opening media port %d\n", media->description.port_local); + LOGP(DCC, LOGL_DEBUG, "Opening media port %d\n", media->description.port_local); return 0; } @@ -301,7 +301,7 @@ int osmo_cc_rtp_connect(osmo_cc_session_media_t *media) uint16_t *sport; int rc; - PDEBUG(DCC, DEBUG_DEBUG, "Connecting media port %d->%d\n", media->description.port_local, media->description.port_remote); + LOGP(DCC, LOGL_DEBUG, "Connecting media port %d->%d\n", media->description.port_local, media->description.port_remote); switch (media->connection_data_remote.addrtype) { case osmo_cc_session_addrtype_ipv4: @@ -311,7 +311,7 @@ int osmo_cc_rtp_connect(osmo_cc_session_media_t *media) rc = inet_pton(AF_INET, media->connection_data_remote.address, &sa4->sin_addr); if (rc < 1) { pton_error: - PDEBUG(DCC, DEBUG_NOTICE, "Cannot connect to address '%s'.\n", media->connection_data_remote.address); + LOGP(DCC, LOGL_NOTICE, "Cannot connect to address '%s'.\n", media->connection_data_remote.address); return -EINVAL; } sport = &sa4->sin_port; @@ -328,7 +328,7 @@ pton_error: slen = sizeof(*sa6); break; case osmo_cc_session_addrtype_unknown: - PDEBUG(DCC, DEBUG_NOTICE, "Unsupported address type '%s'.\n", media->connection_data_local.addrtype_name); + LOGP(DCC, LOGL_NOTICE, "Unsupported address type '%s'.\n", media->connection_data_local.addrtype_name); return -EINVAL; } @@ -336,7 +336,7 @@ pton_error: rc = connect(media->rtp_ofd.fd, (struct sockaddr *)&sa, slen); if (rc < 0) { connect_error: - PDEBUG(DCC, DEBUG_NOTICE, "Cannot connect to address '%s'.\n", media->connection_data_remote.address); + LOGP(DCC, LOGL_NOTICE, "Cannot connect to address '%s'.\n", media->connection_data_remote.address); osmo_cc_rtp_close(media); return -EIO; } @@ -395,7 +395,7 @@ static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when) break; } if (!codec) { - PDEBUG(DCC, DEBUG_NOTICE, "Received RTP frame for unknown codec (payload_type = %d).\n", payload_type); + LOGP(DCC, LOGL_NOTICE, "Received RTP frame for unknown codec (payload_type = %d).\n", payload_type); return 0; } diff --git a/src/libosmocc/screen.c b/src/libosmocc/screen.c index a3b0797..be12f08 100644 --- a/src/libosmocc/screen.c +++ b/src/libosmocc/screen.c @@ -153,7 +153,7 @@ int osmo_cc_add_screen(osmo_cc_endpoint_t *ep, const char *text) text += 17; list_p = &ep->screen_called_out; } else { - PDEBUG(DCC, DEBUG_ERROR, "Invalid screening definition \"%s\". It must start with 'screen-calling-in' or 'screen-called-in' or 'screen-calling-out' or 'screen-called-out'\n", text); + LOGP(DCC, LOGL_ERROR, "Invalid screening definition \"%s\". It must start with 'screen-calling-in' or 'screen-called-in' or 'screen-calling-out' or 'screen-called-out'\n", text); return -EINVAL; } @@ -172,7 +172,7 @@ next_from: token = osmo_cc_strtok_quotes(&text); if (!token) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Missing 'from' string in screening definition \"%s\". If the string shall be empty, use double quotes. (\'\' or \"\")\n", text); + LOGP(DCC, LOGL_ERROR, "Missing 'from' string in screening definition \"%s\". If the string shall be empty, use double quotes. (\'\' or \"\")\n", text); return -EINVAL; } if (!strcasecmp(token, "unknown")) { @@ -209,8 +209,8 @@ next_from: if (no_present) { no_present_error: free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "Keyword '%s' not allowed in screen entry for called number\n", token); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "Keyword '%s' not allowed in screen entry for called number\n", token); return -EINVAL; } list->has_from_present = 1; @@ -232,8 +232,8 @@ no_present_error: if (token[i] == '*') { if (star_used) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "The '*' may be used only once.\n"); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "The '*' may be used only once.\n"); return -EINVAL; } list->from[j] = SCREEN_STAR; @@ -251,8 +251,8 @@ next_to: token = osmo_cc_strtok_quotes(&text); if (!token) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "Missing screening result. If the string shall be empty, use double quotes. (\'\' or \"\")\n"); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "Missing screening result. If the string shall be empty, use double quotes. (\'\' or \"\")\n"); return -EINVAL; } if (!strcasecmp(token, "unknown")) { @@ -304,8 +304,8 @@ next_to: if (token[i] == '*') { if (star_used) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "The '*' may be used only once.\n"); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "The '*' may be used only once.\n"); return -EINVAL; } list->to[j] = SCREEN_STAR; @@ -314,14 +314,14 @@ next_to: if (token[i] == '@') { if (!calling_in) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "The '@' may be used only for incoming calls from interface.\n"); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "The '@' may be used only for incoming calls from interface.\n"); return -EINVAL; } if (at_used) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "The '@' may be used only once.\n"); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "The '@' may be used only once.\n"); return -EINVAL; } list->to[j] = SCREEN_AT; @@ -338,8 +338,8 @@ next_to: token = osmo_cc_strtok_quotes(&text); if (token) { free(list); - PDEBUG(DCC, DEBUG_ERROR, "Error in screening definition '%s'.\n", text); - PDEBUG(DCC, DEBUG_ERROR, "Got garbage behind screening result.\n"); + LOGP(DCC, LOGL_ERROR, "Error in screening definition '%s'.\n", text); + LOGP(DCC, LOGL_ERROR, "Got garbage behind screening result.\n"); return -EINVAL; } @@ -392,76 +392,76 @@ static int osmo_cc_screen(const char *what, osmo_cc_screen_list_t *list, uint8_t const char *suffix; int i, j, rule; - PDEBUG(DCC, DEBUG_INFO, "Screening %s '%s':\n", what, id_from); + LOGP(DCC, LOGL_INFO, "Screening %s '%s':\n", what, id_from); switch (*type) { case OSMO_CC_TYPE_UNKNOWN: - PDEBUG(DCC, DEBUG_INFO, " -> type = unknown\n"); + LOGP(DCC, LOGL_INFO, " -> type = unknown\n"); break; case OSMO_CC_TYPE_INTERNATIONAL: - PDEBUG(DCC, DEBUG_INFO, " -> type = international\n"); + LOGP(DCC, LOGL_INFO, " -> type = international\n"); break; case OSMO_CC_TYPE_NATIONAL: - PDEBUG(DCC, DEBUG_INFO, " -> type = national\n"); + LOGP(DCC, LOGL_INFO, " -> type = national\n"); break; case OSMO_CC_TYPE_NETWORK: - PDEBUG(DCC, DEBUG_INFO, " -> type = network\n"); + LOGP(DCC, LOGL_INFO, " -> type = network\n"); break; case OSMO_CC_TYPE_SUBSCRIBER: - PDEBUG(DCC, DEBUG_INFO, " -> type = subscriber\n"); + LOGP(DCC, LOGL_INFO, " -> type = subscriber\n"); break; case OSMO_CC_TYPE_ABBREVIATED: - PDEBUG(DCC, DEBUG_INFO, " -> type = abbreviated\n"); + LOGP(DCC, LOGL_INFO, " -> type = abbreviated\n"); break; } if (present) switch (*present) { case OSMO_CC_PRESENT_ALLOWED: - PDEBUG(DCC, DEBUG_INFO, " -> present = allowed\n"); + LOGP(DCC, LOGL_INFO, " -> present = allowed\n"); break; case OSMO_CC_PRESENT_RESTRICTED: - PDEBUG(DCC, DEBUG_INFO, " -> present = restricted\n"); + LOGP(DCC, LOGL_INFO, " -> present = restricted\n"); break; } rule = 0; while (list) { rule++; - PDEBUG(DCC, DEBUG_INFO, "Comparing with rule #%d: '%s':\n", rule, print_rule_string(list->from)); + LOGP(DCC, LOGL_INFO, "Comparing with rule #%d: '%s':\n", rule, print_rule_string(list->from)); if (list->has_from_type) switch (list->from_type) { case OSMO_CC_TYPE_UNKNOWN: - PDEBUG(DCC, DEBUG_INFO, " -> type = unknown\n"); + LOGP(DCC, LOGL_INFO, " -> type = unknown\n"); break; case OSMO_CC_TYPE_INTERNATIONAL: - PDEBUG(DCC, DEBUG_INFO, " -> type = international\n"); + LOGP(DCC, LOGL_INFO, " -> type = international\n"); break; case OSMO_CC_TYPE_NATIONAL: - PDEBUG(DCC, DEBUG_INFO, " -> type = national\n"); + LOGP(DCC, LOGL_INFO, " -> type = national\n"); break; case OSMO_CC_TYPE_NETWORK: - PDEBUG(DCC, DEBUG_INFO, " -> type = network\n"); + LOGP(DCC, LOGL_INFO, " -> type = network\n"); break; case OSMO_CC_TYPE_SUBSCRIBER: - PDEBUG(DCC, DEBUG_INFO, " -> type = subscriber\n"); + LOGP(DCC, LOGL_INFO, " -> type = subscriber\n"); break; case OSMO_CC_TYPE_ABBREVIATED: - PDEBUG(DCC, DEBUG_INFO, " -> type = abbreviated\n"); + LOGP(DCC, LOGL_INFO, " -> type = abbreviated\n"); break; } if (list->has_from_present) switch (list->from_present) { case OSMO_CC_PRESENT_ALLOWED: - PDEBUG(DCC, DEBUG_INFO, " -> present = allowed\n"); + LOGP(DCC, LOGL_INFO, " -> present = allowed\n"); break; case OSMO_CC_PRESENT_RESTRICTED: - PDEBUG(DCC, DEBUG_INFO, " -> present = restricted\n"); + LOGP(DCC, LOGL_INFO, " -> present = restricted\n"); break; } suffix = NULL; /* attributes do not match */ if (list->has_from_type && list->from_type != *type) { - PDEBUG(DCC, DEBUG_INFO, "Rule does not match, because 'type' is different.\n"); + LOGP(DCC, LOGL_INFO, "Rule does not match, because 'type' is different.\n"); continue; } if (present && list->has_from_present && list->from_present != *present) { - PDEBUG(DCC, DEBUG_INFO, "Rule does not match, because 'present' is different.\n"); + LOGP(DCC, LOGL_INFO, "Rule does not match, because 'present' is different.\n"); continue; } for (i = 0; list->from[i] && id_from[i]; i++) { @@ -485,7 +485,7 @@ static int osmo_cc_screen(const char *what, osmo_cc_screen_list_t *list, uint8_t /* if all digits have matched */ if (list->from[i] == '\0' && id_from[i] == '\0') break; - PDEBUG(DCC, DEBUG_INFO, "Rule does not match, because %s is different.\n", what); + LOGP(DCC, LOGL_INFO, "Rule does not match, because %s is different.\n", what); list = list->next; } @@ -522,37 +522,37 @@ static int osmo_cc_screen(const char *what, osmo_cc_screen_list_t *list, uint8_t } id_to[j] = '\0'; - PDEBUG(DCC, DEBUG_INFO, "Rule matches, changing %s to '%s'.\n", what, print_rule_string(id_to)); + LOGP(DCC, LOGL_INFO, "Rule matches, changing %s to '%s'.\n", what, print_rule_string(id_to)); if (list->has_to_type) switch (list->to_type) { case OSMO_CC_TYPE_UNKNOWN: - PDEBUG(DCC, DEBUG_INFO, " -> type = unknown\n"); + LOGP(DCC, LOGL_INFO, " -> type = unknown\n"); break; case OSMO_CC_TYPE_INTERNATIONAL: - PDEBUG(DCC, DEBUG_INFO, " -> type = international\n"); + LOGP(DCC, LOGL_INFO, " -> type = international\n"); break; case OSMO_CC_TYPE_NATIONAL: - PDEBUG(DCC, DEBUG_INFO, " -> type = national\n"); + LOGP(DCC, LOGL_INFO, " -> type = national\n"); break; case OSMO_CC_TYPE_NETWORK: - PDEBUG(DCC, DEBUG_INFO, " -> type = network\n"); + LOGP(DCC, LOGL_INFO, " -> type = network\n"); break; case OSMO_CC_TYPE_SUBSCRIBER: - PDEBUG(DCC, DEBUG_INFO, " -> type = subscriber\n"); + LOGP(DCC, LOGL_INFO, " -> type = subscriber\n"); break; case OSMO_CC_TYPE_ABBREVIATED: - PDEBUG(DCC, DEBUG_INFO, " -> type = abbreviated\n"); + LOGP(DCC, LOGL_INFO, " -> type = abbreviated\n"); break; } if (list->has_to_present) switch (list->to_present) { case OSMO_CC_PRESENT_ALLOWED: - PDEBUG(DCC, DEBUG_INFO, " -> present = allowed\n"); + LOGP(DCC, LOGL_INFO, " -> present = allowed\n"); break; case OSMO_CC_PRESENT_RESTRICTED: - PDEBUG(DCC, DEBUG_INFO, " -> present = restricted\n"); + LOGP(DCC, LOGL_INFO, " -> present = restricted\n"); break; } if (routing_p && *routing_p) - PDEBUG(DCC, DEBUG_INFO, " -> remote = %s\n", *routing_p); + LOGP(DCC, LOGL_INFO, " -> remote = %s\n", *routing_p); return 0; } diff --git a/src/libosmocc/sdp.c b/src/libosmocc/sdp.c index 3498843..e350d52 100644 --- a/src/libosmocc/sdp.c +++ b/src/libosmocc/sdp.c @@ -136,7 +136,7 @@ char *osmo_cc_session_gensdp(osmo_cc_session_t *session) /* check for overflow and return */ if (strlen(sdp) == sizeof(sdp) - 1) { - PDEBUG(DCC, DEBUG_ERROR, "Fatal error: Allocated SDP buffer with %d bytes is too small, please fix!\n", (int)sizeof(sdp)); + LOGP(DCC, LOGL_ERROR, "Fatal error: Allocated SDP buffer with %d bytes is too small, please fix!\n", (int)sizeof(sdp)); return NULL; } return sdp; @@ -286,21 +286,21 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, continue; if (line[1] != '=') { - PDEBUG(DCC, DEBUG_NOTICE, "SDP line %d = '%s' is garbage, expecting '=' as second character.\n", line_no, line); + LOGP(DCC, LOGL_NOTICE, "SDP line %d = '%s' is garbage, expecting '=' as second character.\n", line_no, line); continue; } switch(line[0]) { case 'v': - PDEBUG(DCC, DEBUG_DEBUG, " -> Version: %s\n", next_word); + LOGP(DCC, LOGL_DEBUG, " -> Version: %s\n", next_word); if (atoi(next_word) != 0) { - PDEBUG(DCC, DEBUG_NOTICE, "SDP line %d = '%s' describes unsupported version.\n", line_no, line); + LOGP(DCC, LOGL_NOTICE, "SDP line %d = '%s' describes unsupported version.\n", line_no, line); osmo_cc_free_session(session); return NULL; } break; case 'o': - PDEBUG(DCC, DEBUG_DEBUG, " -> Originator: %s\n", next_word); + LOGP(DCC, LOGL_DEBUG, " -> Originator: %s\n", next_word); /* Originator */ word = wordsep(&next_word); if (!word) @@ -335,12 +335,12 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, break; case 's': /* Session Name */ - PDEBUG(DCC, DEBUG_DEBUG, " -> Session Name: %s\n", next_word); + LOGP(DCC, LOGL_DEBUG, " -> Session Name: %s\n", next_word); free((char *)session->name); // if already set session->name = strdup(next_word); break; case 'c': /* Connection Data */ - PDEBUG(DCC, DEBUG_DEBUG, " -> Connection Data: %s\n", next_word); + LOGP(DCC, LOGL_DEBUG, " -> Connection Data: %s\n", next_word); if (media) cd = &media->connection_data_remote; else @@ -351,7 +351,7 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, if (!strcmp(word, "IN")) cd->nettype = osmo_cc_session_nettype_inet; else { - PDEBUG(DCC, DEBUG_NOTICE, "Unsupported network type '%s' in SDP line %d = '%s'\n", word, line_no, line); + LOGP(DCC, LOGL_NOTICE, "Unsupported network type '%s' in SDP line %d = '%s'\n", word, line_no, line); break; } /* address type */ @@ -359,13 +359,13 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, break; if (!strcmp(word, "IP4")) { cd->addrtype = osmo_cc_session_addrtype_ipv4; - PDEBUG(DCC, DEBUG_DEBUG, " -> Address Type = IPv4\n"); + LOGP(DCC, LOGL_DEBUG, " -> Address Type = IPv4\n"); } else if (!strcmp(word, "IP6")) { cd->addrtype = osmo_cc_session_addrtype_ipv6; - PDEBUG(DCC, DEBUG_DEBUG, " -> Address Type = IPv6\n"); + LOGP(DCC, LOGL_DEBUG, " -> Address Type = IPv6\n"); } else { - PDEBUG(DCC, DEBUG_NOTICE, "Unsupported address type '%s' in SDP line %d = '%s'\n", word, line_no, line); + LOGP(DCC, LOGL_NOTICE, "Unsupported address type '%s' in SDP line %d = '%s'\n", word, line_no, line); break; } /* connection address */ @@ -375,10 +375,10 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, *p++ = '\0'; free((char *)cd->address); // in case of multiple lines of 'c' cd->address = strdup(word); - PDEBUG(DCC, DEBUG_DEBUG, " -> Address = %s\n", word); + LOGP(DCC, LOGL_DEBUG, " -> Address = %s\n", word); break; case 'm': /* Media Description */ - PDEBUG(DCC, DEBUG_DEBUG, " -> Media Description: %s\n", next_word); + LOGP(DCC, LOGL_DEBUG, " -> Media Description: %s\n", next_word); /* add media description */ media = osmo_cc_add_media(session, 0, 0, NULL, 0, 0, 0, csend, creceive, NULL, 0); /* copy common connection data from common connection, if exists */ @@ -395,7 +395,7 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, else { media->description.type = osmo_cc_session_media_type_unknown; media->description.type_name = strdup(word); - PDEBUG(DCC, DEBUG_DEBUG, "Unsupported media type in SDP line %d = '%s'\n", line_no, line); + LOGP(DCC, LOGL_DEBUG, "Unsupported media type in SDP line %d = '%s'\n", line_no, line); } /* port */ if (!(word = wordsep(&next_word))) @@ -409,7 +409,7 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, else { media->description.proto = osmo_cc_session_media_proto_unknown; media->description.proto_name = strdup(word); - PDEBUG(DCC, DEBUG_NOTICE, "Unsupported protocol type in SDP line %d = '%s'\n", line_no, line); + LOGP(DCC, LOGL_NOTICE, "Unsupported protocol type in SDP line %d = '%s'\n", line_no, line); break; } /* create codec description for each codec and link */ @@ -419,17 +419,17 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, /* fmt */ codec->payload_type_remote = atoi(word); complete_codec_by_fmt(codec->payload_type_remote, &codec->payload_name, &codec->payload_rate, &codec->payload_channels); - PDEBUG(DCC, DEBUG_DEBUG, " -> payload type = %d\n", codec->payload_type_remote); + LOGP(DCC, LOGL_DEBUG, " -> payload type = %d\n", codec->payload_type_remote); if (codec->payload_name) - PDEBUG(DCC, DEBUG_DEBUG, " -> payload name = %s\n", codec->payload_name); + LOGP(DCC, LOGL_DEBUG, " -> payload name = %s\n", codec->payload_name); if (codec->payload_rate) - PDEBUG(DCC, DEBUG_DEBUG, " -> payload rate = %d\n", codec->payload_rate); + LOGP(DCC, LOGL_DEBUG, " -> payload rate = %d\n", codec->payload_rate); if (codec->payload_channels) - PDEBUG(DCC, DEBUG_DEBUG, " -> payload channels = %d\n", codec->payload_channels); + LOGP(DCC, LOGL_DEBUG, " -> payload channels = %d\n", codec->payload_channels); } break; case 'a': - PDEBUG(DCC, DEBUG_DEBUG, " -> Attribute: %s\n", next_word); + LOGP(DCC, LOGL_DEBUG, " -> Attribute: %s\n", next_word); word = wordsep(&next_word); if (!strcmp(word, "sendrecv")) { if (media) { @@ -472,7 +472,7 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, break; } else if (!media) { - PDEBUG(DCC, DEBUG_NOTICE, "Attribute without previously defined media in SDP line %d = '%s'\n", line_no, line); + LOGP(DCC, LOGL_NOTICE, "Attribute without previously defined media in SDP line %d = '%s'\n", line_no, line); break; } if (!strncmp(word, "rtpmap:", 7)) { @@ -482,23 +482,23 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, break; } if (!codec) { - PDEBUG(DCC, DEBUG_NOTICE, "Attribute without previously defined codec in SDP line %d = '%s'\n", line_no, line); + LOGP(DCC, LOGL_NOTICE, "Attribute without previously defined codec in SDP line %d = '%s'\n", line_no, line); break; } - PDEBUG(DCC, DEBUG_DEBUG, " -> (rtpmap) payload type = %d\n", codec->payload_type_remote); + LOGP(DCC, LOGL_DEBUG, " -> (rtpmap) payload type = %d\n", codec->payload_type_remote); if (!(word = wordsep(&next_word))) goto rtpmap_done; if ((p = strchr(word, '/'))) *p++ = '\0'; free((char *)codec->payload_name); // in case it is already set above codec->payload_name = strdup(word); - PDEBUG(DCC, DEBUG_DEBUG, " -> (rtpmap) payload name = %s\n", codec->payload_name); + LOGP(DCC, LOGL_DEBUG, " -> (rtpmap) payload name = %s\n", codec->payload_name); if (!(word = p)) goto rtpmap_done; if ((p = strchr(word, '/'))) *p++ = '\0'; codec->payload_rate = atoi(word); - PDEBUG(DCC, DEBUG_DEBUG, " -> (rtpmap) payload rate = %d\n", codec->payload_rate); + LOGP(DCC, LOGL_DEBUG, " -> (rtpmap) payload rate = %d\n", codec->payload_rate); if (!(word = p)) { /* if no channel is given and no default was specified, we must set 1 channel */ if (!codec->payload_channels) @@ -506,10 +506,10 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, goto rtpmap_done; } codec->payload_channels = atoi(word); - PDEBUG(DCC, DEBUG_DEBUG, " -> (rtpmap) payload channels = %d\n", codec->payload_channels); + LOGP(DCC, LOGL_DEBUG, " -> (rtpmap) payload channels = %d\n", codec->payload_channels); rtpmap_done: if (!codec->payload_name || !codec->payload_rate || !codec->payload_channels) { - PDEBUG(DCC, DEBUG_NOTICE, "Broken 'rtpmap' definition in SDP line %d = '%s' Skipping codec!\n", line_no, line); + LOGP(DCC, LOGL_NOTICE, "Broken 'rtpmap' definition in SDP line %d = '%s' Skipping codec!\n", line_no, line); osmo_cc_free_codec(codec); } } @@ -519,7 +519,7 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, /* if something is incomplete, abort here */ if (osmo_cc_session_check(session, 1)) { - PDEBUG(DCC, DEBUG_NOTICE, "Parsing SDP failed.\n"); + LOGP(DCC, LOGL_NOTICE, "Parsing SDP failed.\n"); osmo_cc_free_session(session); return NULL; } @@ -537,7 +537,7 @@ void osmo_cc_debug_sdp(const char *_sdp) for (i = 0; *sdp > 0 && *sdp >= 32 && i < (int)sizeof(text) - 1; i++) text[i] = *sdp++; text[i] = '\0'; - PDEBUG(DCC, DEBUG_DEBUG, " | %s\n", text); + LOGP(DCC, LOGL_DEBUG, " | %s\n", text); while (*sdp > 0 && *sdp < 32) sdp++; } diff --git a/src/libosmocc/session.c b/src/libosmocc/session.c index 5e2447a..f4e7b88 100644 --- a/src/libosmocc/session.c +++ b/src/libosmocc/session.c @@ -43,11 +43,11 @@ osmo_cc_session_t *osmo_cc_new_session(osmo_cc_session_config_t *conf, void *pri { osmo_cc_session_t *session; - if (debug) PDEBUG(DCC, DEBUG_DEBUG, "Creating session structure.\n"); + if (debug) LOGP(DCC, LOGL_DEBUG, "Creating session structure.\n"); session = calloc(1, sizeof(*session)); if (!session) { - PDEBUG(DCC, DEBUG_ERROR, "No mem!\n"); + LOGP(DCC, LOGL_ERROR, "No mem!\n"); abort(); } session->config = conf; @@ -56,7 +56,7 @@ osmo_cc_session_t *osmo_cc_new_session(osmo_cc_session_config_t *conf, void *pri int i; for (i = 0; username[i]; i++) { if ((uint8_t)username[i] < 33) { - PDEBUG(DCC, DEBUG_ERROR, "Fatal error: SDP's originator (username) uses invalid characters, please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Fatal error: SDP's originator (username) uses invalid characters, please fix!\n"); abort(); } } @@ -64,7 +64,7 @@ osmo_cc_session_t *osmo_cc_new_session(osmo_cc_session_config_t *conf, void *pri } if (!username) session->origin_local.username = strdup("-"); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> user name = %s\n", session->origin_local.username); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> user name = %s\n", session->origin_local.username); if (sess_id) session->origin_local.sess_id = strdup(sess_id); if (sess_version) @@ -80,35 +80,35 @@ osmo_cc_session_t *osmo_cc_new_session(osmo_cc_session_config_t *conf, void *pri if (!sess_version) session->origin_local.sess_version = strdup(ntp_timestamp); } - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> session ID = %s\n", session->origin_local.sess_id); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> session version = %s\n", session->origin_local.sess_version); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> session ID = %s\n", session->origin_local.sess_id); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> session version = %s\n", session->origin_local.sess_version); if (nettype) session->origin_local.nettype = strdup(osmo_cc_session_nettype2string(nettype)); else session->origin_local.nettype = strdup(osmo_cc_session_nettype2string(conf->default_nettype)); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> network type = %s\n", session->origin_local.nettype); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> network type = %s\n", session->origin_local.nettype); if (addrtype) session->origin_local.addrtype = strdup(osmo_cc_session_addrtype2string(addrtype)); else session->origin_local.addrtype = strdup(osmo_cc_session_addrtype2string(conf->default_addrtype)); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> address type = %s\n", session->origin_local.addrtype); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> address type = %s\n", session->origin_local.addrtype); if (unicast_address) session->origin_local.unicast_address = strdup(unicast_address); else session->origin_local.unicast_address = strdup(conf->default_unicast_address); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> unicast address = %s\n", session->origin_local.unicast_address); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> unicast address = %s\n", session->origin_local.unicast_address); if (session_name) session->name = strdup(session_name); if (!session_name) session->name = strdup("-"); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> session name = %s\n", session->name); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> session name = %s\n", session->name); return session; } void osmo_cc_free_session(osmo_cc_session_t *session) { - PDEBUG(DCC, DEBUG_DEBUG, "Free session structure.\n"); + LOGP(DCC, LOGL_DEBUG, "Free session structure.\n"); free((char *)session->origin_local.username); free((char *)session->origin_local.sess_id); @@ -135,7 +135,7 @@ osmo_cc_session_media_t *osmo_cc_add_media(osmo_cc_session_t *session, enum osmo media = calloc(1, sizeof(*media)); if (!media) { - PDEBUG(DCC, DEBUG_ERROR, "No mem!\n"); + LOGP(DCC, LOGL_ERROR, "No mem!\n"); abort(); } media->session = session; @@ -164,14 +164,14 @@ osmo_cc_session_media_t *osmo_cc_add_media(osmo_cc_session_t *session, enum osmo mediap = &((*mediap)->next); *mediap = media; - if (debug) PDEBUG(DCC, DEBUG_DEBUG, "Adding session media.\n"); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> network type = %s\n", osmo_cc_session_nettype2string(media->connection_data_local.nettype)); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> address type = %s\n", osmo_cc_session_addrtype2string(media->connection_data_local.addrtype)); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> address = %s\n", media->connection_data_local.address); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> media type = %s\n", osmo_cc_session_media_type2string(media->description.type)); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> media port = %d\n", media->description.port_local); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> media proto = %s\n", osmo_cc_session_media_proto2string(media->description.proto)); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, "Opening and binding media port %d\n", media->description.port_local); + if (debug) LOGP(DCC, LOGL_DEBUG, "Adding session media.\n"); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> network type = %s\n", osmo_cc_session_nettype2string(media->connection_data_local.nettype)); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> address type = %s\n", osmo_cc_session_addrtype2string(media->connection_data_local.addrtype)); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> address = %s\n", media->connection_data_local.address); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> media type = %s\n", osmo_cc_session_media_type2string(media->description.type)); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> media port = %d\n", media->description.port_local); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> media proto = %s\n", osmo_cc_session_media_proto2string(media->description.proto)); + if (debug) LOGP(DCC, LOGL_DEBUG, "Opening and binding media port %d\n", media->description.port_local); return media; } @@ -180,7 +180,7 @@ void osmo_cc_free_media(osmo_cc_session_media_t *media) { osmo_cc_session_media_t **mediap; - PDEBUG(DCC, DEBUG_DEBUG, "Free session media.\n"); + LOGP(DCC, LOGL_DEBUG, "Free session media.\n"); osmo_cc_rtp_close(media); free((char *)media->connection_data_local.nettype_name); @@ -205,7 +205,7 @@ osmo_cc_session_codec_t *osmo_cc_add_codec(osmo_cc_session_media_t *media, const codec = calloc(1, sizeof(*codec)); if (!codec) { - PDEBUG(DCC, DEBUG_ERROR, "No mem!\n"); + LOGP(DCC, LOGL_ERROR, "No mem!\n"); abort(); } codec->media = media; @@ -232,11 +232,11 @@ osmo_cc_session_codec_t *osmo_cc_add_codec(osmo_cc_session_media_t *media, const codecp = &((*codecp)->next); *codecp = codec; - if (debug) PDEBUG(DCC, DEBUG_DEBUG, "Adding session codec.\n"); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> payload type = %d\n", codec->payload_type_local); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> payload name = %s\n", codec->payload_name); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> payload rate = %d\n", codec->payload_rate); - if (debug) PDEBUG(DCC, DEBUG_DEBUG, " -> payload channels = %d\n", codec->payload_channels); + if (debug) LOGP(DCC, LOGL_DEBUG, "Adding session codec.\n"); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> payload type = %d\n", codec->payload_type_local); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> payload name = %s\n", codec->payload_name); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> payload rate = %d\n", codec->payload_rate); + if (debug) LOGP(DCC, LOGL_DEBUG, " -> payload channels = %d\n", codec->payload_channels); return codec; } @@ -245,7 +245,7 @@ void osmo_cc_free_codec(osmo_cc_session_codec_t *codec) { osmo_cc_session_codec_t **codecp; - PDEBUG(DCC, DEBUG_DEBUG, "Free session codec.\n"); + LOGP(DCC, LOGL_DEBUG, "Free session codec.\n"); free((char *)codec->payload_name); codecp = &codec->media->codec_list; @@ -274,15 +274,15 @@ int osmo_cc_session_check(osmo_cc_session_t *session, int remote) || !orig->nettype || !orig->addrtype || !orig->unicast_address) { - PDEBUG(DCC, DEBUG_NOTICE, "Missing data in session origin\n"); + LOGP(DCC, LOGL_NOTICE, "Missing data in session origin\n"); return -EINVAL; } if (!session->name) { - PDEBUG(DCC, DEBUG_NOTICE, "Missing data in session origin\n"); + LOGP(DCC, LOGL_NOTICE, "Missing data in session origin\n"); return -EINVAL; } if (!session->media_list) { - PDEBUG(DCC, DEBUG_NOTICE, "Missing media session\n"); + LOGP(DCC, LOGL_NOTICE, "Missing media session\n"); return -EINVAL; } i = 0; @@ -293,39 +293,39 @@ int osmo_cc_session_check(osmo_cc_session_t *session, int remote) else cd = &media->connection_data_local; if (!cd->nettype && !cd->nettype_name) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d is missing connection network type\n", i); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d is missing connection network type\n", i); return -EINVAL; } if (!cd->addrtype && !cd->addrtype_name) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d is missing connection address type\n", i); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d is missing connection address type\n", i); return -EINVAL; } if (!cd->address) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d is missing connection address\n", i); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d is missing connection address\n", i); return -EINVAL; } md = &media->description; if (!md->type && !md->type_name) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d is missing media type\n", i); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d is missing media type\n", i); return -EINVAL; } if (!md->proto && !md->proto_name) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d is missing protocol\n", i); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d is missing protocol\n", i); return -EINVAL; } j = 0; osmo_cc_session_for_each_codec(media->codec_list, codec) { j++; if (!codec->payload_name) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d, codec #%d is missing name\n", i, j); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d, codec #%d is missing name\n", i, j); return -EINVAL; } if (!codec->payload_rate) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d, codec #%d is missing rate\n", i, j); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d, codec #%d is missing rate\n", i, j); return -EINVAL; } if (!codec->payload_channels) { - PDEBUG(DCC, DEBUG_NOTICE, "Session with media #%d, codec #%d is missing channel count\n", i, j); + LOGP(DCC, LOGL_NOTICE, "Session with media #%d, codec #%d is missing channel count\n", i, j); return -EINVAL; } } @@ -340,11 +340,11 @@ const char *osmo_cc_session_send_offer(osmo_cc_session_t *session) const char *sdp; int rc; - PDEBUG(DCC, DEBUG_DEBUG, "Generating session offer and opening RTP stream.\n"); + LOGP(DCC, LOGL_DEBUG, "Generating session offer and opening RTP stream.\n"); rc = osmo_cc_session_check(session, 0); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "Please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Please fix!\n"); abort(); } @@ -359,7 +359,7 @@ osmo_cc_session_t *osmo_cc_session_receive_offer(osmo_cc_session_config_t *conf, osmo_cc_session_t *session; int rc; - PDEBUG(DCC, DEBUG_DEBUG, "Parsing session offer.\n"); + LOGP(DCC, LOGL_DEBUG, "Parsing session offer.\n"); osmo_cc_debug_sdp(sdp); session = osmo_cc_session_parsesdp(conf, priv, sdp); @@ -397,10 +397,10 @@ void osmo_cc_session_accept_media(osmo_cc_session_media_t *media, enum osmo_cc_s media->receive = receive; media->receiver = receiver; - PDEBUG(DCC, DEBUG_DEBUG, "Accepting session media.\n"); - PDEBUG(DCC, DEBUG_DEBUG, " -> network type = %s\n", osmo_cc_session_nettype2string(media->connection_data_local.nettype)); - PDEBUG(DCC, DEBUG_DEBUG, " -> address type = %s\n", osmo_cc_session_addrtype2string(media->connection_data_local.addrtype)); - PDEBUG(DCC, DEBUG_DEBUG, " -> address = %s\n", media->connection_data_local.address); + LOGP(DCC, LOGL_DEBUG, "Accepting session media.\n"); + LOGP(DCC, LOGL_DEBUG, " -> network type = %s\n", osmo_cc_session_nettype2string(media->connection_data_local.nettype)); + LOGP(DCC, LOGL_DEBUG, " -> address type = %s\n", osmo_cc_session_addrtype2string(media->connection_data_local.addrtype)); + LOGP(DCC, LOGL_DEBUG, " -> address = %s\n", media->connection_data_local.address); } @@ -412,11 +412,11 @@ void osmo_cc_session_accept_codec(osmo_cc_session_codec_t *codec, void (*encoder /* when we accept a codec, we just use the same payload type as the remote */ codec->payload_type_local = codec->payload_type_remote; - PDEBUG(DCC, DEBUG_DEBUG, "Accepting session codec.\n"); - PDEBUG(DCC, DEBUG_DEBUG, " -> payload type = %d\n", codec->payload_type_local); - PDEBUG(DCC, DEBUG_DEBUG, " -> payload name = %s\n", codec->payload_name); - PDEBUG(DCC, DEBUG_DEBUG, " -> payload rate = %d\n", codec->payload_rate); - PDEBUG(DCC, DEBUG_DEBUG, " -> payload channels = %d\n", codec->payload_channels); + LOGP(DCC, LOGL_DEBUG, "Accepting session codec.\n"); + LOGP(DCC, LOGL_DEBUG, " -> payload type = %d\n", codec->payload_type_local); + LOGP(DCC, LOGL_DEBUG, " -> payload name = %s\n", codec->payload_name); + LOGP(DCC, LOGL_DEBUG, " -> payload rate = %d\n", codec->payload_rate); + LOGP(DCC, LOGL_DEBUG, " -> payload channels = %d\n", codec->payload_channels); } /* remove codecs/media that have not been accepted and generate SDP */ @@ -427,7 +427,7 @@ const char *osmo_cc_session_send_answer(osmo_cc_session_t *session) const char *sdp; int rc; - PDEBUG(DCC, DEBUG_DEBUG, "Generating session answer.\n"); + LOGP(DCC, LOGL_DEBUG, "Generating session answer.\n"); /* loop all media */ osmo_cc_session_for_each_media(session->media_list, media) { @@ -450,7 +450,7 @@ const char *osmo_cc_session_send_answer(osmo_cc_session_t *session) rc = osmo_cc_session_check(session, 0); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "Please fix!\n"); + LOGP(DCC, LOGL_ERROR, "Please fix!\n"); abort(); } @@ -470,7 +470,7 @@ static int osmo_cc_session_negotiate(osmo_cc_session_t *session_local, struct os osmo_cc_session_codec_t *codec_local, *codec_remote, **codec_local_p; int rc; - PDEBUG(DCC, DEBUG_DEBUG, "Negotiating session.\n"); + LOGP(DCC, LOGL_DEBUG, "Negotiating session.\n"); /* copy remote session information */ session_local->origin_remote.username = strdup(session_remote->origin_remote.username); @@ -517,11 +517,11 @@ static int osmo_cc_session_negotiate(osmo_cc_session_t *session_local, struct os } } if (media_local) { - PDEBUG(DCC, DEBUG_NOTICE, "Negotiation failed, because remote endpoint returns less media streams than we offered.\n"); + LOGP(DCC, LOGL_NOTICE, "Negotiation failed, because remote endpoint returns less media streams than we offered.\n"); return -EINVAL; } if (media_remote) { - PDEBUG(DCC, DEBUG_NOTICE, "Negotiation failed, because remote endpoint returns more media streams than we offered.\n"); + LOGP(DCC, LOGL_NOTICE, "Negotiation failed, because remote endpoint returns more media streams than we offered.\n"); return -EINVAL; } @@ -550,7 +550,7 @@ int osmo_cc_session_receive_answer(osmo_cc_session_t *session, const char *sdp) osmo_cc_session_t *session_remote; int rc; - PDEBUG(DCC, DEBUG_DEBUG, "Parsing session answer.\n"); + LOGP(DCC, LOGL_DEBUG, "Parsing session answer.\n"); osmo_cc_debug_sdp(sdp); session_remote = osmo_cc_session_parsesdp(session->config, NULL, sdp); diff --git a/src/libosmocc/socket.c b/src/libosmocc/socket.c index d489fcf..9d8f30a 100644 --- a/src/libosmocc/socket.c +++ b/src/libosmocc/socket.c @@ -55,7 +55,7 @@ static int _getaddrinfo(const char *host, uint16_t port, struct addrinfo **resul rc = getaddrinfo(host, portstr, &hints, result); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "Failed to create socket for host '%s', port '%d': %s.\n", host, port, gai_strerror(rc)); + LOGP(DCC, LOGL_ERROR, "Failed to create socket for host '%s', port '%d': %s.\n", host, port, gai_strerror(rc)); return rc; } return rc; @@ -98,7 +98,7 @@ static void rx_keepalive_timeout(void *data) { osmo_cc_conn_t *conn = data; - PDEBUG(DCC, DEBUG_ERROR, "OsmoCC-Socket failed due to timeout.\n"); + LOGP(DCC, LOGL_ERROR, "OsmoCC-Socket failed due to timeout.\n"); close_conn(conn, OSMO_CC_SOCKET_CAUSE_TIMEOUT); } @@ -121,7 +121,7 @@ try_again: auto_port = 1; } - PDEBUG(DCC, DEBUG_DEBUG, "Create socket for host %s port %d.\n", host, port); + LOGP(DCC, LOGL_DEBUG, "Create socket for host %s port %d.\n", host, port); rc = _getaddrinfo(host, port, &result); if (rc < 0) @@ -140,17 +140,17 @@ try_again: freeaddrinfo(result); if (rp == NULL) { if (auto_port && port < OSMO_CC_DEFAULT_PORT_MAX) { - PDEBUG(DCC, DEBUG_DEBUG, "Failed to bind host %s port %d, trying again.\n", host, port); + LOGP(DCC, LOGL_DEBUG, "Failed to bind host %s port %d, trying again.\n", host, port); goto try_again; } - PDEBUG(DCC, DEBUG_ERROR, "Failed to bind given host %s port %d.\n", host, port); + LOGP(DCC, LOGL_ERROR, "Failed to bind given host %s port %d.\n", host, port); return -EIO; } /* listen to socket */ rc = listen(sock, 10); if (rc < 0) { - PDEBUG(DCC, DEBUG_ERROR, "Failed to listen on socket.\n"); + LOGP(DCC, LOGL_ERROR, "Failed to listen on socket.\n"); close(sock); return rc; } @@ -178,7 +178,7 @@ static osmo_cc_conn_t *open_conn(osmo_cc_socket_t *os, int sock, uint32_t callre /* create connection */ conn = calloc(1, sizeof(*conn)); if (!conn) { - PDEBUG(DCC, DEBUG_ERROR, "No mem!\n"); + LOGP(DCC, LOGL_ERROR, "No mem!\n"); abort(); } conn->os = os; @@ -200,7 +200,7 @@ static osmo_cc_conn_t *open_conn(osmo_cc_socket_t *os, int sock, uint32_t callre timer_start(&conn->tx_keepalive_timer, OSMO_CC_SOCKET_TX_KEEPALIVE); timer_start(&conn->rx_keepalive_timer, OSMO_CC_SOCKET_RX_KEEPALIVE); - PDEBUG(DCC, DEBUG_DEBUG, "New socket connection (callref %d).\n", conn->callref); + LOGP(DCC, LOGL_DEBUG, "New socket connection (callref %d).\n", conn->callref); /* attach to list */ connp = &os->conn_list; @@ -228,7 +228,7 @@ static void close_conn(osmo_cc_conn_t *conn, uint8_t socket_cause) rej_msg(conn->os, conn->callref, socket_cause, 0, 0); } - PDEBUG(DCC, DEBUG_DEBUG, "Destroy socket connection (callref %d).\n", conn->callref); + LOGP(DCC, LOGL_DEBUG, "Destroy socket connection (callref %d).\n", conn->callref); /* close socket */ if (conn->ofd.fd) { @@ -256,7 +256,7 @@ void osmo_cc_close_socket(osmo_cc_socket_t *os) { osmo_cc_msg_list_t *ml; - PDEBUG(DCC, DEBUG_DEBUG, "Destroy socket.\n"); + LOGP(DCC, LOGL_DEBUG, "Destroy socket.\n"); /* free all connections */ while (os->conn_list) @@ -317,12 +317,12 @@ static int receive_conn(osmo_cc_conn_t *conn) if (conn->read_version_pos == strlen(version_string)) { conn->read_version = 0; if (!!memcmp(conn->read_version_string, version_string, strlen(version_string) - 1)) { - PDEBUG(DCC, DEBUG_NOTICE, "Remote does not seem to be an Osmo-CC socket, rejecting!\n"); + LOGP(DCC, LOGL_NOTICE, "Remote does not seem to be an Osmo-CC socket, rejecting!\n"); socket_cause = OSMO_CC_SOCKET_CAUSE_FAILED; goto close; } if (conn->read_version_string[strlen(version_string) - 1] != version_string[strlen(version_string) - 1]) { - PDEBUG(DCC, DEBUG_NOTICE, "Remote Osmo-CC socket has wrong version (local=%s, remote=%s), rejecting!\n", version_string, conn->read_version_string); + LOGP(DCC, LOGL_NOTICE, "Remote Osmo-CC socket has wrong version (local=%s, remote=%s), rejecting!\n", version_string, conn->read_version_string); socket_cause = OSMO_CC_SOCKET_CAUSE_VERSION_MISMATCH; goto close; } @@ -382,7 +382,7 @@ empty_message: else conn->os->recv_msg_cb(conn->os->priv, conn->callref, msg); if (msg_type == OSMO_CC_MSG_REL_REQ || msg_type == OSMO_CC_MSG_REJ_REQ) { - PDEBUG(DCC, DEBUG_DEBUG, "closing socket because we received a release or reject message.\n"); + LOGP(DCC, LOGL_DEBUG, "closing socket because we received a release or reject message.\n"); close_conn(conn, 0); return 1; /* conn removed */ } @@ -391,7 +391,7 @@ empty_message: return work; close: - PDEBUG(DCC, DEBUG_ERROR, "OsmoCC-Socket failed, socket cause %d.\n", socket_cause); + LOGP(DCC, LOGL_ERROR, "OsmoCC-Socket failed, socket cause %d.\n", socket_cause); close_conn(conn, socket_cause); return work; /* conn removed */ } @@ -418,7 +418,7 @@ static int transmit_conn(osmo_cc_conn_t *conn) goto close; } if (rc != strlen(version_string)) { - PDEBUG(DCC, DEBUG_ERROR, "short write, please fix handling!\n"); + LOGP(DCC, LOGL_ERROR, "short write, please fix handling!\n"); abort(); } conn->write_version = 0; @@ -437,12 +437,12 @@ static int transmit_conn(osmo_cc_conn_t *conn) goto close; } if (rc != len) { - PDEBUG(DCC, DEBUG_ERROR, "short write, please fix handling!\n"); + LOGP(DCC, LOGL_ERROR, "short write, please fix handling!\n"); abort(); } /* close socket after sending release/reject message */ if (msg->type == OSMO_CC_MSG_REL_REQ || msg->type == OSMO_CC_MSG_REJ_REQ) { - PDEBUG(DCC, DEBUG_DEBUG, "closing socket because we sent a release or reject message.\n"); + LOGP(DCC, LOGL_DEBUG, "closing socket because we sent a release or reject message.\n"); close_conn(conn, 0); return work; /* conn removed */ } @@ -463,7 +463,7 @@ static int transmit_conn(osmo_cc_conn_t *conn) return work; close: - PDEBUG(DCC, DEBUG_NOTICE, "OsmoCC-Socket failed.\n"); + LOGP(DCC, LOGL_NOTICE, "OsmoCC-Socket failed.\n"); close_conn(conn, socket_cause); return work; /* conn removed */ } @@ -516,7 +516,7 @@ int osmo_cc_handle_socket(osmo_cc_socket_t *os) /* reject, if this is not a setup message */ if (ml->msg->type != OSMO_CC_MSG_SETUP_REQ && ml->msg->type != OSMO_CC_MSG_ATTACH_REQ) { - PDEBUG(DCC, DEBUG_ERROR, "Message with unknown callref.\n"); + LOGP(DCC, LOGL_ERROR, "Message with unknown callref.\n"); rej_msg(os, ml->callref, 0, OSMO_CC_ISDN_CAUSE_INVAL_CALLREF, 0); /* drop message */ osmo_cc_free_msg(ml->msg); @@ -550,7 +550,7 @@ int osmo_cc_handle_socket(osmo_cc_socket_t *os) } freeaddrinfo(result); if (rp == NULL) { - PDEBUG(DCC, DEBUG_ERROR, "Failed to connect to given host %s port %d.\n", ml->host, ml->port); + LOGP(DCC, LOGL_ERROR, "Failed to connect to given host %s port %d.\n", ml->host, ml->port); rej_msg(os, ml->callref, OSMO_CC_SOCKET_CAUSE_FAILED, 0, 0); /* drop message */ osmo_cc_free_msg(ml->msg);