]>
Commit | Line | Data |
---|---|---|
d1e348cf A |
1 | /* |
2 | * Copyright (c) 2008 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
11 | * | |
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 | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | ||
23 | #ifndef _IPSECMESSAGETRACER_H | |
24 | #define _IPSECMESSAGETRACER_H | |
25 | ||
e8d9021d A |
26 | #import <asl.h> |
27 | ||
d1e348cf A |
28 | #define CONSTSTR(str) (const char *)str |
29 | ||
30 | #define L2TPIPSECVPN_CONNECTION_ESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.disconnect.l2tpipsec") | |
31 | #define CISCOIPSECVPN_CONNECTION_ESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.disconnect.ciscoipsec") | |
32 | #define BTMMIPSEC_CONNECTION_ESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.disconnect.btmm") | |
33 | #define PLAINIPSEC_CONNECTION_ESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.disconnect.plain") | |
34 | #define L2TPIPSECVPN_CONNECTION_NOTESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.connect.l2tpipsec") | |
35 | #define CISCOIPSECVPN_CONNECTION_NOTESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.connect.ciscoipsec") | |
36 | #define BTMMIPSEC_CONNECTION_NOTESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.connect.btmm") | |
37 | #define PLAINIPSEC_CONNECTION_NOTESTABLISHED_DOMAIN CONSTSTR("com.apple.Networking.ipsec.connect.plain") | |
38 | #define L2TPIPSECVPN_PHASE_DOMAIN CONSTSTR("com.apple.Networking.ipsec.phasestats.l2tpipsec") | |
39 | #define CISCOIPSECVPN_PHASE_DOMAIN CONSTSTR("com.apple.Networking.ipsec.phasestats.ciscoipsec") | |
40 | #define BTMMIPSEC_PHASE_DOMAIN CONSTSTR("com.apple.Networking.ipsec.phasestats.btmm") | |
41 | #define PLAINIPSEC_PHASE_DOMAIN CONSTSTR("com.apple.Networking.ipsec.phasestats.plain") | |
42 | #define PLAINIPSECDOMAIN CONSTSTR("com.apple.Networking.ipsec.main") | |
43 | ||
e8d9021d A |
44 | #define IPSECASLDOMAIN CONSTSTR("com.apple.Networking.ipsec.asl") |
45 | #define IPSECASLKEY CONSTSTR("IPSEC") | |
46 | ||
4aae5213 | 47 | #if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) |
fce29cd9 A |
48 | |
49 | #define IPSECCONFIGTRACEREVENT(config, eventCode, message, failure_reason) | |
50 | ||
51 | #define IPSECPOLICYTRACEREVENT(policy, eventCode, message, failure_reason) | |
52 | ||
53 | #define IPSECSESSIONTRACERSTART(session) | |
54 | #define IPSECSESSIONTRACEREVENT(session, eventCode, message, failure_reason) | |
55 | #define IPSECSESSIONTRACERSTOP(session, is_failure, reason) | |
56 | #define IPSECSESSIONTRACERESTABLISHED(session) | |
57 | ||
4aae5213 | 58 | #else // (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) |
fce29cd9 | 59 | |
d1e348cf A |
60 | #define IPSECCONFIGTRACEREVENT(config, eventCode, message, failure_reason) ipsecConfigTracerEvent(config, eventCode, message, failure_reason) |
61 | ||
62 | #define IPSECPOLICYTRACEREVENT(policy, eventCode, message, failure_reason) ipsecPolicyTracerEvent(policy, eventCode, message, failure_reason) | |
63 | ||
64 | #define IPSECSESSIONTRACERSTART(session) ipsecSessionTracerStart(session) | |
65 | #define IPSECSESSIONTRACEREVENT(session, eventCode, message, failure_reason) ipsecSessionTracerEvent(session, eventCode, message, failure_reason) | |
66 | #define IPSECSESSIONTRACERSTOP(session, is_failure, reason) ipsecSessionTracerStop(session, is_failure, reason) | |
67 | #define IPSECSESSIONTRACERESTABLISHED(session) ipsecSessionTracerLogEstablished(session) | |
68 | ||
4aae5213 | 69 | #endif // (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) |
fce29cd9 | 70 | |
4aae5213 | 71 | #if 1 |
65c25746 | 72 | #define IPSECLOGASLMSG(format, args...) plog(ASL_LEVEL_NOTICE, format, ##args); |
e8d9021d A |
73 | #else |
74 | #define IPSECLOGASLMSG(format, args...) do { \ | |
75 | aslmsg m = asl_new(ASL_TYPE_MSG); \ | |
76 | asl_set(m, ASL_KEY_FACILITY, IPSECASLDOMAIN); \ | |
77 | asl_set(m, ASL_KEY_MSG, IPSECASLKEY); \ | |
78 | asl_log(NULL, m, ASL_LEVEL_NOTICE, format, ##args); \ | |
79 | asl_free(m); \ | |
80 | } while(0) | |
81 | #endif | |
82 | ||
d1e348cf A |
83 | static inline double get_percentage (double numerator, double denominator) |
84 | { | |
85 | if (numerator >= denominator || denominator == 0) { | |
86 | return((double)100); | |
87 | } | |
88 | return((numerator/denominator)*100); | |
89 | } | |
90 | ||
91 | #endif /* _IPSECMESSAGETRACER_H */ |