+nq
This commit is contained in:
parent
fb3ece074c
commit
3c684a39e6
@ -27,9 +27,10 @@
|
||||
#include "openssl/ssl.h"
|
||||
#include "openssl/err.h"
|
||||
#include "util.h"
|
||||
#include "Generator.h"
|
||||
#include "generator.h"
|
||||
#include "logger.h"
|
||||
#include "mod.h"
|
||||
#include "msg.h"
|
||||
|
||||
static constexpr int MAX_MOD_ARGS = 32;
|
||||
static constexpr int MAX_MOD_ARG_LEN = 128;
|
||||
@ -61,9 +62,10 @@ struct dsmbr_request_record {
|
||||
uint64_t epoch;
|
||||
};
|
||||
|
||||
static constexpr int DSMBR_MSG_MAX_DATA = 16;
|
||||
struct dsmbr_ctrl_msg {
|
||||
int code;
|
||||
char data[32]; //fixed size for simplicity
|
||||
uint32_t code;
|
||||
uint64_t data[DSMBR_MSG_MAX_DATA];
|
||||
};
|
||||
|
||||
struct dsmbr_conn {
|
||||
@ -79,7 +81,6 @@ struct dsmbr_conn {
|
||||
|
||||
struct dsmbr_options {
|
||||
int verbose;
|
||||
|
||||
char server_ip[64];
|
||||
int server_port;
|
||||
int conn_per_thread;
|
||||
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
struct dsmbr_msg {
|
||||
uint32_t size;
|
||||
char data[0];
|
||||
};
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
struct ppd_msg {
|
||||
uint32_t size;
|
@ -1,93 +0,0 @@
|
||||
// modified from mutilate
|
||||
|
||||
#include "Generator.h"
|
||||
|
||||
#define FNV_64_PRIME (0x100000001b3ULL)
|
||||
#define FNV1_64_INIT (0xcbf29ce484222325ULL)
|
||||
uint64_t fnv_64_buf(const void* buf, size_t len)
|
||||
{
|
||||
uint64_t hval = FNV1_64_INIT;
|
||||
|
||||
unsigned char *bp = (unsigned char *)buf; /* start of buffer */
|
||||
unsigned char *be = bp + len; /* beyond end of buffer */
|
||||
|
||||
while (bp < be) {
|
||||
hval ^= (uint64_t)*bp++;
|
||||
hval *= FNV_64_PRIME;
|
||||
}
|
||||
|
||||
return hval;
|
||||
}
|
||||
|
||||
Generator* createFacebookKey() { return new GEV(30.7984, 8.20449, 0.078688); }
|
||||
|
||||
Generator* createFacebookValue() {
|
||||
Generator* g = new GPareto(15.0, 214.476, 0.348238);
|
||||
|
||||
Discrete* d = new Discrete(g);
|
||||
d->add(0.00536, 0.0);
|
||||
d->add(0.00047, 1.0);
|
||||
d->add(0.17820, 2.0);
|
||||
d->add(0.09239, 3.0);
|
||||
d->add(0.00018, 4.0);
|
||||
d->add(0.02740, 5.0);
|
||||
d->add(0.00065, 6.0);
|
||||
d->add(0.00606, 7.0);
|
||||
d->add(0.00023, 8.0);
|
||||
d->add(0.00837, 9.0);
|
||||
d->add(0.00837, 10.0);
|
||||
d->add(0.08989, 11.0);
|
||||
d->add(0.00092, 12.0);
|
||||
d->add(0.00326, 13.0);
|
||||
d->add(0.01980, 14.0);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
Generator* createFacebookIA() { return new GPareto(0, 16.0292, 0.154971); }
|
||||
|
||||
Generator* createGenerator(std::string str) {
|
||||
if (!strcmp(str.c_str(), "fb_key")) return createFacebookKey();
|
||||
else if (!strcmp(str.c_str(), "fb_value")) return createFacebookValue();
|
||||
else if (!strcmp(str.c_str(), "fb_ia")) return createFacebookIA();
|
||||
|
||||
char *s_copy = new char[str.length() + 1];
|
||||
strcpy(s_copy, str.c_str());
|
||||
char *saveptr = NULL;
|
||||
|
||||
if (atoi(s_copy) != 0 || !strcmp(s_copy, "0")) {
|
||||
double v = atof(s_copy);
|
||||
delete[] s_copy;
|
||||
return new Fixed(v);
|
||||
}
|
||||
|
||||
char *t_ptr = strtok_r(s_copy, ":", &saveptr);
|
||||
char *a_ptr = strtok_r(NULL, ":", &saveptr);
|
||||
|
||||
if (t_ptr == NULL) // || a_ptr == NULL)
|
||||
DIE("strtok(.., \":\") failed to parse %s", str.c_str());
|
||||
|
||||
char t = t_ptr[0];
|
||||
|
||||
saveptr = NULL;
|
||||
char *s1 = strtok_r(a_ptr, ",", &saveptr);
|
||||
char *s2 = strtok_r(NULL, ",", &saveptr);
|
||||
char *s3 = strtok_r(NULL, ",", &saveptr);
|
||||
|
||||
double a1 = s1 ? atof(s1) : 0.0;
|
||||
double a2 = s2 ? atof(s2) : 0.0;
|
||||
double a3 = s3 ? atof(s3) : 0.0;
|
||||
|
||||
delete[] s_copy;
|
||||
|
||||
if (strcasestr(str.c_str(), "fixed")) return new Fixed(a1);
|
||||
else if (strcasestr(str.c_str(), "normal")) return new Normal(a1, a2);
|
||||
else if (strcasestr(str.c_str(), "exponential")) return new Exponential(a1);
|
||||
else if (strcasestr(str.c_str(), "pareto")) return new GPareto(a1, a2, a3);
|
||||
else if (strcasestr(str.c_str(), "gev")) return new GEV(a1, a2, a3);
|
||||
else if (strcasestr(str.c_str(), "uniform")) return new Uniform(a1);
|
||||
|
||||
DIE("Unable to create Generator '%s'", str.c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
8
ppd/io.h
8
ppd/io.h
@ -22,14 +22,6 @@ struct ppd_bsock_io_ssl_ctx {
|
||||
|
||||
struct bsock_ringbuf_io ppd_bsock_io_ssl();
|
||||
|
||||
int ppd_readbuf_ssl(SSL *ssl, void *buf, int len);
|
||||
|
||||
int ppd_writebuf_ssl(SSL *ssl, void *buf, int len);
|
||||
|
||||
int ppd_readbuf(struct bsock *bsock, int len);
|
||||
|
||||
int ppd_writebuf(struct bsock *bsock, int len);
|
||||
|
||||
int ppd_readmsg(struct bsock *bsock, char *buf, size_t len);
|
||||
|
||||
int ppd_writemsg(struct bsock *bsock, struct ppd_msg *msg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user