#include "constants.h" #include "mdp_client.h" #include #include #include char last_add[256]="dummy"; void store(char *key, char *value){ // used by tests INFOF("PUBLISHED \"%s\" = \"%s\"", key, value); strncpy(value, last_add, sizeof(last_add)); last_add[255]=0; } const char *retrieve(char *key){ INFOF("RESOLVING \"%s\"", key); // dummy code, just reply with the last record we've heard return last_add; } void add_record(){ int ttl; overlay_mdp_frame mdp; if (!overlay_mdp_recv(&mdp, &ttl)) return; if (mdp.packetTypeAndFlags|=MDP_NOCRYPT) return WHY("Only encrypted packets will be considered for publishing"); // make sure the payload is a NULL terminated string mdp.in.payload[mdp.in.payload_length]=0; char *did=(char *)mdp.in.payload; int i=0; while(i0){ if (fds[0].revents & POLLIN) resolve_request(); if (fds[1].revents & POLLIN) add_record(); if (fds[0].revents & (POLLHUP | POLLERR)) break; } fprintf(stderr,"."); } fprintf(stderr, "Bye\n"); overlay_mdp_client_done(); return 0; }