mirror of
https://github.com/JHUAPL/kvspool.git
synced 2026-01-09 15:37:56 -05:00
mac as cast.cfg type
This commit is contained in:
@@ -9,7 +9,7 @@ extern UT_array /* of int */ *output_types;
|
||||
|
||||
extern char *supported_types_str[];
|
||||
|
||||
#define TYPES x(i16) x(i32) x(ipv4) x(str) x(i8) x(d64)
|
||||
#define TYPES x(i16) x(i32) x(ipv4) x(str) x(i8) x(d64) x(mac)
|
||||
#define x(t) t,
|
||||
enum supported_types { TYPES };
|
||||
#undef x
|
||||
|
||||
@@ -43,7 +43,7 @@ void usage(char *prog) {
|
||||
}
|
||||
|
||||
int set_to_binary(void *set, zmq_msg_t *part) {
|
||||
uint32_t l, u, a,b,c,d, abcd;
|
||||
uint32_t l, u, a,b,c,d,e,f, abcd;
|
||||
uint16_t s;
|
||||
uint8_t g;
|
||||
double h;
|
||||
@@ -73,6 +73,19 @@ int set_to_binary(void *set, zmq_msg_t *part) {
|
||||
l=kv->vlen; utstring_bincpy(tmp,&l,sizeof(l)); /* length prefix */
|
||||
utstring_bincpy(tmp,kv->val,kv->vlen); /* string itself */
|
||||
break;
|
||||
case mac:
|
||||
if ((sscanf(kv->val,"%u:%u:%u:%u:%u:%u",&a,&b,&c,&d,&e,&f) != 6) ||
|
||||
(a > 255 || b > 255 || c > 255 || d > 255 || e > 255 || f > 255)) {
|
||||
fprintf(stderr,"invalid MAC for key %s: %s\n",*k,kv->val);
|
||||
goto done;
|
||||
}
|
||||
utstring_bincpy(tmp,&a,sizeof(a));
|
||||
utstring_bincpy(tmp,&b,sizeof(b));
|
||||
utstring_bincpy(tmp,&c,sizeof(c));
|
||||
utstring_bincpy(tmp,&d,sizeof(d));
|
||||
utstring_bincpy(tmp,&e,sizeof(e));
|
||||
utstring_bincpy(tmp,&f,sizeof(f));
|
||||
break;
|
||||
case ipv4:
|
||||
if ((sscanf(kv->val,"%u.%u.%u.%u",&a,&b,&c,&d) != 4) ||
|
||||
(a > 255 || b > 255 || c > 255 || d > 255)) {
|
||||
|
||||
@@ -34,7 +34,7 @@ void usage(char *prog) {
|
||||
}
|
||||
|
||||
int set_to_binary(void *set) {
|
||||
uint32_t l, u, a,b,c,d, abcd;
|
||||
uint32_t l, u, a,b,c,d,e,f, abcd;
|
||||
uint16_t s;
|
||||
uint8_t g;
|
||||
double h;
|
||||
@@ -64,6 +64,19 @@ int set_to_binary(void *set) {
|
||||
l=kv->vlen; utstring_bincpy(tmp,&l,sizeof(l)); /* length prefix */
|
||||
utstring_bincpy(tmp,kv->val,kv->vlen); /* string itself */
|
||||
break;
|
||||
case mac:
|
||||
if ((sscanf(kv->val,"%u:%u:%u:%u:%u:%u",&a,&b,&c,&d,&e,&f) != 6) ||
|
||||
(a > 255 || b > 255 || c > 255 || d > 255 || e > 255 || f > 255)) {
|
||||
fprintf(stderr,"invalid MAC for key %s: %s\n",*k,kv->val);
|
||||
goto done;
|
||||
}
|
||||
utstring_bincpy(tmp,&a,sizeof(a));
|
||||
utstring_bincpy(tmp,&b,sizeof(b));
|
||||
utstring_bincpy(tmp,&c,sizeof(c));
|
||||
utstring_bincpy(tmp,&d,sizeof(d));
|
||||
utstring_bincpy(tmp,&e,sizeof(e));
|
||||
utstring_bincpy(tmp,&f,sizeof(f));
|
||||
break;
|
||||
case ipv4:
|
||||
if ((sscanf(kv->val,"%u.%u.%u.%u",&a,&b,&c,&d) != 4) ||
|
||||
(a > 255 || b > 255 || c > 255 || d > 255)) {
|
||||
|
||||
@@ -83,7 +83,7 @@ void mark_writable() {
|
||||
}
|
||||
|
||||
int set_to_binary(void *set, UT_string *bin) {
|
||||
uint32_t l, u, a,b,c,d, abcd;
|
||||
uint32_t l, u, a,b,c,d,e,f, abcd;
|
||||
uint16_t s;
|
||||
uint8_t g;
|
||||
double h;
|
||||
@@ -114,6 +114,19 @@ int set_to_binary(void *set, UT_string *bin) {
|
||||
l=kv->vlen; utstring_bincpy(bin,&l,sizeof(l)); /* length prefix */
|
||||
utstring_bincpy(bin,kv->val,kv->vlen); /* string itself */
|
||||
break;
|
||||
case mac:
|
||||
if ((sscanf(kv->val,"%u:%u:%u:%u:%u:%u",&a,&b,&c,&d,&e,&f) != 6) ||
|
||||
(a > 255 || b > 255 || c > 255 || d > 255 || e > 255 || f > 255)) {
|
||||
fprintf(stderr,"invalid MAC for key %s: %s\n",*k,kv->val);
|
||||
goto done;
|
||||
}
|
||||
utstring_bincpy(bin,&a,sizeof(a));
|
||||
utstring_bincpy(bin,&b,sizeof(b));
|
||||
utstring_bincpy(bin,&c,sizeof(c));
|
||||
utstring_bincpy(bin,&d,sizeof(d));
|
||||
utstring_bincpy(bin,&e,sizeof(e));
|
||||
utstring_bincpy(bin,&f,sizeof(f));
|
||||
break;
|
||||
case ipv4:
|
||||
if ((sscanf(kv->val,"%u.%u.%u.%u",&a,&b,&c,&d) != 4) ||
|
||||
(a > 255 || b > 255 || c > 255 || d > 255)) {
|
||||
|
||||
Reference in New Issue
Block a user