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...
 

Functions

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.

Author
Husni Fahmi husni.nosp@m.fahm.nosp@m.i@out.nosp@m.look.nosp@m..com
Date
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.

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

Open database connection.

Parameters
usernameUsername used to open database connection.
passwordPassword used to open database connection.
dbnameName of database being opened.
Returns
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.

Parameters
recv_biomData packet from frontend.
biom_lengthSize of data packet (unused).
Returns
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.

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

Close message broker connection.

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

Open message broker connection.

Create a ZeroMQ socket for interprocess communication.

Parameters
contextZeroMQ context.
socket_typeSocket type which determines the semantics of communication over the socket.
identityBuffer to receive unique string identifying the connection.
Returns
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.

Parameters
connApplication's global storage.
client_addrClient address
recv_biomMain packet.
biom_lengthPacket's length.
Returns
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.

Parameters
connApplication global storage.
client_addrClient address
Returns
0 on success.