summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/dbus-adapter.c1
-rw-r--r--hcid/dbus-error.c6
-rw-r--r--hcid/dbus-manager.c15
-rw-r--r--hcid/device.c45
-rw-r--r--hcid/hcid.h5
-rw-r--r--hcid/parser.y5
-rw-r--r--hcid/sdp.c20
-rw-r--r--hcid/security.c35
8 files changed, 54 insertions, 78 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 41cd1037..ff756023 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <syslog.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
diff --git a/hcid/dbus-error.c b/hcid/dbus-error.c
index c93b103c..4da6a9fd 100644
--- a/hcid/dbus-error.c
+++ b/hcid/dbus-error.c
@@ -116,13 +116,13 @@ static const char *bluez_dbus_error_to_str(const uint32_t ecode)
if (ecode & BLUEZ_ESYSTEM_OFFSET) {
/* System error */
raw_code = (~BLUEZ_ESYSTEM_OFFSET) & ecode;
- syslog(LOG_INFO, "%s - msg:%s", __PRETTY_FUNCTION__, strerror(raw_code));
+ info("%s - msg:%s", __PRETTY_FUNCTION__, strerror(raw_code));
return strerror(raw_code);
} else if (ecode & BLUEZ_EDBUS_OFFSET) {
/* D-Bus error */
for (ptr = dbus_error_array; ptr->code; ptr++) {
if (ptr->code == ecode) {
- syslog(LOG_INFO, "%s - msg:%s", __PRETTY_FUNCTION__, ptr->str);
+ info("%s - msg:%s", __PRETTY_FUNCTION__, ptr->str);
return ptr->str;
}
}
@@ -130,7 +130,7 @@ static const char *bluez_dbus_error_to_str(const uint32_t ecode)
/* BLUEZ_EBT_OFFSET - Bluetooth HCI errors */
for (ptr = hci_error_array; ptr->code; ptr++) {
if (ptr->code == ecode) {
- syslog(LOG_INFO, "%s - msg:%s", __PRETTY_FUNCTION__, ptr->str);
+ info("%s - msg:%s", __PRETTY_FUNCTION__, ptr->str);
return ptr->str;
}
}
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index 784266fd..ad04f862 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -139,15 +139,14 @@ DBusHandlerResult msg_func_manager(DBusConnection *conn, DBusMessage *msg, void
const char *iface;
const char *method;
const char *signature;
- uint32_t error = BLUEZ_EDBUS_UNKNOWN_METHOD;
+ uint32_t err = BLUEZ_EDBUS_UNKNOWN_METHOD;
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
iface = dbus_message_get_interface(msg);
method = dbus_message_get_member(msg);
signature = dbus_message_get_signature(msg);
- syslog(LOG_INFO, "Manager path:%s method:%s",
- dbus_message_get_path(msg), method);
+ info("Manager path:%s method:%s", dbus_message_get_path(msg), method);
if (strcmp(iface, MANAGER_INTERFACE))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -157,21 +156,21 @@ DBusHandlerResult msg_func_manager(DBusConnection *conn, DBusMessage *msg, void
continue;
if (strcmp(handlers->signature, signature) != 0)
- error = BLUEZ_EDBUS_WRONG_SIGNATURE;
+ err = BLUEZ_EDBUS_WRONG_SIGNATURE;
else {
reply = handlers->handler_func(msg, data);
- error = 0;
+ err = 0;
}
ret = DBUS_HANDLER_RESULT_HANDLED;
}
- if (error)
- reply = bluez_new_failure_msg(msg, error);
+ if (err)
+ reply = bluez_new_failure_msg(msg, err);
if (reply) {
if (!dbus_connection_send (conn, reply, NULL))
- syslog(LOG_ERR, "Can't send reply message");
+ error("Can't send reply message");
dbus_message_unref(reply);
}
diff --git a/hcid/device.c b/hcid/device.c
index f81ac693..b67f87a7 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -29,7 +29,6 @@
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
-#include <syslog.h>
#include <string.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -39,6 +38,8 @@
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
+#include "hcid.h"
+
#include "textfile.h"
#include "oui.h"
@@ -87,28 +88,6 @@ static struct hci_dev devices[MAX_DEVICES];
#define ASSERT_DEV_ID { if (dev_id >= MAX_DEVICES) return -ERANGE; }
-static void info(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
-
- vsyslog(LOG_INFO, format, ap);
-
- va_end(ap);
-}
-
-static void err(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
-
- vsyslog(LOG_ERR, format, ap);
-
- va_end(ap);
-}
-
void init_devices(void)
{
int i;
@@ -164,13 +143,13 @@ int start_device(uint16_t dev_id)
dd = hci_open_dev(dev_id);
if (dd < 0) {
- err("Can't open device hci%d",
+ error("Can't open device hci%d",
dev_id, strerror(errno), errno);
return -errno;
}
if (hci_read_local_version(dd, &ver, 1000) < 0) {
- err("Can't read version info for hci%d: %s (%d)",
+ error("Can't read version info for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
return -errno;
}
@@ -213,13 +192,13 @@ int get_device_address(uint16_t dev_id, char *address, size_t size)
dd = hci_open_dev(dev_id);
if (dd < 0) {
- err("Can't open device hci%d",
+ error("Can't open device hci%d",
dev_id, strerror(errno), errno);
return -errno;
}
if (hci_read_bd_addr(dd, &dev->bdaddr, 2000) < 0) {
- err("Can't read address for hci%d: %s (%d)",
+ error("Can't read address for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
return -errno;
}
@@ -269,7 +248,7 @@ static int digi_revision(uint16_t dev_id, char *revision, size_t size)
dd = hci_open_dev(dev_id);
if (dd < 0) {
- err("Can't open device hci%d",
+ error("Can't open device hci%d",
dev_id, strerror(errno), errno);
return -errno;
}
@@ -283,7 +262,7 @@ static int digi_revision(uint16_t dev_id, char *revision, size_t size)
rq.rlen = sizeof(buf);
if (hci_send_req(dd, &rq, 2000) < 0) {
- err("Can't read revision for hci%d: %s (%d)",
+ error("Can't read revision for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
return -errno;
}
@@ -361,13 +340,13 @@ int get_device_name(uint16_t dev_id, char *name, size_t size)
dd = hci_open_dev(dev_id);
if (dd < 0) {
- err("Can't open device hci%d",
+ error("Can't open device hci%d",
dev_id, strerror(errno), errno);
return -errno;
}
if (hci_read_local_name(dd, sizeof(tmp), tmp, 2000) < 0) {
- err("Can't read name for hci%d: %s (%d)",
+ error("Can't read name for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
return -errno;
}
@@ -387,13 +366,13 @@ int set_device_name(uint16_t dev_id, const char *name)
dd = hci_open_dev(dev_id);
if (dd < 0) {
- err("Can't open device hci%d",
+ error("Can't open device hci%d",
dev_id, strerror(errno), errno);
return -errno;
}
if (hci_write_local_name(dd, name, 5000) < 0) {
- err("Can't read name for hci%d: %s (%d)",
+ error("Can't read name for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
return -errno;
}
diff --git a/hcid/hcid.h b/hcid/hcid.h
index f25ebea8..1483c6ba 100644
--- a/hcid/hcid.h
+++ b/hcid/hcid.h
@@ -24,7 +24,6 @@
*/
#include <time.h>
-#include <syslog.h>
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -189,7 +188,7 @@ static inline int find_conn(int dd, int dev_id, long arg)
cl = malloc(10 * sizeof(*ci) + sizeof(*cl));
if (!cl) {
- syslog(LOG_ERR, "Can't allocate memory");
+ error("Can't allocate memory");
return 0;
}
@@ -198,7 +197,7 @@ static inline int find_conn(int dd, int dev_id, long arg)
ci = cl->conn_info;
if (ioctl(dd, HCIGETCONNLIST, (void *) cl)) {
- syslog(LOG_ERR, "Can't get connection list");
+ error("Can't get connection list");
return 0;
}
diff --git a/hcid/parser.y b/hcid/parser.y
index 2697559f..60dd986f 100644
--- a/hcid/parser.y
+++ b/hcid/parser.y
@@ -32,7 +32,6 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include <syslog.h>
#include <stdarg.h>
#include <sys/socket.h>
@@ -317,7 +316,7 @@ bool: K_YES { $$ = 1; } | K_NO { $$ = 0; };
int yyerror(char *s)
{
- syslog(LOG_ERR, "%s line %d", s, lineno);
+ error("%s line %d", s, lineno);
return 0;
}
@@ -342,7 +341,7 @@ int read_config(char *file)
extern FILE *yyin;
if (!(yyin = fopen(file, "r"))) {
- syslog(LOG_ERR,"Can not open %s", file);
+ error("Can't open config file %s", file);
return -1;
}
diff --git a/hcid/sdp.c b/hcid/sdp.c
index 22ac4211..8837c436 100644
--- a/hcid/sdp.c
+++ b/hcid/sdp.c
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
-#include <syslog.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
@@ -39,6 +38,7 @@
#include "glib-ectomy.h"
+#include "hcid.h"
#include "sdp.h"
struct session {
@@ -50,7 +50,7 @@ static void session_destory(gpointer data)
{
struct session *session_data = data;
- syslog(LOG_DEBUG, "Cleanup of SDP session");
+ debug("Cleanup of SDP session");
if (session_data)
free(session_data);
@@ -67,7 +67,7 @@ static gboolean session_event(GIOChannel *chan, GIOCondition cond, gpointer data
if (cond & (G_IO_HUP | G_IO_ERR))
return FALSE;
- syslog(LOG_DEBUG, "Incoming SDP transaction");
+ debug("Incoming SDP transaction");
err = g_io_channel_read(chan, (gchar *) buf, sizeof(buf), &len);
if (err == G_IO_ERROR_AGAIN)
@@ -95,7 +95,7 @@ static gboolean connect_event(GIOChannel *chan, GIOCondition cond, gpointer data
socklen_t optlen;
int sk, nsk;
- syslog(LOG_DEBUG, "Incoming SDP connection");
+ debug("Incoming SDP connection");
sk = g_io_channel_unix_get_fd(chan);
@@ -104,7 +104,7 @@ static gboolean connect_event(GIOChannel *chan, GIOCondition cond, gpointer data
nsk = accept(sk, (struct sockaddr *) &addr, &optlen);
if (nsk < 0) {
- syslog(LOG_ERR, "Can't accept L2CAP connection: %s (%d)",
+ error("Can't accept L2CAP connection: %s (%d)",
strerror(errno), errno);
return TRUE;
}
@@ -113,7 +113,7 @@ static gboolean connect_event(GIOChannel *chan, GIOCondition cond, gpointer data
optlen = sizeof(opts);
if (getsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &opts, &optlen) < 0) {
- syslog(LOG_ERR, "Can't get L2CAP options: %s (%d)",
+ error("Can't get L2CAP options: %s (%d)",
strerror(errno), errno);
close(nsk);
return TRUE;
@@ -144,11 +144,11 @@ int start_sdp_server(void)
struct sockaddr_l2 addr;
int sk;
- syslog(LOG_INFO, "Starting SDP server");
+ info("Starting SDP server");
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
if (sk < 0) {
- syslog(LOG_ERR, "Can't open L2CAP socket: %s (%d)",
+ error("Can't open L2CAP socket: %s (%d)",
strerror(errno), errno);
return -errno;
}
@@ -159,7 +159,7 @@ int start_sdp_server(void)
addr.l2_psm = htobs(1);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- syslog(LOG_ERR, "Can't bind L2CAP socket: %s (%d)",
+ error("Can't bind L2CAP socket: %s (%d)",
strerror(errno), errno);
return -errno;
}
@@ -175,5 +175,5 @@ int start_sdp_server(void)
void stop_sdp_server(void)
{
- syslog(LOG_INFO, "Stopping SDP server");
+ info("Stopping SDP server");
}
diff --git a/hcid/security.c b/hcid/security.c
index 02cc8ed8..0c8fd777 100644
--- a/hcid/security.c
+++ b/hcid/security.c
@@ -36,7 +36,6 @@
#include <malloc.h>
#include <string.h>
#include <signal.h>
-#include <syslog.h>
#include <time.h>
#include <sys/time.h>
#include <sys/ioctl.h>
@@ -68,7 +67,7 @@ void toggle_pairing(int enable)
else
pairing = 0;
- syslog(LOG_INFO, "Pairing %s", pairing ? "enabled" : "disabled");
+ info("Pairing %s", pairing ? "enabled" : "disabled");
}
static inline int get_bdaddr(int dev, bdaddr_t *sba, uint16_t handle, bdaddr_t *dba)
@@ -134,7 +133,7 @@ static void link_key_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
int err;
ba2str(sba, sa); ba2str(dba, da);
- syslog(LOG_INFO, "link_key_request (sba=%s, dba=%s)", sa, da);
+ info("link_key_request (sba=%s, dba=%s)", sa, da);
err = read_link_key(sba, dba, key);
if (err < 0) {
@@ -158,7 +157,7 @@ static void link_key_notify(int dev, bdaddr_t *sba, void *ptr)
int dev_id;
ba2str(sba, sa); ba2str(dba, da);
- syslog(LOG_INFO, "link_key_notify (sba=%s, dba=%s)", sa, da);
+ info("link_key_notify (sba=%s, dba=%s)", sa, da);
dev_id = hci_devid(sa);
@@ -184,7 +183,7 @@ static void return_link_keys(int dev, bdaddr_t *sba, void *ptr)
bacpy(&dba, ptr); ba2str(&dba, da);
memcpy(key, ptr + 6, 16);
- syslog(LOG_INFO, "return_link_keys (sba=%s, dba=%s)", sa, da);
+ info("return_link_keys (sba=%s, dba=%s)", sa, da);
ptr += 22;
}
@@ -225,14 +224,14 @@ static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
case 0:
break;
case -1:
- syslog(LOG_ERR, "Can't fork PIN helper: %s (%d)",
+ error("Can't fork PIN helper: %s (%d)",
strerror(errno), errno);
default:
return;
}
if (access(hcid.pin_helper, R_OK | X_OK)) {
- syslog(LOG_ERR, "Can't exec PIN helper %s: %s (%d)",
+ error("Can't exec PIN helper %s: %s (%d)",
hcid.pin_helper, strerror(errno), errno);
goto reject;
}
@@ -277,7 +276,7 @@ static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
pipe = popen(str, "r");
if (!pipe) {
- syslog(LOG_ERR, "Can't exec PIN helper: %s (%d)",
+ error("Can't exec PIN helper: %s (%d)",
strerror(errno), errno);
goto reject;
}
@@ -308,7 +307,7 @@ static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
nopin:
if (!pin || strncmp("ERR", pin, 3))
- syslog(LOG_ERR, "PIN helper exited abnormally with code %d", ret);
+ error("PIN helper exited abnormally with code %d", ret);
reject:
hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, &ci->bdaddr);
@@ -339,7 +338,7 @@ static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
bacpy(&pr.bdaddr, dba);
ba2str(sba, sa); ba2str(dba, da);
- syslog(LOG_INFO, "pin_code_request (sba=%s, dba=%s)", sa, da);
+ info("pin_code_request (sba=%s, dba=%s)", sa, da);
cr = malloc(sizeof(*cr) + sizeof(*ci));
if (!cr)
@@ -348,7 +347,7 @@ static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
bacpy(&cr->bdaddr, dba);
cr->type = ACL_LINK;
if (ioctl(dev, HCIGETCONNINFO, (unsigned long) cr) < 0) {
- syslog(LOG_ERR, "Can't get conn info: %s (%d)",
+ error("Can't get conn info: %s (%d)",
strerror(errno), errno);
goto reject;
}
@@ -361,7 +360,7 @@ static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
err = read_link_key(sba, dba, key);
if (!err) {
ba2str(dba, da);
- syslog(LOG_WARNING, "PIN code request for already paired device %s", da);
+ error("PIN code request for already paired device %s", da);
goto reject;
}
} else if (pairing == HCID_PAIRING_NONE)
@@ -729,10 +728,10 @@ void start_security_manager(int hdev)
if (chan)
return;
- syslog(LOG_INFO, "Starting security manager %d", hdev);
+ info("Starting security manager %d", hdev);
if ((dev = hci_open_dev(hdev)) < 0) {
- syslog(LOG_ERR, "Can't open device hci%d: %s (%d)",
+ error("Can't open device hci%d: %s (%d)",
hdev, strerror(errno), errno);
return;
}
@@ -757,7 +756,7 @@ void start_security_manager(int hdev)
hci_filter_set_event(EVT_DISCONN_COMPLETE, &flt);
hci_filter_set_event(EVT_AUTH_COMPLETE, &flt);
if (setsockopt(dev, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
- syslog(LOG_ERR, "Can't set filter on hci%d: %s (%d)",
+ error("Can't set filter on hci%d: %s (%d)",
hdev, strerror(errno), errno);
close(dev);
return;
@@ -765,7 +764,7 @@ void start_security_manager(int hdev)
di = malloc(sizeof(*di));
if (!di) {
- syslog(LOG_ERR, "Can't allocate device info buffer: %s (%d)",
+ error("Can't allocate device info buffer: %s (%d)",
strerror(errno), errno);
close(dev);
return;
@@ -773,7 +772,7 @@ void start_security_manager(int hdev)
di->dev_id = hdev;
if (ioctl(dev, HCIGETDEVINFO, (void *)di)) {
- syslog(LOG_ERR, "Can't get device info: %s (%d)",
+ error("Can't get device info: %s (%d)",
strerror(errno), errno);
close(dev);
return;
@@ -803,7 +802,7 @@ void stop_security_manager(int hdev)
if (!chan)
return;
- syslog(LOG_INFO, "Stoping security manager %d", hdev);
+ info("Stoping security manager %d", hdev);
/* this is a bit sneaky. closing the fd will cause the event
loop to call us right back with G_IO_NVAL set, at which