All of these are subject to change, as the API isn't remotely stable yet.
void main() {
.tag = { .upper = 0xFFFFFFFFFFFFFFFF, .lower = 0 },
.valuesz = 8,
.value = "hello!!!"
};
.paircnt = 1,
.pairs = &pair
};
uint8_t signature[4] = { 0x12, 0x34, 0x56, 0x78 };
};
fprintf(stderr, "\nWrote %d bytes\n", n);
}
Services, records and tags.
int sprkl_service_write(struct sprkl_service *service, FILE *stream)
Encodes and writes a service in wire format to a stream.
Definition service.c:6
A record, made up of multiple tag-value pairs.
Definition service.h:25
A service, contains a collection of related records and is cryptographically signed.
Definition service.h:32
struct sprkl_record * records
Array of records.
Definition service.h:41
uint8_t * signature
Signature (no terminator).
Definition service.h:34
uint32_t flags
Flags (bitfield).
Definition service.h:39
uint16_t index
Service index within its zone.
Definition service.h:35
uint16_t reccnt
Number of records in the service.
Definition service.h:40
A tag-value pair, contains one labelled piece of data.
Definition service.h:18
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
int main(int argc, char** argv) {
if (argc != 3) {
fprintf(stderr, "usage: %s <inet4-addr> <tcp-port>\n", argv[0]);
return 1;
}
uint8_t key[0x20] = {
0xc5, 0x82, 0x1e, 0x05, 0x34, 0x80, 0x17, 0x25,
0x3c, 0xfc, 0x80, 0x87, 0x0b, 0xca, 0x03, 0xed,
0x0a, 0x8b, 0x93, 0xbc, 0x33, 0x58, 0x33, 0x9e,
0x7e, 0xee, 0x44, 0x08, 0xff, 0xfd, 0x2c, 0x2d
};
);
struct sockaddr_in saddr;
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = inet_addr(argv[1]);
saddr.sin_port = htons(atoi(argv[2]));
int sock = socket(AF_INET, SOCK_STREAM, 6);
errno = 0;
if (connect(sock, (struct sockaddr*) &saddr, sizeof saddr)) {
fprintf(stderr, "connect error: %s\n", strerror(errno));
return errno;
}
FILE* stream = fdopen(sock, "r+");
if (err) {
return err;
}
if (err) {
return err;
}
fclose(stream);
fprintf(stderr, "response status code is %x\n", resp.status);
fprintf(stderr, "server said: %*s\n", resp.errmsgsz, resp.errmsg);
} else {
}
}
@ SPRKL_SIGALGO_ED25519
Ed25519.
Definition common.h:10
void sprkl_request_freeall(struct sprkl_request *request)
Frees any pointers contained within the request, and then the request itself.
Definition request.c:87
@ SPRKL_STATUS_OK
Success.
Definition request.h:32
void sprkl_response_freeparts(struct sprkl_response *response, bool errmsg)
Frees any pointers contained within the response, but not the response itself.
Definition request.c:208
struct sprkl_request * sprkl_request_make_fetchservice(enum sprkl_sigalgo keyalgo, uint8_t *key, uint16_t serviceidx)
Allocates and returns a new request to fetch a service given its key and index.
Definition request.c:92
Request tagged union.
Definition request.h:74
enum sprkl_request_verb verb
Union tag, request verb.
Definition request.h:75
Response tagged union (varies on the associated request verb and status).
Definition request.h:84
enum sprkl_request_verb verb
Union tag, original request verb.
Definition request.h:85
Generic transport vtable.
Definition transport.h:15
Generic transport mechanism and concrete implementations.
int sprkl_transport_sendrequest(struct sprkl_transport *t, struct sprkl_request *request)
Sends a request via the given transport.
Definition transport.c:11
int sprkl_transport_recvresponse(struct sprkl_transport *t, struct sprkl_response *response)
Receives a response via the given transport.
Definition transport.c:26
char * sprkl_transport_strerror(struct sprkl_transport *t, int error)
Converts a transport-defined error number to a string description.
Definition transport.c:31
struct sprkl_transport sprkl_transport_make_stream(FILE *stream)
Creates a new transport operating on the given stdio stream.
Definition transport.c:69
#include <stdio.h>
int main(int argc, char** argv) {
uint8_t key[0x20] = {
0xc5, 0x82, 0x1e, 0x05, 0x34, 0x80, 0x17, 0x25,
0x3c, 0xfc, 0x80, 0x87, 0x0b, 0xca, 0x03, 0xed,
0x0a, 0x8b, 0x93, 0xbc, 0x33, 0x58, 0x33, 0x9e,
0x7e, 0xee, 0x44, 0x08, 0xff, 0xfd, 0x2c, 0x2d
};
);
if (err == -1) {
fprintf(stderr, "error: no default transport is available\n");
return err;
} else if (err) {
return err;
}
if (err) {
return err;
}
if (err) {
return err;
}
fprintf(stderr, "response status code is %x\n", resp.status);
fprintf(stderr, "server said: %*s\n", resp.errmsgsz, resp.errmsg);
} else {
}
}
void sprkl_transport_fini_default(struct sprkl_transport *transport)
Finalises the default transport.
Definition transport.c:101
int sprkl_transport_make_default(struct sprkl_transport *transport)
Creates the platform's default transport, usually configured by environment variable(s).
Definition transport.c:82