diff options
author | David Benjamin <davidben@mit.edu> | 2013-08-20 13:40:19 -0400 |
---|---|---|
committer | Karl Ramm <kcr@1ts.org> | 2013-09-28 14:20:40 -0400 |
commit | f269734ef50e1a9aa22eb9f18125967ca772744b (patch) | |
tree | f8ec0ecea416fac1698484b16d73d55b0378ed46 /lib/ZSubs.c | |
parent | 50d60c3dc739be77574cbf80bc24d7fbd2ff41be (diff) |
Create an alternate Z_AuthProc that saves keys
The start of proper session key management in libzephyr. A new Z_AuthProc is
added which appends the key into a queue. ZSubscribeTo and
ZSubscribeToSansDefaults are modified to use it. For now, it's extremely simple
and makes no attempt to expire old keys.
Diffstat (limited to 'lib/ZSubs.c')
-rw-r--r-- | lib/ZSubs.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/ZSubs.c b/lib/ZSubs.c index 7c7949b..535f3f9 100644 --- a/lib/ZSubs.c +++ b/lib/ZSubs.c @@ -91,6 +91,7 @@ ZSubscriptions(register ZSubscription_t *sublist, 0xFF, so some bytes are encoded as two bytes. */ int size_avail = Z_MAXPKTLEN-Z_FRAGFUDGE-Z_FRAGFUDGE; int size, start, numok; + Z_AuthProc cert_routine; /* nitems = 0 means cancel all subscriptions; still need to allocate a */ /* array for one item so we can cancel, however. */ @@ -117,6 +118,14 @@ ZSubscriptions(register ZSubscription_t *sublist, return(retval); } + /* if a subscription request, we save the key */ + if (strcmp(opcode, CLIENT_SUBSCRIBE) == 0 || + strcmp(opcode, CLIENT_SUBSCRIBE_NODEFS) == 0) { + cert_routine = ZSUBAUTH; + } else { + cert_routine = ZAUTH; + } + /* compute amount of room left */ size_avail -= hdrlen; size = size_avail; @@ -138,7 +147,7 @@ ZSubscriptions(register ZSubscription_t *sublist, numok = 0; if (!nitems) { /* there aren't really any, but we need to xmit anyway */ - retval = ZSrvSendList(¬ice, list, 0, ZAUTH, send_routine); + retval = ZSrvSendList(¬ice, list, 0, cert_routine, send_routine); free((char *)list); return(retval); } @@ -163,7 +172,7 @@ ZSubscriptions(register ZSubscription_t *sublist, return(ZERR_FIELDLEN); } retval = ZSrvSendList(¬ice, &list[start*3], numok * 3, - ZAUTH, send_routine); + cert_routine, send_routine); if (retval) { free((char *)list); return(retval); @@ -172,7 +181,7 @@ ZSubscriptions(register ZSubscription_t *sublist, } if (numok) retval = ZSrvSendList(¬ice, &list[start*3], numok * 3, - ZAUTH, send_routine); + cert_routine, send_routine); free((char *)list); return(retval); } |