zhouguangwu / lanscan Goto Github PK
View Code? Open in Web Editor NEWios版的局域网扫描器, 网络工具包
ios版的局域网扫描器, 网络工具包
(NSString *) gateway2{
int mib[6] = {CTL_NET,
PF_ROUTE,//其实就是af_route的define
0, AF_INET,
NET_RT_FLAGS, RTF_GATEWAY};
size_t len;
NSAssert(sysctl(mib,sizeof(mib)/sizeof(int), 0, &len, 0, 0) >= 0, @"取长度出错");
// NSLog(@"sysctl buf长度%zd",len);
char *buf = calloc(len, 1);
NSAssert(sysctl(mib,sizeof(mib)/sizeof(int), buf, &len, 0, 0) >= 0, @"取长度出错");
// NSLog(@"实际内容长度%zd",len);
struct rt_msghdr *rtptr = (struct rt_msghdr *)buf;//routeptr, 后面解析数据就一样的了
struct sockaddr *sa = (struct sockaddr *)(rtptr + 1);
struct sockaddr_in *gateway = (struct sockaddr_in *)((char *)sa + sa->sa_len);//第一个是RTAX_DST, 我们只要网关
free(rtptr);
// NSLog(@"%s",inet_ntoa(gateway->sin_addr));
return [NSString stringWithUTF8String:inet_ntoa(gateway->sin_addr)];
}
return [NSString stringWithUTF8String:inet_ntoa(gateway->sin_addr)];
返回的时候报错了
您好,我现在想使用您写的这个demo获取手机mac地址,但是如果我想适配IPv6-Only网络的话还需要修改哪些地方呢?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.