static int service_level_connection(struct ofono_modem *modem, int fd, guint16 version) { struct hfp *hfp = ofono_modem_get_data(modem); struct hfp_slc_info *info = &hfp->info; GIOChannel *io; GAtSyntax *syntax; GAtChat *chat; io = g_io_channel_unix_new(fd); syntax = g_at_syntax_new_gsm_permissive(); chat = g_at_chat_new(io, syntax); g_at_syntax_unref(syntax); g_io_channel_set_close_on_unref(io, TRUE); g_io_channel_unref(io); if (chat == NULL) return -ENOMEM; g_at_chat_set_disconnect_function(chat, hfp_disconnected_cb, modem); if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, hfp_debug, ""); hfp_slc_info_init(info, version); info->chat = chat; hfp_slc_establish(info, slc_established, slc_failed, modem); return -EINPROGRESS; }
static int localhfp_enable(struct ofono_modem *modem) { struct hfp_slc_info *info = ofono_modem_get_data(modem); GIOChannel *io; GAtSyntax *syntax; GAtChat *chat; const char *address; int sk, port; address = ofono_modem_get_string(modem, "Address"); if (address == NULL) return -EINVAL; port = ofono_modem_get_integer(modem, "Port"); if (port < 0) return -EINVAL; sk = connect_socket(address, port); if (sk < 0) return sk; io = g_io_channel_unix_new(sk); if (io == NULL) { close(sk); return -ENOMEM; } syntax = g_at_syntax_new_gsmv1(); chat = g_at_chat_new(io, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(io); if (chat == NULL) return -ENOMEM; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, phonesim_debug, "LocalHfp: "); g_at_chat_set_disconnect_function(chat, slc_failed, modem); hfp_slc_info_init(info, HFP_VERSION_LATEST); info->chat = chat; hfp_slc_establish(info, slc_established, slc_failed, modem); return -EINPROGRESS; }
static DBusMessage *hfp_agent_new_connection(DBusConnection *conn, DBusMessage *msg, void *data) { int fd, err; struct ofono_modem *modem = data; struct hfp_data *hfp_data = ofono_modem_get_data(modem); guint16 version; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_UINT16, &version, DBUS_TYPE_INVALID)) return __ofono_error_invalid_args(msg); hfp_slc_info_init(&hfp_data->info, version); err = service_level_connection(modem, fd); if (err < 0 && err != -EINPROGRESS) return __ofono_error_failed(msg); hfp_data->slc_msg = msg; dbus_message_ref(msg); return NULL; }