#ifndef LIBCLIENT_H
#define LIBCLIENT_H

#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>

#include "config.h"


/*** int ns_bind( char*, struct in_addr*, char*, int )
 ***
 *** Function: connects a nameserver at ns_addr:port and insert
 ***           the given data into the namespace
 *** Return:  0  ok
 ***         -1  error
 ***/ 
int ns_bind( char *name, struct in_addr* ip, char* ns_addr, int port );

/*** in_addr* resolve_name( char*, char *, int )
 ***
 *** Function: connect to nameserver at ns_addr:port and request
 ***           the ip address for the given name.
 *** Return:  in_addr format of ip address
 ***          NULL if ip address is not bound
 ***/
struct in_addr* ns_resolve_name( char* name, char *ns_addr, int port );


/*** char* resolve_ip( struct in_addr*, char *, int )
 ***
 *** Function: connect to nameserver at ns_addr:port and request
 ***           the hostname for the given ip address.
 *** Return:  char* representing the hostname for ip address
 ***          NULL if name is not bound
 ***/
char* ns_resolve_ip( struct in_addr* ip, char *ns_addr, int port );


/*** int delete( struct in_addr*, char *, int )
 ***
 *** Function: connect to nameserver at ns_addr:port and delete
 ***           the namespace entry for the given ip address.
 *** Return:  0  successfully deleted
 ***         -1  error deleting the entry
 ***/
int ns_delete( struct in_addr* ip, char *ns_addr, int port );


#endif // LIBCLIENT_H
