├── demo.jpg
├── iOSRouter.xcodeproj
├── xcuserdata
│ └── xujialiang.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── iOSRouter.xcscheme
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── xujialiang.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── project.pbxproj
├── iOSRouter
├── ViewController.h
├── AppDelegate.h
├── main.m
├── Router
│ ├── Router.h
│ ├── Router.m
│ └── util
│ │ └── route.h
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── ViewController.m
└── AppDelegate.m
└── README.md
/demo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujialiang/iOSRoutingTable/HEAD/demo.jpg
--------------------------------------------------------------------------------
/iOSRouter.xcodeproj/xcuserdata/xujialiang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/iOSRouter.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOSRouter.xcodeproj/project.xcworkspace/xcuserdata/xujialiang.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujialiang/iOSRoutingTable/HEAD/iOSRouter.xcodeproj/project.xcworkspace/xcuserdata/xujialiang.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOSRouter/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/27.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/iOSRouter/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/27.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/iOSRouter/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/27.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iOSRouter.xcodeproj/xcuserdata/xujialiang.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iOSRouter.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 6CEE73471D71294400CA250E
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/iOSRouter/Router/Router.h:
--------------------------------------------------------------------------------
1 | //
2 | // Router.h
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/28.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RoutingTableItem;
12 |
13 | @interface Router : NSObject
14 |
15 | + (NSArray *)getRoutingTable;
16 |
17 | @end
18 |
19 | @interface RoutingTableItem : NSObject
20 |
21 | @property (nonatomic,copy) NSString *destination;
22 | @property (nonatomic,copy) NSString *gateway;
23 | @property (nonatomic,copy) NSString *flags;
24 | @property (nonatomic,copy) NSString *refs;
25 | @property (nonatomic,copy) NSString *use;
26 | @property (nonatomic,copy) NSString *mtu;
27 | @property (nonatomic,copy) NSString *expire;
28 | @property (nonatomic,copy) NSString *netif;
29 |
30 | @property (nonatomic,copy) NSString *desc;
31 | @end
--------------------------------------------------------------------------------
/iOSRouter/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/iOSRouter/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/iOSRouter/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOSRoutingTable
2 |
3 | ## 获取iOS手机路由表
4 | 看到surge app里提供了路由表信息,感觉在调试网络时候非常有用。
5 |
6 | 
7 |
8 | `
9 |
10 | __block NSString *showStr = @"Destination Gateway Flags Refs Use Netif Expire \r\n";
11 |
12 | NSArray *result = [Router getRoutingTable];
13 |
14 | [result enumerateObjectsUsingBlock:^(RoutingTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) {
15 | NSString *dest = [[NSString stringWithFormat:@"%@", obj.destination] stringByPaddingToLength:19 withString:@" " startingAtIndex:0];
16 | NSString *gateway = [[NSString stringWithFormat:@"%@", obj.gateway] stringByPaddingToLength:19 withString:@" " startingAtIndex:0];
17 | NSString *flags = [[NSString stringWithFormat:@"%@", obj.flags] stringByPaddingToLength:13 withString:@" " startingAtIndex:0];
18 | NSString *refs = [[NSString stringWithFormat:@"%@", obj.refs] stringByPaddingToLength:10 withString:@" " startingAtIndex:0];
19 | NSString *use = [[NSString stringWithFormat:@"%@", obj.use] stringByPaddingToLength:6 withString:@" " startingAtIndex:0];
20 | NSString *netif = [[NSString stringWithFormat:@"%@", obj.netif] stringByPaddingToLength:6 withString:@" " startingAtIndex:0];
21 |
22 | NSString *expire = [[NSString stringWithFormat:@"%@", obj.expire] stringByPaddingToLength:10 withString:@" " startingAtIndex:0];
23 |
24 | NSString *itemstr = [NSString stringWithFormat:@"%@%@%@%@%@%@%@\r\n",dest,gateway,flags,refs,use,netif,expire];
25 | showStr = [showStr stringByAppendingString:itemstr];
26 | }];
27 |
28 | self->txtView.text = showStr;
29 | `
30 |
31 | ----
32 | ## TODO:
33 | flags 可能不全,已尽最大努力找了linux相关netstat的资料了。
34 |
35 |
36 | ----
37 | 感谢以下开源项目给我的帮助
38 |
39 | https://github.com/Shmoopi/iOS-System-Services
40 |
41 | https://github.com/ygweric/IOS-RouteAddress
--------------------------------------------------------------------------------
/iOSRouter/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/27.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "Router/Router.h"
11 |
12 | @interface ViewController (){
13 |
14 | __weak IBOutlet UITextView *txtView;
15 |
16 | }
17 |
18 | @end
19 |
20 | @implementation ViewController
21 |
22 | - (void)viewDidLoad {
23 | [super viewDidLoad];
24 |
25 |
26 | __block NSString *showStr = @"Destination Gateway Flags Refs Use Netif Expire \r\n";
27 |
28 | NSArray *result = [Router getRoutingTable];
29 | [result enumerateObjectsUsingBlock:^(RoutingTableItem *obj, NSUInteger idx, BOOL * _Nonnull stop) {
30 | NSString *dest = [[NSString stringWithFormat:@"%@", obj.destination] stringByPaddingToLength:19 withString:@" " startingAtIndex:0];
31 | NSString *gateway = [[NSString stringWithFormat:@"%@", obj.gateway] stringByPaddingToLength:19 withString:@" " startingAtIndex:0];
32 | NSString *flags = [[NSString stringWithFormat:@"%@", obj.flags] stringByPaddingToLength:13 withString:@" " startingAtIndex:0];
33 | NSString *refs = [[NSString stringWithFormat:@"%@", obj.refs] stringByPaddingToLength:10 withString:@" " startingAtIndex:0];
34 | NSString *use = [[NSString stringWithFormat:@"%@", obj.use] stringByPaddingToLength:6 withString:@" " startingAtIndex:0];
35 | NSString *netif = [[NSString stringWithFormat:@"%@", obj.netif] stringByPaddingToLength:6 withString:@" " startingAtIndex:0];
36 |
37 | NSString *expire = [[NSString stringWithFormat:@"%@", obj.expire] stringByPaddingToLength:10 withString:@" " startingAtIndex:0];
38 |
39 | NSString *itemstr = [NSString stringWithFormat:@"%@%@%@%@%@%@%@\r\n",dest,gateway,flags,refs,use,netif,expire];
40 | showStr = [showStr stringByAppendingString:itemstr];
41 | }];
42 |
43 | self->txtView.text = showStr;
44 |
45 | }
46 |
47 |
48 |
49 | - (void)didReceiveMemoryWarning {
50 | [super didReceiveMemoryWarning];
51 | // Dispose of any resources that can be recreated.
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/iOSRouter/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/27.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 |
21 |
22 | return YES;
23 | }
24 |
25 | - (void)applicationWillResignActive:(UIApplication *)application {
26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
28 | }
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 | - (void)applicationWillEnterForeground:(UIApplication *)application {
36 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
37 | }
38 |
39 | - (void)applicationDidBecomeActive:(UIApplication *)application {
40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
41 | }
42 |
43 | - (void)applicationWillTerminate:(UIApplication *)application {
44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/iOSRouter/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/iOSRouter.xcodeproj/xcuserdata/xujialiang.xcuserdatad/xcschemes/iOSRouter.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/iOSRouter/Router/Router.m:
--------------------------------------------------------------------------------
1 | //
2 | // Router.m
3 | // iOSRouter
4 | //
5 | // Created by 徐佳良 on 16/8/28.
6 | // Copyright © 2016年 Credoo. All rights reserved.
7 | //
8 |
9 | #import "Router.h"
10 | // ifaddrs
11 | #import
12 | // inet
13 | #import
14 | #import
15 | #include
16 | #include
17 | #include
18 | // route
19 | #if TARGET_IPHONE_SIMULATOR
20 | #include
21 | #else
22 | #include "route.h"
23 | #endif
24 |
25 | @interface Router(){
26 | struct sockaddr m_addrs[8];
27 | struct rt_msghdr2 m_rtm;
28 | }
29 |
30 | @end
31 |
32 | @implementation Router
33 |
34 | -initWithRtm: (struct rt_msghdr2*) rtm
35 | {
36 | int i;
37 | struct sockaddr* sa = (struct sockaddr*)(rtm + 1);
38 |
39 | memcpy(&(m_rtm), rtm, sizeof(struct rt_msghdr2));
40 | for(i = 0; i < RTAX_MAX; i++)
41 | {
42 | [self setAddr:&(sa[i]) index:i];
43 | }
44 |
45 | return self;
46 | }
47 |
48 | -(void) setAddr:(struct sockaddr*)sa index:(int)rtax_index
49 | {
50 | if(rtax_index >= 0 && rtax_index < RTAX_MAX)
51 | {
52 | memcpy(&(m_addrs[rtax_index]), sa, sizeof(struct sockaddr));
53 | }
54 | }
55 |
56 | + (NSArray *)getRoutingTable {
57 | @try {
58 | // Set the router array variable with the routing information
59 | NSMutableArray *routerArray = [Router getRoutes];
60 | NSMutableArray *res = [NSMutableArray new];
61 |
62 | for(int i = 0; i < (int)[routerArray count]; i++)
63 | {
64 | // Set the router info
65 | Router* router = (Router*)[routerArray objectAtIndex:i];
66 | RoutingTableItem *item = [[RoutingTableItem alloc] init];
67 |
68 | item.destination = [Router getStdFormatSting:[router getDestination]];
69 | item.gateway = [Router getStdFormatSting:[router getGateway]];
70 | item.flags = [Router getStdFormatSting:[router getFlags]];
71 | item.refs = [Router getStdFormatSting:[router getRefs]];
72 | item.use = [Router getStdFormatSting:[router getUse]];
73 | item.mtu = [Router getStdFormatSting:[router getMTU]];
74 | item.expire = [Router getStdFormatSting:[router getExpire]];
75 | item.netif = [Router getStdFormatSting:[router getNetif]];
76 |
77 | [res addObject:item];
78 | }
79 | // Return Successful
80 | return res;
81 | }
82 | @catch (NSException *exception) {
83 | // Error
84 | return nil;
85 | }
86 | }
87 |
88 | +(NSString *)getStdFormatSting:(NSString *)str{
89 | return [[str stringByReplacingOccurrencesOfString:@" " withString:@""] stringByReplacingOccurrencesOfString:@"\x02" withString:@""];
90 | }
91 |
92 | -(nullable NSString*) getFlags{
93 | NSString *result = [[NSString alloc] init];
94 | if(m_rtm.rtm_flags & RTF_UP){
95 | result = [result stringByAppendingString:@"U"];
96 | }
97 | if(m_rtm.rtm_flags & RTF_GATEWAY){
98 | result = [result stringByAppendingString:@"G"];
99 | }
100 | if(m_rtm.rtm_flags & RTF_HOST){
101 | result = [result stringByAppendingString:@"H"];
102 | }
103 | if(m_rtm.rtm_flags & RTF_REJECT){
104 | result = [result stringByAppendingString:@"R"];
105 | }
106 | if(m_rtm.rtm_flags & RTF_DYNAMIC){
107 | result = [result stringByAppendingString:@"D"];
108 | }
109 | if(m_rtm.rtm_flags & RTF_MODIFIED){
110 | result = [result stringByAppendingString:@"M"];
111 | }
112 | if(m_rtm.rtm_flags & RTF_DONE){
113 | result = [result stringByAppendingString:@"d"];
114 | }
115 | if(m_rtm.rtm_flags & RTF_MULTICAST){
116 | result = [result stringByAppendingString:@"m"];
117 | }
118 | if(m_rtm.rtm_flags & RTF_CLONING){
119 | result = [result stringByAppendingString:@"C"];
120 | }
121 | if(m_rtm.rtm_flags & RTF_PRCLONING){
122 | result = [result stringByAppendingString:@"c"];
123 | }
124 | if(m_rtm.rtm_flags & RTF_LLINFO){
125 | result = [result stringByAppendingString:@"L"];
126 | }
127 | if(m_rtm.rtm_flags & RTF_WASCLONED){
128 | result = [result stringByAppendingString:@"W"];
129 | }
130 | if(m_rtm.rtm_flags & RTF_STATIC){
131 | result = [result stringByAppendingString:@"S"];
132 | }
133 | if(m_rtm.rtm_flags & RTF_BLACKHOLE){
134 | result = [result stringByAppendingString:@"B"];
135 | }
136 | if(m_rtm.rtm_flags & RTF_PROTO1){
137 | result = [result stringByAppendingString:@"1"];
138 | }
139 | if(m_rtm.rtm_flags & RTF_PROTO2){
140 | result = [result stringByAppendingString:@"2"];
141 | }
142 | if(m_rtm.rtm_flags & RTF_PROTO3){
143 | result = [result stringByAppendingString:@"2"];
144 | }
145 | if(m_rtm.rtm_flags & RTF_BROADCAST){
146 | result = [result stringByAppendingString:@"b"];
147 | }
148 | if(m_rtm.rtm_flags & RTF_ROUTER){
149 | result = [result stringByAppendingString:@"r"];
150 | }
151 | if(m_rtm.rtm_flags & RTF_IFSCOPE){
152 | result = [result stringByAppendingString:@"l"];
153 | }
154 |
155 |
156 | if(m_rtm.rtm_flags & RTF_XRESOLVE){
157 | result = [result stringByAppendingString:@"X"];
158 | }
159 |
160 | if(m_rtm.rtm_flags & RTF_IFREF){
161 | result = [result stringByAppendingString:@"i"];
162 | }
163 |
164 | return result;
165 | }
166 |
167 | + (NSMutableArray*) getRoutes
168 | {
169 | NSMutableArray* routeArray = [NSMutableArray array];
170 | Router* route = nil;
171 |
172 | size_t len;
173 | int mib[6];
174 | char *buf;
175 | register struct rt_msghdr2 *rtm;
176 |
177 | mib[0] = CTL_NET;
178 | mib[1] = PF_ROUTE;
179 | mib[2] = 0;
180 | mib[3] = PF_INET;
181 | mib[4] = NET_RT_DUMP2;
182 | mib[5] = 0;
183 |
184 | sysctl(mib, 6, NULL, &len, NULL, 0);
185 | buf = malloc(len);
186 | if (buf && sysctl(mib, 6, buf, &len, NULL, 0) == 0)
187 | {
188 | for (char * ptr = buf; ptr < buf + len; ptr += rtm->rtm_msglen)
189 | {
190 | rtm = (struct rt_msghdr2 *)ptr;
191 | route = [Router getRoute:rtm];
192 | if(route != nil)
193 | {
194 | [routeArray addObject:route];
195 | }
196 | }
197 | }
198 |
199 | free(buf);
200 |
201 | return routeArray;
202 | }
203 |
204 | + (nullable Router*) getRoute:(struct rt_msghdr2 *)rtm
205 | {
206 | struct sockaddr* dst_sa = (struct sockaddr *)(rtm + 1);
207 | Router* route = nil;
208 |
209 | if(rtm->rtm_addrs & RTA_DST)
210 | {
211 | if(dst_sa->sa_family == AF_INET && !((rtm->rtm_flags & RTF_WASCLONED) && (rtm->rtm_parentflags & RTF_PRCLONING)))
212 | {
213 | route = [[Router alloc] initWithRtm:rtm];
214 | }
215 | }
216 | return route;
217 | }
218 |
219 | -(nullable NSString*) getGateway
220 | {
221 | return [self getAddrStringByIndex:RTAX_GATEWAY];
222 | }
223 | -(nullable NSString*) getDestination
224 | {
225 | return [self getAddrStringByIndex:RTAX_DST];
226 | }
227 |
228 | -(nullable NSString*) getRefs
229 | {
230 | return [NSString stringWithFormat:@"%d",m_rtm.rtm_refcnt];
231 | }
232 |
233 | -(nullable NSString*) getUse
234 | {
235 | return [NSString stringWithFormat:@"%d",m_rtm.rtm_use];
236 | }
237 |
238 | -(nullable NSString*) getMTU
239 | {
240 | return [NSString stringWithFormat:@"%d",m_rtm.rtm_rmx.rmx_mtu];
241 | }
242 |
243 | -(nullable NSString*) getExpire
244 | {
245 | int diff = m_rtm.rtm_rmx.rmx_expire-[[NSDate new] timeIntervalSince1970];
246 | if (diff<0) {
247 | diff = 0;
248 | }
249 | return [NSString stringWithFormat:@"%d",diff];
250 | }
251 |
252 | -(nullable NSString*) getAddrStringByIndex: (int)rtax_index
253 | {
254 | NSString * routeString = nil;
255 |
256 | struct sockaddr* sa = &(m_addrs[rtax_index]);
257 | int flagVal = 1 << rtax_index;
258 |
259 | if(!(m_rtm.rtm_addrs & flagVal))
260 | {
261 | return nil;
262 | }
263 |
264 | if(rtax_index >= 0 && rtax_index < RTAX_MAX)
265 | {
266 | switch(sa->sa_family)
267 | {
268 | case AF_INET:
269 | {
270 | struct sockaddr_in* si = (struct sockaddr_in *)sa;
271 | if(si->sin_addr.s_addr == INADDR_ANY)
272 | routeString = @"default";
273 | else
274 | routeString = [NSString stringWithCString:(char *)inet_ntoa(si->sin_addr) encoding:NSASCIIStringEncoding];
275 | }
276 | break;
277 |
278 | case AF_LINK:
279 | {
280 | struct sockaddr_dl* sdl = (struct sockaddr_dl*)sa;
281 | if(sdl->sdl_nlen + sdl->sdl_alen + sdl->sdl_slen == 0)
282 | {
283 | routeString = [NSString stringWithFormat: @"link #%d", sdl->sdl_index];
284 | }
285 | else
286 | routeString = [NSString stringWithCString:link_ntoa(sdl) encoding:NSASCIIStringEncoding];
287 | }
288 | break;
289 |
290 | default:
291 | {
292 | char a[3 * sa->sa_len];
293 | char *cp;
294 | char *sep = "";
295 | int i;
296 |
297 | if(sa->sa_len == 0)
298 | {
299 | routeString = nil;
300 | }
301 | else
302 | {
303 | a[0] = '\0';
304 | for(i = 0, cp = a; i < sa->sa_len; i++)
305 | {
306 | cp += sprintf(cp, "%s%02x", sep, (unsigned char)sa->sa_data[i]);
307 | sep = ":";
308 | }
309 | routeString = [NSString stringWithCString:a encoding:NSASCIIStringEncoding];
310 | }
311 | }
312 | }
313 | }
314 |
315 | return routeString;
316 | }
317 |
318 | -(nullable NSString*)getNetif{
319 | int mib[6];
320 | char * buf;
321 | size_t lenp;
322 | struct if_msghdr *interfaceMsgStruct;
323 | struct sockaddr_dl *socketStruct;
324 |
325 | mib[0] = CTL_NET;
326 | mib[1] = AF_ROUTE;
327 | mib[2] = 0;
328 | mib[3] = 0; /* only addresses of this family */
329 | mib[4] = NET_RT_IFLIST;
330 | mib[5] = m_rtm.rtm_index; /* interface index, or 0 */
331 | if(sysctl(mib, 6, NULL, &lenp, NULL, 0) < 0) /* 第一次调用sysctl时第三个参数为空,在lenp指向的变量中返回存放所有结构信息要用的缓冲区的大小 */
332 | return(NULL);
333 | if((buf = malloc(lenp)) == NULL) /* 给缓冲区分配空间 */
334 | return(NULL);
335 |
336 | sysctl(mib, 6, buf, &lenp, NULL, 0);
337 | interfaceMsgStruct = (struct if_msghdr *) buf;
338 | socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);
339 |
340 | NSString *result = [NSString stringWithCString:socketStruct->sdl_data encoding:NSUTF8StringEncoding];
341 |
342 | free(buf);
343 |
344 |
345 | return [NSString stringWithFormat:@"%@",result];
346 | }
347 |
348 | @end
349 |
350 | @implementation RoutingTableItem
351 | -(NSString *)desc{
352 | return [NSString stringWithFormat:@"Destination:%@,Gateway:%@,Flags:%@,Refs:%@,Use:%@,MTU:%@,Netif:%@,Expire:%@",self.destination,self.gateway,self.flags,self.refs,self.use,self.mtu,self.netif,self.expire ];
353 | }
354 | @end
355 |
--------------------------------------------------------------------------------
/iOSRouter/Router/util/route.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * Copyright (c) 1980, 1986, 1993
30 | * The Regents of the University of California. All rights reserved.
31 | *
32 | * Redistribution and use in source and binary forms, with or without
33 | * modification, are permitted provided that the following conditions
34 | * are met:
35 | * 1. Redistributions of source code must retain the above copyright
36 | * notice, this list of conditions and the following disclaimer.
37 | * 2. Redistributions in binary form must reproduce the above copyright
38 | * notice, this list of conditions and the following disclaimer in the
39 | * documentation and/or other materials provided with the distribution.
40 | * 3. All advertising materials mentioning features or use of this software
41 | * must display the following acknowledgement:
42 | * This product includes software developed by the University of
43 | * California, Berkeley and its contributors.
44 | * 4. Neither the name of the University nor the names of its contributors
45 | * may be used to endorse or promote products derived from this software
46 | * without specific prior written permission.
47 | *
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 | * SUCH DAMAGE.
59 | *
60 | * @(#)route.h 8.3 (Berkeley) 4/19/94
61 | * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $
62 | */
63 |
64 | #if !(TARGET_IPHONE_SIMULATOR)
65 | #ifndef _NET_ROUTE_H_
66 | #define _NET_ROUTE_H_
67 | #include
68 | #include
69 | #include
70 | #include
71 |
72 | /*
73 | * These numbers are used by reliable protocols for determining
74 | * retransmission behavior and are included in the routing structure.
75 | */
76 | struct rt_metrics {
77 | u_int32_t rmx_locks; /* Kernel leaves these values alone */
78 | u_int32_t rmx_mtu; /* MTU for this path */
79 | u_int32_t rmx_hopcount; /* max hops expected */
80 | int32_t rmx_expire; /* lifetime for route, e.g. redirect */
81 | u_int32_t rmx_recvpipe; /* inbound delay-bandwidth product */
82 | u_int32_t rmx_sendpipe; /* outbound delay-bandwidth product */
83 | u_int32_t rmx_ssthresh; /* outbound gateway buffer limit */
84 | u_int32_t rmx_rtt; /* estimated round trip time */
85 | u_int32_t rmx_rttvar; /* estimated rtt variance */
86 | u_int32_t rmx_pksent; /* packets sent using this route */
87 | u_int32_t rmx_filler[4]; /* will be used for T/TCP later */
88 | };
89 |
90 | /*
91 | * rmx_rtt and rmx_rttvar are stored as microseconds;
92 | */
93 | #define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */
94 |
95 |
96 |
97 | #define RTF_UP 0x1 /* route usable */
98 | #define RTF_GATEWAY 0x2 /* destination is a gateway */
99 | #define RTF_HOST 0x4 /* host entry (net otherwise) */
100 | #define RTF_REJECT 0x8 /* host or net unreachable */
101 | #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
102 | #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
103 | #define RTF_DONE 0x40 /* message confirmed */
104 | #define RTF_DELCLONE 0x80 /* delete cloned route */
105 | #define RTF_CLONING 0x100 /* generate new routes on use */
106 | #define RTF_XRESOLVE 0x200 /* external daemon resolves name */
107 | #define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */
108 | #define RTF_STATIC 0x800 /* manually added */
109 | #define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */
110 | #define RTF_NOIFREF 0x2000 /* not eligible for RTF_IFREF */
111 | #define RTF_PROTO2 0x4000 /* protocol specific routing flag */
112 | #define RTF_PROTO1 0x8000 /* protocol specific routing flag */
113 |
114 | #define RTF_PRCLONING 0x10000 /* protocol requires cloning */
115 | #define RTF_WASCLONED 0x20000 /* route generated through cloning */
116 | #define RTF_PROTO3 0x40000 /* protocol specific routing flag */
117 | /* 0x80000 unused */
118 | #define RTF_PINNED 0x100000 /* future use */
119 | #define RTF_LOCAL 0x200000 /* route represents a local address */
120 | #define RTF_BROADCAST 0x400000 /* route represents a bcast address */
121 | #define RTF_MULTICAST 0x800000 /* route represents a mcast address */
122 | #define RTF_IFSCOPE 0x1000000 /* has valid interface scope */
123 | #define RTF_CONDEMNED 0x2000000 /* defunct; no longer modifiable */
124 | #define RTF_IFREF 0x4000000 /* route holds a ref to interface */
125 | #define RTF_PROXY 0x8000000 /* proxying, no interface scope */
126 | #define RTF_ROUTER 0x10000000 /* host is a router */
127 | /* 0x20000000 and up unassigned */
128 |
129 | #define RTF_BITS \
130 | "\020\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" \
131 | "\10DELCLONE\11CLONING\12XRESOLVE\13LLINFO\14STATIC\15BLACKHOLE" \
132 | "\16NOIFREF\17PROTO2\20PROTO1\21PRCLONING\22WASCLONED\23PROTO3" \
133 | "\25PINNED\26LOCAL\27BROADCAST\30MULTICAST\31IFSCOPE\32CONDEMNED" \
134 | "\33IFREF\34PROXY\35ROUTER"
135 |
136 | /*
137 | * Routing statistics.
138 | */
139 | struct rtstat {
140 | short rts_badredirect; /* bogus redirect calls */
141 | short rts_dynamic; /* routes created by redirects */
142 | short rts_newgateway; /* routes modified by redirects */
143 | short rts_unreach; /* lookups which failed */
144 | short rts_wildcard; /* lookups satisfied by a wildcard */
145 | };
146 |
147 | /*
148 | * Structures for routing messages.
149 | */
150 | struct rt_msghdr {
151 | u_short rtm_msglen; /* to skip over non-understood messages */
152 | u_char rtm_version; /* future binary compatibility */
153 | u_char rtm_type; /* message type */
154 | u_short rtm_index; /* index for associated ifp */
155 | int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
156 | int rtm_addrs; /* bitmask identifying sockaddrs in msg */
157 | pid_t rtm_pid; /* identify sender */
158 | int rtm_seq; /* for sender to identify action */
159 | int rtm_errno; /* why failed */
160 | int rtm_use; /* from rtentry */
161 | u_int32_t rtm_inits; /* which metrics we are initializing */
162 | struct rt_metrics rtm_rmx; /* metrics themselves */
163 | };
164 |
165 | struct rt_msghdr2 {
166 | u_short rtm_msglen; /* to skip over non-understood messages */
167 | u_char rtm_version; /* future binary compatibility */
168 | u_char rtm_type; /* message type */
169 | u_short rtm_index; /* index for associated ifp */
170 | int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
171 | int rtm_addrs; /* bitmask identifying sockaddrs in msg */
172 | int32_t rtm_refcnt; /* reference count */
173 | int rtm_parentflags; /* flags of the parent route */
174 | int rtm_reserved; /* reserved field set to 0 */
175 | int rtm_use; /* from rtentry */
176 | u_int32_t rtm_inits; /* which metrics we are initializing */
177 | struct rt_metrics rtm_rmx; /* metrics themselves */
178 | };
179 |
180 |
181 | #define RTM_VERSION 5 /* Up the ante and ignore older versions */
182 |
183 | /*
184 | * Message types.
185 | */
186 | #define RTM_ADD 0x1 /* Add Route */
187 | #define RTM_DELETE 0x2 /* Delete Route */
188 | #define RTM_CHANGE 0x3 /* Change Metrics or flags */
189 | #define RTM_GET 0x4 /* Report Metrics */
190 | #define RTM_LOSING 0x5 /* RTM_LOSING is no longer generated by xnu
191 | and is deprecated */
192 | #define RTM_REDIRECT 0x6 /* Told to use different route */
193 | #define RTM_MISS 0x7 /* Lookup failed on this address */
194 | #define RTM_LOCK 0x8 /* fix specified metrics */
195 | #define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
196 | #define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
197 | #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */
198 | #define RTM_NEWADDR 0xc /* address being added to iface */
199 | #define RTM_DELADDR 0xd /* address being removed from iface */
200 | #define RTM_IFINFO 0xe /* iface going up/down etc. */
201 | #define RTM_NEWMADDR 0xf /* mcast group membership being added to if */
202 | #define RTM_DELMADDR 0x10 /* mcast group membership being deleted */
203 | #define RTM_IFINFO2 0x12 /* */
204 | #define RTM_NEWMADDR2 0x13 /* */
205 | #define RTM_GET2 0x14 /* */
206 |
207 | /*
208 | * Bitmask values for rtm_inits and rmx_locks.
209 | */
210 | #define RTV_MTU 0x1 /* init or lock _mtu */
211 | #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
212 | #define RTV_EXPIRE 0x4 /* init or lock _expire */
213 | #define RTV_RPIPE 0x8 /* init or lock _recvpipe */
214 | #define RTV_SPIPE 0x10 /* init or lock _sendpipe */
215 | #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */
216 | #define RTV_RTT 0x40 /* init or lock _rtt */
217 | #define RTV_RTTVAR 0x80 /* init or lock _rttvar */
218 |
219 | /*
220 | * Bitmask values for rtm_addrs.
221 | */
222 | #define RTA_DST 0x1 /* destination sockaddr present */
223 | #define RTA_GATEWAY 0x2 /* gateway sockaddr present */
224 | #define RTA_NETMASK 0x4 /* netmask sockaddr present */
225 | #define RTA_GENMASK 0x8 /* cloning mask sockaddr present */
226 | #define RTA_IFP 0x10 /* interface name sockaddr present */
227 | #define RTA_IFA 0x20 /* interface addr sockaddr present */
228 | #define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */
229 | #define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */
230 |
231 | /*
232 | * Index offsets for sockaddr array for alternate internal encoding.
233 | */
234 | #define RTAX_DST 0 /* destination sockaddr present */
235 | #define RTAX_GATEWAY 1 /* gateway sockaddr present */
236 | #define RTAX_NETMASK 2 /* netmask sockaddr present */
237 | #define RTAX_GENMASK 3 /* cloning mask sockaddr present */
238 | #define RTAX_IFP 4 /* interface name sockaddr present */
239 | #define RTAX_IFA 5 /* interface addr sockaddr present */
240 | #define RTAX_AUTHOR 6 /* sockaddr for author of redirect */
241 | #define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */
242 | #define RTAX_MAX 8 /* size of array to allocate */
243 |
244 | struct rt_addrinfo {
245 | int rti_addrs;
246 | struct sockaddr *rti_info[RTAX_MAX];
247 | };
248 |
249 |
250 | #endif /* _NET_ROUTE_H_ */
251 | #endif /* TARGET_IPHONE_SIMULATOR */
252 |
--------------------------------------------------------------------------------
/iOSRouter.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 6CEE734D1D71294400CA250E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CEE734C1D71294400CA250E /* main.m */; };
11 | 6CEE73501D71294400CA250E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CEE734F1D71294400CA250E /* AppDelegate.m */; };
12 | 6CEE73531D71294400CA250E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CEE73521D71294400CA250E /* ViewController.m */; };
13 | 6CEE73561D71294400CA250E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6CEE73541D71294400CA250E /* Main.storyboard */; };
14 | 6CEE73581D71294400CA250E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CEE73571D71294400CA250E /* Assets.xcassets */; };
15 | 6CEE735B1D71294400CA250E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6CEE73591D71294400CA250E /* LaunchScreen.storyboard */; };
16 | 6CEE73651D72CF8000CA250E /* Router.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CEE73641D72CF8000CA250E /* Router.m */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXFileReference section */
20 | 6CEE73481D71294400CA250E /* iOSRouter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSRouter.app; sourceTree = BUILT_PRODUCTS_DIR; };
21 | 6CEE734C1D71294400CA250E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
22 | 6CEE734E1D71294400CA250E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
23 | 6CEE734F1D71294400CA250E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
24 | 6CEE73511D71294400CA250E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
25 | 6CEE73521D71294400CA250E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
26 | 6CEE73551D71294400CA250E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
27 | 6CEE73571D71294400CA250E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
28 | 6CEE735A1D71294400CA250E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
29 | 6CEE735C1D71294400CA250E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
30 | 6CEE73631D72CF8000CA250E /* Router.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Router.h; sourceTree = ""; };
31 | 6CEE73641D72CF8000CA250E /* Router.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Router.m; sourceTree = ""; };
32 | 6CEE73671D72D63000CA250E /* route.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = route.h; sourceTree = ""; };
33 | /* End PBXFileReference section */
34 |
35 | /* Begin PBXFrameworksBuildPhase section */
36 | 6CEE73451D71294400CA250E /* Frameworks */ = {
37 | isa = PBXFrameworksBuildPhase;
38 | buildActionMask = 2147483647;
39 | files = (
40 | );
41 | runOnlyForDeploymentPostprocessing = 0;
42 | };
43 | /* End PBXFrameworksBuildPhase section */
44 |
45 | /* Begin PBXGroup section */
46 | 6CEE733F1D71294400CA250E = {
47 | isa = PBXGroup;
48 | children = (
49 | 6CEE734A1D71294400CA250E /* iOSRouter */,
50 | 6CEE73491D71294400CA250E /* Products */,
51 | );
52 | sourceTree = "";
53 | };
54 | 6CEE73491D71294400CA250E /* Products */ = {
55 | isa = PBXGroup;
56 | children = (
57 | 6CEE73481D71294400CA250E /* iOSRouter.app */,
58 | );
59 | name = Products;
60 | sourceTree = "";
61 | };
62 | 6CEE734A1D71294400CA250E /* iOSRouter */ = {
63 | isa = PBXGroup;
64 | children = (
65 | 6CEE73621D72CF5000CA250E /* Router */,
66 | 6CEE734E1D71294400CA250E /* AppDelegate.h */,
67 | 6CEE734F1D71294400CA250E /* AppDelegate.m */,
68 | 6CEE73511D71294400CA250E /* ViewController.h */,
69 | 6CEE73521D71294400CA250E /* ViewController.m */,
70 | 6CEE73541D71294400CA250E /* Main.storyboard */,
71 | 6CEE73571D71294400CA250E /* Assets.xcassets */,
72 | 6CEE73591D71294400CA250E /* LaunchScreen.storyboard */,
73 | 6CEE735C1D71294400CA250E /* Info.plist */,
74 | 6CEE734B1D71294400CA250E /* Supporting Files */,
75 | );
76 | path = iOSRouter;
77 | sourceTree = "";
78 | };
79 | 6CEE734B1D71294400CA250E /* Supporting Files */ = {
80 | isa = PBXGroup;
81 | children = (
82 | 6CEE734C1D71294400CA250E /* main.m */,
83 | );
84 | name = "Supporting Files";
85 | sourceTree = "";
86 | };
87 | 6CEE73621D72CF5000CA250E /* Router */ = {
88 | isa = PBXGroup;
89 | children = (
90 | 6CEE73661D72D63000CA250E /* util */,
91 | 6CEE73631D72CF8000CA250E /* Router.h */,
92 | 6CEE73641D72CF8000CA250E /* Router.m */,
93 | );
94 | path = Router;
95 | sourceTree = "";
96 | };
97 | 6CEE73661D72D63000CA250E /* util */ = {
98 | isa = PBXGroup;
99 | children = (
100 | 6CEE73671D72D63000CA250E /* route.h */,
101 | );
102 | path = util;
103 | sourceTree = "";
104 | };
105 | /* End PBXGroup section */
106 |
107 | /* Begin PBXNativeTarget section */
108 | 6CEE73471D71294400CA250E /* iOSRouter */ = {
109 | isa = PBXNativeTarget;
110 | buildConfigurationList = 6CEE735F1D71294400CA250E /* Build configuration list for PBXNativeTarget "iOSRouter" */;
111 | buildPhases = (
112 | 6CEE73441D71294400CA250E /* Sources */,
113 | 6CEE73451D71294400CA250E /* Frameworks */,
114 | 6CEE73461D71294400CA250E /* Resources */,
115 | );
116 | buildRules = (
117 | );
118 | dependencies = (
119 | );
120 | name = iOSRouter;
121 | productName = iOSRouter;
122 | productReference = 6CEE73481D71294400CA250E /* iOSRouter.app */;
123 | productType = "com.apple.product-type.application";
124 | };
125 | /* End PBXNativeTarget section */
126 |
127 | /* Begin PBXProject section */
128 | 6CEE73401D71294400CA250E /* Project object */ = {
129 | isa = PBXProject;
130 | attributes = {
131 | LastUpgradeCheck = 0730;
132 | ORGANIZATIONNAME = Credoo;
133 | TargetAttributes = {
134 | 6CEE73471D71294400CA250E = {
135 | CreatedOnToolsVersion = 7.3.1;
136 | };
137 | };
138 | };
139 | buildConfigurationList = 6CEE73431D71294400CA250E /* Build configuration list for PBXProject "iOSRouter" */;
140 | compatibilityVersion = "Xcode 3.2";
141 | developmentRegion = English;
142 | hasScannedForEncodings = 0;
143 | knownRegions = (
144 | en,
145 | Base,
146 | );
147 | mainGroup = 6CEE733F1D71294400CA250E;
148 | productRefGroup = 6CEE73491D71294400CA250E /* Products */;
149 | projectDirPath = "";
150 | projectRoot = "";
151 | targets = (
152 | 6CEE73471D71294400CA250E /* iOSRouter */,
153 | );
154 | };
155 | /* End PBXProject section */
156 |
157 | /* Begin PBXResourcesBuildPhase section */
158 | 6CEE73461D71294400CA250E /* Resources */ = {
159 | isa = PBXResourcesBuildPhase;
160 | buildActionMask = 2147483647;
161 | files = (
162 | 6CEE735B1D71294400CA250E /* LaunchScreen.storyboard in Resources */,
163 | 6CEE73581D71294400CA250E /* Assets.xcassets in Resources */,
164 | 6CEE73561D71294400CA250E /* Main.storyboard in Resources */,
165 | );
166 | runOnlyForDeploymentPostprocessing = 0;
167 | };
168 | /* End PBXResourcesBuildPhase section */
169 |
170 | /* Begin PBXSourcesBuildPhase section */
171 | 6CEE73441D71294400CA250E /* Sources */ = {
172 | isa = PBXSourcesBuildPhase;
173 | buildActionMask = 2147483647;
174 | files = (
175 | 6CEE73651D72CF8000CA250E /* Router.m in Sources */,
176 | 6CEE73531D71294400CA250E /* ViewController.m in Sources */,
177 | 6CEE73501D71294400CA250E /* AppDelegate.m in Sources */,
178 | 6CEE734D1D71294400CA250E /* main.m in Sources */,
179 | );
180 | runOnlyForDeploymentPostprocessing = 0;
181 | };
182 | /* End PBXSourcesBuildPhase section */
183 |
184 | /* Begin PBXVariantGroup section */
185 | 6CEE73541D71294400CA250E /* Main.storyboard */ = {
186 | isa = PBXVariantGroup;
187 | children = (
188 | 6CEE73551D71294400CA250E /* Base */,
189 | );
190 | name = Main.storyboard;
191 | sourceTree = "";
192 | };
193 | 6CEE73591D71294400CA250E /* LaunchScreen.storyboard */ = {
194 | isa = PBXVariantGroup;
195 | children = (
196 | 6CEE735A1D71294400CA250E /* Base */,
197 | );
198 | name = LaunchScreen.storyboard;
199 | sourceTree = "";
200 | };
201 | /* End PBXVariantGroup section */
202 |
203 | /* Begin XCBuildConfiguration section */
204 | 6CEE735D1D71294400CA250E /* Debug */ = {
205 | isa = XCBuildConfiguration;
206 | buildSettings = {
207 | ALWAYS_SEARCH_USER_PATHS = NO;
208 | CLANG_ANALYZER_NONNULL = YES;
209 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
210 | CLANG_CXX_LIBRARY = "libc++";
211 | CLANG_ENABLE_MODULES = YES;
212 | CLANG_ENABLE_OBJC_ARC = YES;
213 | CLANG_WARN_BOOL_CONVERSION = YES;
214 | CLANG_WARN_CONSTANT_CONVERSION = YES;
215 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
216 | CLANG_WARN_EMPTY_BODY = YES;
217 | CLANG_WARN_ENUM_CONVERSION = YES;
218 | CLANG_WARN_INT_CONVERSION = YES;
219 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
220 | CLANG_WARN_UNREACHABLE_CODE = YES;
221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
223 | COPY_PHASE_STRIP = NO;
224 | DEBUG_INFORMATION_FORMAT = dwarf;
225 | ENABLE_STRICT_OBJC_MSGSEND = YES;
226 | ENABLE_TESTABILITY = YES;
227 | GCC_C_LANGUAGE_STANDARD = gnu99;
228 | GCC_DYNAMIC_NO_PIC = NO;
229 | GCC_NO_COMMON_BLOCKS = YES;
230 | GCC_OPTIMIZATION_LEVEL = 0;
231 | GCC_PREPROCESSOR_DEFINITIONS = (
232 | "DEBUG=1",
233 | "$(inherited)",
234 | );
235 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
236 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
237 | GCC_WARN_UNDECLARED_SELECTOR = YES;
238 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
239 | GCC_WARN_UNUSED_FUNCTION = YES;
240 | GCC_WARN_UNUSED_VARIABLE = YES;
241 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
242 | MTL_ENABLE_DEBUG_INFO = YES;
243 | ONLY_ACTIVE_ARCH = YES;
244 | SDKROOT = iphoneos;
245 | TARGETED_DEVICE_FAMILY = "1,2";
246 | };
247 | name = Debug;
248 | };
249 | 6CEE735E1D71294400CA250E /* Release */ = {
250 | isa = XCBuildConfiguration;
251 | buildSettings = {
252 | ALWAYS_SEARCH_USER_PATHS = NO;
253 | CLANG_ANALYZER_NONNULL = YES;
254 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
255 | CLANG_CXX_LIBRARY = "libc++";
256 | CLANG_ENABLE_MODULES = YES;
257 | CLANG_ENABLE_OBJC_ARC = YES;
258 | CLANG_WARN_BOOL_CONVERSION = YES;
259 | CLANG_WARN_CONSTANT_CONVERSION = YES;
260 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
261 | CLANG_WARN_EMPTY_BODY = YES;
262 | CLANG_WARN_ENUM_CONVERSION = YES;
263 | CLANG_WARN_INT_CONVERSION = YES;
264 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
265 | CLANG_WARN_UNREACHABLE_CODE = YES;
266 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
267 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
268 | COPY_PHASE_STRIP = NO;
269 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
270 | ENABLE_NS_ASSERTIONS = NO;
271 | ENABLE_STRICT_OBJC_MSGSEND = YES;
272 | GCC_C_LANGUAGE_STANDARD = gnu99;
273 | GCC_NO_COMMON_BLOCKS = YES;
274 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
275 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
276 | GCC_WARN_UNDECLARED_SELECTOR = YES;
277 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
278 | GCC_WARN_UNUSED_FUNCTION = YES;
279 | GCC_WARN_UNUSED_VARIABLE = YES;
280 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
281 | MTL_ENABLE_DEBUG_INFO = NO;
282 | SDKROOT = iphoneos;
283 | TARGETED_DEVICE_FAMILY = "1,2";
284 | VALIDATE_PRODUCT = YES;
285 | };
286 | name = Release;
287 | };
288 | 6CEE73601D71294400CA250E /* Debug */ = {
289 | isa = XCBuildConfiguration;
290 | buildSettings = {
291 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
292 | INFOPLIST_FILE = iOSRouter/Info.plist;
293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
294 | PRODUCT_BUNDLE_IDENTIFIER = net.xujialiang.iOSRouter;
295 | PRODUCT_NAME = "$(TARGET_NAME)";
296 | };
297 | name = Debug;
298 | };
299 | 6CEE73611D71294400CA250E /* Release */ = {
300 | isa = XCBuildConfiguration;
301 | buildSettings = {
302 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
303 | INFOPLIST_FILE = iOSRouter/Info.plist;
304 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
305 | PRODUCT_BUNDLE_IDENTIFIER = net.xujialiang.iOSRouter;
306 | PRODUCT_NAME = "$(TARGET_NAME)";
307 | };
308 | name = Release;
309 | };
310 | /* End XCBuildConfiguration section */
311 |
312 | /* Begin XCConfigurationList section */
313 | 6CEE73431D71294400CA250E /* Build configuration list for PBXProject "iOSRouter" */ = {
314 | isa = XCConfigurationList;
315 | buildConfigurations = (
316 | 6CEE735D1D71294400CA250E /* Debug */,
317 | 6CEE735E1D71294400CA250E /* Release */,
318 | );
319 | defaultConfigurationIsVisible = 0;
320 | defaultConfigurationName = Release;
321 | };
322 | 6CEE735F1D71294400CA250E /* Build configuration list for PBXNativeTarget "iOSRouter" */ = {
323 | isa = XCConfigurationList;
324 | buildConfigurations = (
325 | 6CEE73601D71294400CA250E /* Debug */,
326 | 6CEE73611D71294400CA250E /* Release */,
327 | );
328 | defaultConfigurationIsVisible = 0;
329 | };
330 | /* End XCConfigurationList section */
331 | };
332 | rootObject = 6CEE73401D71294400CA250E /* Project object */;
333 | }
334 |
--------------------------------------------------------------------------------