2 * Copyright (c) 2008 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/types.h>
27 #include "ipsecConfigTracer.h"
28 #include "ipsecMessageTracer.h"
30 const char * ipsecConfigTracerFailedString
= "Tracer Failed";
31 const char * ipsecConfigInvalidEventString
= "Invalid Event";
32 const char * ipsecConfigString
= "IPSEC";
34 const char * const ipsecConfigEventStrings
[IPSECCONFIGEVENTCODE_MAX
] = { CONSTSTR("NONE") /* index place holder */,
35 CONSTSTR("Configuration Reparse Error"),
36 CONSTSTR("Configuration Parse Error"),
37 CONSTSTR("Signal Error"),
41 ipsecConfigEventCodeToString (ipsecConfigEventCode_t eventCode
)
43 if (eventCode
<= IPSECCONFIGEVENTCODE_NONE
|| eventCode
>= IPSECCONFIGEVENTCODE_MAX
)
44 return ipsecConfigInvalidEventString
;
45 return(ipsecConfigEventStrings
[eventCode
]);
50 ipsecConfigLogEvent (const char *event_msg
, const char *failure_signature
)
58 m
= asl_new(ASL_TYPE_MSG
);
59 asl_set(m
, ASL_KEY_FACILITY
, PLAINIPSECDOMAIN
);
60 asl_set(m
, ASL_KEY_MSG
, ipsecConfigString
);
61 #if 0 /* <rdar://problem/6468252> is flooding 300000+ events to MessageTracer servers */
62 if (failure_signature
) {
63 asl_set(m
, "com.apple.message.domain", PLAINIPSECDOMAIN
);
64 asl_set(m
, "com.apple.message.result", "failure"); // failure
65 asl_set(m
, "com.apple.message.signature", failure_signature
);
67 asl_log(NULL
, m
, ASL_LEVEL_NOTICE
, "%s", event_msg
);
69 if (failure_signature
) {
70 asl_log(NULL
, m
, ASL_LEVEL_NOTICE
, "%s (failure: %s)", event_msg
, failure_signature
);
72 asl_log(NULL
, m
, ASL_LEVEL_NOTICE
, "%s", event_msg
);
79 ipsecConfigTracerEvent (const char *filename
, ipsecConfigEventCode_t eventCode
, const char *event
, const char *failure_reason
)
83 if (filename
== NULL
) {
84 ipsecConfigLogEvent(CONSTSTR("tracer failed. (Invalid filename)."), ipsecConfigTracerFailedString
);
87 if (eventCode
<= IPSECCONFIGEVENTCODE_NONE
|| eventCode
>= IPSECCONFIGEVENTCODE_MAX
) {
88 ipsecConfigLogEvent(CONSTSTR("tracer failed. (Invalid event code)."), ipsecConfigTracerFailedString
);
92 ipsecConfigLogEvent(CONSTSTR("tracer failed. (Invalid event)."), ipsecConfigTracerFailedString
);
97 snprintf(buf
, sizeof(buf
), "%s. (%s, filename %s).", ipsecConfigEventCodeToString(eventCode
), failure_reason
, filename
);
98 ipsecConfigLogEvent(CONSTSTR(buf
), event
);