Print this page
8927 sadb_x_kmc_t's KM cookie should be 64-bits
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>

*** 21,30 **** --- 21,31 ---- */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2012 Milan Juri. All rights reserved. + * Copyright 2017 Joyent, Inc. */ #include <unistd.h> #include <stdio.h> #include <stdlib.h>
*** 1150,1159 **** --- 1151,1163 ---- * Lookup the given cookie and return its corresponding label. Return * a pointer to the label on success, NULL on error (or if the label is * not found). Note that the returned label pointer points to a static * string, so the label will be overwritten by a subsequent call to the * function; the function is also not thread-safe as a result. + * + * Because this is possibly publically exported, do not change its name, + * but this is for all intents and purposes an IKEv1/in.iked function. */ char * kmc_lookup_by_cookie(int cookie) { FILE *map;
*** 2589,2605 **** void print_kmc(FILE *file, char *prefix, struct sadb_x_kmc *kmc) { char *cookie_label; ! if ((cookie_label = kmc_lookup_by_cookie(kmc->sadb_x_kmc_cookie)) == ! NULL) ! cookie_label = dgettext(TEXT_DOMAIN, "<Label not found.>"); ! (void) fprintf(file, dgettext(TEXT_DOMAIN, "%sProtocol %u, cookie=\"%s\" (%u)\n"), prefix, ! kmc->sadb_x_kmc_proto, cookie_label, kmc->sadb_x_kmc_cookie); } /* * Print an SADB_X_EXT_REPLAY_CTR extension. */ --- 2593,2628 ---- void print_kmc(FILE *file, char *prefix, struct sadb_x_kmc *kmc) { char *cookie_label; ! switch (kmc->sadb_x_kmc_proto) { ! case SADB_X_KMP_IKE: ! cookie_label = kmc_lookup_by_cookie(kmc->sadb_x_kmc_cookie); ! if (cookie_label == NULL) ! cookie_label = ! dgettext(TEXT_DOMAIN, "<Label not found.>"); (void) fprintf(file, dgettext(TEXT_DOMAIN, "%sProtocol %u, cookie=\"%s\" (%u)\n"), prefix, ! kmc->sadb_x_kmc_proto, cookie_label, ! kmc->sadb_x_kmc_cookie); ! return; ! case SADB_X_KMP_MANUAL: ! cookie_label = dgettext(TEXT_DOMAIN, "Manual SA with cookie"); ! break; ! /* case SADB_X_KMP_IKEV2: */ ! default: ! cookie_label = ! dgettext(TEXT_DOMAIN, "<unknown KM protocol>"); ! break; ! } ! ! /* XXX KEBE ASKS... htonll() on generic kmc_cookie? */ ! (void) fprintf(file, dgettext(TEXT_DOMAIN, ! "%sProtocol %u, cookie=\"%s\" (0x%"PRIx64"/%"PRIu64")\n"), ! prefix, kmc->sadb_x_kmc_proto, cookie_label, ! kmc->sadb_x_kmc_cookie64, kmc->sadb_x_kmc_cookie64); } /* * Print an SADB_X_EXT_REPLAY_CTR extension. */