Biometric Middleware Server  0.0.1
Manage database management for biometrics and identification based on biometrics.
Data Structures | Functions
bio-midware.c File Reference

Biometric middleware server. More...

#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <assert.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <json-c/json.h>
#include <libpq-fe.h>
#include <zmq.h>
#include <inttypes.h>
#include "./dpfj.h"
#include "./fp-cmd.h"
#include "./biom.h"

Data Structures

struct  Connection
 Singleton that holds connection objects. More...
struct  BiodataMahasiswa
 Biodata mahasiswa. More...


int recv_client_address (struct Connection *conn, char *client_addr)
 Get client address. More...
int midware_bio_enroll (struct Connection *conn, const char *client_addr, const char *recv_biom, size_t biom_length)
 Intercept BIO_ENROLL messages. More...
struct BiodataMahasiswaget_biodata_mahasiswa (const char *recv_biom, size_t biom_length)
 Get BiodataMahasiswa. More...
int has_nik (const struct Connection *conn, const char *str_nik)
 Find NIK in database. More...
PGconn * db_open (const char *username, const char *password, const char *dbname)
 Open database connection. More...
void db_close (PGconn *conn)
 Close database connection. More...
void * mb_open (const void *context, int socket_type, char *identity)
 Open message broker connection. More...
void mb_close (void *conn)
 Close message broker connection. More...

Detailed Description

Biometric middleware server.

Husni Fahmi
14 May 2016

It receives BIO_ENROLL and BIO_SEARCH commands.

It manages database management for biometrics and identification based on biometrics.

Function Documentation

void db_close ( PGconn *  conn)

Close database connection.

connConnection object.
PGconn * db_open ( const char *  username,
const char *  password,
const char *  dbname 

Open database connection.

usernameUsername used to open database connection.
passwordPassword used to open database connection.
dbnameName of database being opened.
Connection object or NULL.
struct BiodataMahasiswa * get_biodata_mahasiswa ( const char *  recv_biom,
size_t  biom_length 

Get BiodataMahasiswa.

Parse packet received from client and retrieved BiodataMahasiswa. BiodataMahasiswa related data was json encoded.

recv_biomData packet from frontend.
biom_lengthSize of data packet (unused).
instance of struct BiodataMahasiswa or NULL, user is responsible for freeing the object.
int has_nik ( const struct Connection conn,
const char *  str_nik 

Find NIK in database.

Test if NIK (Nomor Induk Kemahasiswaan) was already registered in database.

connApplication's global storage.
str_nikNomor Induk Kemahasiswaan.
0 if not found, 1 if found, -1 if error.
void mb_close ( void *  conn)

Close message broker connection.

connZeroMQ socket
void * mb_open ( const void *  context,
int  socket_type,
char *  identity 

Open message broker connection.

Create a ZeroMQ socket for interprocess communication.

contextZeroMQ context.
socket_typeSocket type which determines the semantics of communication over the socket.
identityBuffer to receive unique string identifying the connection.
ZeroMQ socket or NULL.
int midware_bio_enroll ( struct Connection conn,
const char *  client_addr,
const char *  recv_biom,
size_t  biom_length 

Intercept BIO_ENROLL messages.

Register fingerprint.

connApplication's global storage.
client_addrClient address
recv_biomMain packet.
biom_lengthPacket's length.
0 if succeed.
int recv_client_address ( struct Connection conn,
char *  client_addr 

Get client address.

The first part of the message from client will be their address.

connApplication global storage.
client_addrClient address
0 on success.