}
}
if (i == httpd->max_connections) {
- logger_log(httpd->logger, LOGGER_INFO, "Max connections reached\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Max connections reached");
shutdown(fd, SHUT_RDWR);
closesocket(fd);
return;
continue;
} else if (ret == -1) {
/* FIXME: Error happened */
- logger_log(httpd->logger, LOGGER_INFO, "Error in select\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Error in select");
break;
}
continue;
}
- logger_log(httpd->logger, LOGGER_INFO, "Accepted client on socket %d\n", fd);
+ logger_log(httpd->logger, LOGGER_INFO, "Accepted client on socket %d", fd);
local = netutils_get_address(&local_saddr, &local_len);
remote = netutils_get_address(&remote_saddr, &remote_len);
assert(connection->request);
}
- logger_log(httpd->logger, LOGGER_DEBUG, "Receiving on socket %d\n", connection->socket_fd);
+ logger_log(httpd->logger, LOGGER_DEBUG, "Receiving on socket %d", connection->socket_fd);
ret = recv(connection->socket_fd, buffer, sizeof(buffer), 0);
if (ret == 0) {
- logger_log(httpd->logger, LOGGER_INFO, "Connection closed for socket %d\n", connection->socket_fd);
+ logger_log(httpd->logger, LOGGER_INFO, "Connection closed for socket %d", connection->socket_fd);
httpd_remove_connection(httpd, connection);
continue;
}
/* Parse HTTP request from data read from connection */
http_request_add_data(connection->request, buffer, ret);
if (http_request_has_error(connection->request)) {
- logger_log(httpd->logger, LOGGER_INFO, "Error in parsing: %s\n", http_request_get_error_name(connection->request));
+ logger_log(httpd->logger, LOGGER_INFO, "Error in parsing: %s", http_request_get_error_name(connection->request));
httpd_remove_connection(httpd, connection);
continue;
}
ret = send(connection->socket_fd, data+written, datalen-written, 0);
if (ret == -1) {
/* FIXME: Error happened */
- logger_log(httpd->logger, LOGGER_INFO, "Error in sending data\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Error in sending data");
break;
}
written += ret;
}
} else {
- logger_log(httpd->logger, LOGGER_INFO, "Didn't get response\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Didn't get response");
}
http_response_destroy(response);
}
if (!connection->connected) {
continue;
}
- logger_log(httpd->logger, LOGGER_INFO, "Removing connection for socket %d\n", connection->socket_fd);
+ logger_log(httpd->logger, LOGGER_INFO, "Removing connection for socket %d", connection->socket_fd);
httpd_remove_connection(httpd, connection);
}
- logger_log(httpd->logger, LOGGER_INFO, "Exiting HTTP thread\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Exiting HTTP thread");
return 0;
}
httpd->server_fd = netutils_init_socket(port, 1, 0);
if (httpd->server_fd == -1) {
- logger_log(httpd->logger, LOGGER_INFO, "Error initialising socket %d\n", SOCKET_GET_ERROR());
+ logger_log(httpd->logger, LOGGER_INFO, "Error initialising socket %d", SOCKET_GET_ERROR());
MUTEX_UNLOCK(httpd->run_mutex);
return -1;
}
if (listen(httpd->server_fd, 5) == -1) {
- logger_log(httpd->logger, LOGGER_INFO, "Error listening to socket\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Error listening to socket");
MUTEX_UNLOCK(httpd->run_mutex);
return -2;
}
- logger_log(httpd->logger, LOGGER_INFO, "Initialized server socket\n");
+ logger_log(httpd->logger, LOGGER_INFO, "Initialized server socket");
/* Set values correctly and create new thread */
httpd->running = 1;
{
assert(logger);
- logger->level = LOGGER_INFO;
+ logger->level = LOGGER_DEBUG;
logger->callback = NULL;
}
char *local = logger_utf8_to_local(buffer);
if (local) {
- fprintf(stderr, "%s", local);
+ fprintf(stderr, "%s\n", local);
free(local);
} else {
- fprintf(stderr, "%s", buffer);
+ fprintf(stderr, "%s\n", buffer);
}
}
}
if (locallen == 4) {
logger_log(&conn->raop->logger, LOGGER_INFO,
- "Local: %d.%d.%d.%d\n",
+ "Local: %d.%d.%d.%d",
local[0], local[1], local[2], local[3]);
} else if (locallen == 16) {
logger_log(&conn->raop->logger, LOGGER_INFO,
- "Local: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
+ "Local: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
local[0], local[1], local[2], local[3], local[4], local[5], local[6], local[7],
local[8], local[9], local[10], local[11], local[12], local[13], local[14], local[15]);
}
if (remotelen == 4) {
logger_log(&conn->raop->logger, LOGGER_INFO,
- "Remote: %d.%d.%d.%d\n",
+ "Remote: %d.%d.%d.%d",
remote[0], remote[1], remote[2], remote[3]);
} else if (remotelen == 16) {
logger_log(&conn->raop->logger, LOGGER_INFO,
- "Remote: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
+ "Remote: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
remote[0], remote[1], remote[2], remote[3], remote[4], remote[5], remote[6], remote[7],
remote[8], remote[9], remote[10], remote[11], remote[12], remote[13], remote[14], remote[15]);
}
authorization = http_request_get_header(request, "Authorization");
if (authorization) {
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Our nonce: %s\n", conn->nonce);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Authorization: %s\n", authorization);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Our nonce: %s", conn->nonce);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Authorization: %s", authorization);
}
if (!digest_is_valid("AppleTV", raop->password, conn->nonce, method, http_request_get_url(request), authorization)) {
char *authstr;
http_response_add_header(res, "WWW-Authenticate", authstr);
free(authstr);
} else {
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "AUTHENTICATION SUCCESS!\n");
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "AUTHENTICATION SUCCESS!");
}
}
conn->local, conn->locallen, raop->hwaddr, raop->hwaddrlen);
http_response_add_header(res, "Apple-Response", signature);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Got challenge: %s\n", challenge);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Got response: %s\n", signature);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Got challenge: %s", challenge);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Got response: %s", signature);
}
if (require_auth) {
aeskeystr = sdp_get_rsaaeskey(sdp);
aesivstr = sdp_get_aesiv(sdp);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "connection: %s\n", remotestr);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "fmtp: %s\n", fmtpstr);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "rsaaeskey: %s\n", aeskeystr);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "aesiv: %s\n", aesivstr);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "connection: %s", remotestr);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "fmtp: %s", fmtpstr);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "rsaaeskey: %s", aeskeystr);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "aesiv: %s", aesivstr);
aeskeylen = rsakey_decrypt(raop->rsakey, aeskey, sizeof(aeskey), aeskeystr);
aesivlen = rsakey_parseiv(raop->rsakey, aesiv, sizeof(aesiv), aesivstr);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "aeskeylen: %d\n", aeskeylen);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "aesivlen: %d\n", aesivlen);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "aeskeylen: %d", aeskeylen);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "aesivlen: %d", aesivlen);
if (conn->raop_rtp) {
/* This should never happen */
transport = http_request_get_header(request, "Transport");
assert(transport);
- logger_log(&conn->raop->logger, LOGGER_INFO, "Transport: %s\n", transport);
+ logger_log(&conn->raop->logger, LOGGER_INFO, "Transport: %s", transport);
use_udp = strncmp(transport, "RTP/AVP/TCP", 11);
if (use_udp) {
char *original, *current, *tmpstr;
ret = sscanf(tmpstr, "control_port=%hu", &value);
if (ret == 1) {
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Found remote control port: %hu\n", value);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Found remote control port: %hu", value);
remote_cport = value;
}
ret = sscanf(tmpstr, "timing_port=%hu", &value);
if (ret == 1) {
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Found remote timing port: %hu\n", value);
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Found remote timing port: %hu", value);
remote_tport = value;
}
}
"RTP/AVP/TCP;unicast;interleaved=0-1;mode=record;server_port=%u",
dport);
}
- logger_log(&conn->raop->logger, LOGGER_INFO, "Responding with %s\n", buffer);
+ logger_log(&conn->raop->logger, LOGGER_INFO, "Responding with %s", buffer);
http_response_add_header(res, "Transport", buffer);
http_response_add_header(res, "Session", "DEADBEEF");
} else if (!strcmp(method, "SET_PARAMETER")) {
rtpinfo = http_request_get_header(request, "RTP-Info");
if (rtpinfo) {
- logger_log(&conn->raop->logger, LOGGER_INFO, "Flush with RTP-Info: %s\n", rtpinfo);
+ logger_log(&conn->raop->logger, LOGGER_INFO, "Flush with RTP-Info: %s", rtpinfo);
if (!strncmp(rtpinfo, "seq=", 4)) {
next_seq = strtol(rtpinfo+4, NULL, 10);
}
}
http_response_finish(res, NULL, 0);
- logger_log(&conn->raop->logger, LOGGER_DEBUG, "Got request %s with URL %s\n", method, http_request_get_url(request));
+ logger_log(&conn->raop->logger, LOGGER_DEBUG, "Got request %s with URL %s", method, http_request_get_url(request));
*response = res;
}
addr = (struct sockaddr *)&raop_rtp->control_saddr;
addrlen = raop_rtp->control_saddr_len;
- logger_log(raop_rtp->logger, LOGGER_DEBUG, "Got resend request %d %d\n", seqnum, count);
+ logger_log(raop_rtp->logger, LOGGER_DEBUG, "Got resend request %d %d", seqnum, count);
ourseqnum = raop_rtp->control_seqnum++;
/* Fill the request buffer */
ret = sendto(raop_rtp->csock, (const char *)packet, sizeof(packet), 0, addr, addrlen);
if (ret == -1) {
- logger_log(raop_rtp->logger, LOGGER_WARNING, "Resend failed: %d\n", SOCKET_GET_ERROR());
+ logger_log(raop_rtp->logger, LOGGER_WARNING, "Resend failed: %d", SOCKET_GET_ERROR());
}
return 0;
if (packetlen >= 12) {
char type = packet[1] & ~0x80;
- logger_log(raop_rtp->logger, LOGGER_DEBUG, "Got control packet of type 0x%02x\n", type);
+ logger_log(raop_rtp->logger, LOGGER_DEBUG, "Got control packet of type 0x%02x", type);
if (type == 0x56) {
/* Handle resent data packet */
int ret = raop_buffer_queue(raop_rtp->buffer, packet+4, packetlen-4, 1);
}
}
} else if (FD_ISSET(raop_rtp->tsock, &rfds)) {
- logger_log(raop_rtp->logger, LOGGER_INFO, "Would have timing packet in queue\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Would have timing packet in queue");
} else if (FD_ISSET(raop_rtp->dsock, &rfds)) {
saddrlen = sizeof(saddr);
packetlen = recvfrom(raop_rtp->dsock, (char *)packet, sizeof(packet), 0,
}
}
}
- logger_log(raop_rtp->logger, LOGGER_INFO, "Exiting UDP RAOP thread\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Exiting UDP RAOP thread");
raop_rtp->callbacks.audio_destroy(raop_rtp->callbacks.cls, cb_data);
return 0;
continue;
} else if (ret == -1) {
/* FIXME: Error happened */
- logger_log(raop_rtp->logger, LOGGER_INFO, "Error in select\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Error in select");
break;
}
if (stream_fd == -1 && FD_ISSET(raop_rtp->dsock, &rfds)) {
struct sockaddr_storage saddr;
socklen_t saddrlen;
- logger_log(raop_rtp->logger, LOGGER_INFO, "Accepting client\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Accepting client");
saddrlen = sizeof(saddr);
stream_fd = accept(raop_rtp->dsock, (struct sockaddr *)&saddr, &saddrlen);
if (stream_fd == -1) {
/* FIXME: Error happened */
- logger_log(raop_rtp->logger, LOGGER_INFO, "Error in accept %d %s\n", errno, strerror(errno));
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Error in accept %d %s", errno, strerror(errno));
break;
}
}
ret = recv(stream_fd, (char *)(packet+packetlen), sizeof(packet)-packetlen, 0);
if (ret == 0) {
/* TCP socket closed */
- logger_log(raop_rtp->logger, LOGGER_INFO, "TCP socket closed\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "TCP socket closed");
break;
} else if (ret == -1) {
/* FIXME: Error happened */
- logger_log(raop_rtp->logger, LOGGER_INFO, "Error in recv\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Error in recv");
break;
}
packetlen += ret;
rtplen = (packet[2] << 8) | packet[3];
if (rtplen > sizeof(packet)) {
/* FIXME: Too long packet */
- logger_log(raop_rtp->logger, LOGGER_INFO, "Error, packet too long %d\n", rtplen);
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Error, packet too long %d", rtplen);
break;
}
if (packetlen < 4+rtplen) {
closesocket(stream_fd);
}
- logger_log(raop_rtp->logger, LOGGER_INFO, "Exiting TCP RAOP thread\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Exiting TCP RAOP thread");
raop_rtp->callbacks.audio_destroy(raop_rtp->callbacks.cls, cb_data);
return 0;
use_ipv6 = 1;
}
if (raop_rtp_init_sockets(raop_rtp, use_ipv6, use_udp) < 0) {
- logger_log(raop_rtp->logger, LOGGER_INFO, "Initializing sockets failed\n");
+ logger_log(raop_rtp->logger, LOGGER_INFO, "Initializing sockets failed");
MUTEX_UNLOCK(raop_rtp->run_mutex);
return;
}