Пример #1
0
gboolean process_comming_request(GIOChannel *gio, GIOCondition condition, gpointer data)
{
	int ret;

	if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
		g_error("unknown condition");


	if (condition & G_IO_IN) {
		int lsock;
		int csock;

		lsock = g_io_channel_unix_get_fd(gio);

		csock = my_accept(lsock);
		if (csock < 0)
			return TRUE;

		ret = recv_pdu(csock);
		if (ret < 0)
			err("process recieved pdu");

		close(csock);
	}

	return TRUE;
}
Пример #2
0
int process_request(int listenfd)
{
	pid_t childpid;
	int connfd;

	connfd = do_accept(listenfd);
	if (connfd < 0)
		return -1;
	childpid = fork();
	if (childpid == 0) {
		close(listenfd);
		recv_pdu(connfd);
		exit(0);
	}
	close(connfd);
	return 0;
}
Пример #3
0
static void recv_response(struct ste_message *msg)
{
    uint32_t status;
    uint8_t *param;

    DBG_VERBOSE("msg_id 0x%x", msg->id);

    if (msg->id == STE_END_SAP_RSP) {
        sap_disconnect_rsp(u8500.sap_data);
        simd_close();
        return;
    }

    param = msg->payload;
    status = *(uint32_t *)param;
    param += sizeof(status);

    DBG_VERBOSE("status 0x%x", status);

    switch (msg->id) {
    case STE_START_SAP_RSP:
        if (status == STE_STATUS_OK) {
            sap_connect_rsp(u8500.sap_data, SAP_STATUS_OK, 0);
        } else {
            sap_connect_rsp(u8500.sap_data,
                            SAP_STATUS_CONNECTION_FAILED, 0);
            simd_close();
        }
        break;

    case STE_SEND_APDU_RSP:
        recv_pdu(STE_SEND_APDU_MSG, msg, status, param,
                 sap_transfer_apdu_rsp);
        break;

    case STE_GET_ATR_RSP:
        recv_pdu(STE_GET_ATR_MSG, msg, status, param,
                 sap_transfer_atr_rsp);
        break;

    case STE_POWER_OFF_RSP:
        recv_state_change(STE_POWER_OFF_MSG, status, STE_POWERED_OFF,
                          sap_power_sim_off_rsp);
        break;

    case STE_POWER_ON_RSP:
        recv_state_change(STE_POWER_ON_MSG, status, STE_ENABLED,
                          sap_power_sim_on_rsp);
        break;

    case STE_RESET_RSP:
        recv_state_change(STE_RESET_MSG, status, STE_ENABLED,
                          sap_reset_sim_rsp);
        break;

    case STE_GET_STATUS_RSP:
        recv_card_status(status, param);
        break;

    case STE_STATUS_IND:
        recv_status(status);
        break;

    default:
        sap_error("unsupported message received (id 0x%x)", msg->id);
    }
}