I am new to SNMP and need to develop a Windows Service that will make the discovery of devices (SNMP) for all network and then need to get the information from discovered devices.
The discovery of devices I could do, although I believe that some devices were not detected, but the problem now is to retrieve device information.
Anyone have any suggestions?
My discovering code:
Discoverer _discoverer = new Discoverer();
_discoverer.AgentFound += Discoverer_AgentFound;
Console.WriteLine("v1 discovery");
_discoverer.Discover(VersionCode.V1, new IPEndPoint(IPAddress.Broadcast, 161), new OctetString("public"), 6000);
Console.WriteLine("v2 discovery");
_discoverer.Discover(VersionCode.V2, new IPEndPoint(IPAddress.Broadcast, 161), new OctetString("public"), 6000);
Console.WriteLine("v3 discovery");
_discoverer.Discover(VersionCode.V3, new IPEndPoint(IPAddress.Broadcast, 161), null, 6000);
SNMP RFC documents do not define a standard way of device discovery using SNMP. Thus, the Discoverer class of #SNMP uses a common approach to detect devices,
https://sharpsnmplib.codeplex.com/wikipage?title=SNMP%20Device%20Discovery
For security concerns, administrators might hide the devices by easily changing configuration. Generally speaking, you should manually add each devices instead.
Related
I'm developing a framework for iOS apps that allows interfacing with custom BLE devices made by my company. We're planning to distribute the framework binary with public headers to clients. I've already designed the client facing interface, but it's lacking a major feature: notification on various different status conditions. That is, when the framework starts scanning for devices, connects to a device, reads data, uploads to our backend, etc, there is currently no way for client apps to know.
This has been fine for local testing, but before releasing, it would be best to add some functionality to allow clients to build a UI that updates based on these various status conditions. I'm not entirely sure of what the current, best way to do this is. I'm aware I can create an NSNotificationCenter and post notifications for each of these status changes, but I'm not sure if there is some better way of doing this? Should I accept a user callback? Expose some sort of listener protocol and ability register listeners? I'm sure others have solved this problem before, what have you found works well for iOS?
Use NSNotificationCenter for one to many communication, it notifies all the objects, which register to event, without knowing who throws it.
Use protocol and delegates for one to one object communication.
As per my experience you should go with delegates, it will be clean implementation and you can also define optional and required protocol.The the global class on client side can use this delegates, and update.
This is for a visualisation project on what data gets recorded about us from our phones.
The idea would be to log as much detail as is reasonable to an internal location (probably) on the phone for later analysis, e.g. HTTP requests. It doesn’t need to be secret at all – the subject will be aware they are participating – and it doesn’t have to be 100% automatic; if the phone owner needs to perform some action regularly that’s okay too, although they need to be able to use their phone approximately normally throughout the day.
I can’t find any Apple APIs that look suitable, but that’s hardly surprising. I can find some approaches that would potentially work on OSX (tcpdump, netstat), so perhaps a jailbroken iOS device would support one of those?
Alternatively, running a custom proxy server would open up a bunch more options, but is there any way to get a mobile device to reliably route through a proxy server?
It appears this question provides a viable proxy-server-based approach:
https://apple.stackexchange.com/questions/81102/proxy-settings-for-iphone-3g-connection
Basically, it seems it is possible to route all requests through a proxy server, even over cellular.
I am new To Intelxdk and want to know whether I can achieve the points.
Handle limited/no internet connection case
Upload file from file manager to the server
Sqlite connection, execute queries(select,add,...)
Navigate between screens using variables(Ex : user_id)
Apply UI design, and handle multiple resolutions for each platform
Download file from server to device
Use maps for a given longitude and latitude
Swipe images by fingers
Package the app for Android & iOS
Push notification configuration
Capture image from camera, save it, and upload it to server
Share text to social networks(Facebook,Twitter) using their apis
Share text to social networks using intent
Call XML webservice, and parse response
Call SOAP webservice, and parse response
Handle device rotation(landscape)
Sorry for big question,
anyone who has any details about all or one of those points. Please let me know,
I will be grateful.
I've also answered this on our forum...
Please see our demo apps and documentation for answers to your questions. I'll try to provide some quick answers below.
Many of your questions presume the XDK is providing platform services -- please note that the XDK provides debug and build services that put your HTML5 code into an embedded webview (an embedded browser window), where many of the features and functions depend on what is available in the embedded webview. This embedded webview container includes JavaScript API "extensions" that provide access to device resources that you normally would be restricted from using in a standard browser, such as access to device features and contacts, but, in general, if you can do something in a browser you can do it in the webview.
Also, keep in mind that the resources available in a webview on a mobile device (memory and CPU) are much more limited than what you are used to on the desktop browser. The desktop browser has nearly unlimited resources, that is not the case with a mobile device. You must design your app to be "lean and mean" for best results. Do not include large numbers of CSS and JS files, especially if you are only using one or two elements within those included apps.
1-Handle limited/no internet connection case
An XDK apps does not require a network connection. If your app uses a network connection it is up to you to determine the behavior when there is limited or no network connectivity. If you only try to access the network when the network is available...
2-Upload file from file manager to the server
There is no such thing as a "file manager" on a mobile device. How you locate and upload files is very device dependent and how you choose to upload them to a server is also up to you to decide. There are standard HTML5 techniques and a few APIs that can help.
3-Sqlite connection, execute queries(select,add,...)
Again, this is device/target platform dependent, it is not dictated by the XDK.
4-Navigate between screens using variables(Ex : user_id)
In general, we advise against using multi-page apps, due to JavaScript context changes, inter-page reload times and resource requirements. Single-page apps that use hidden divs to represent multiple pages tend to work better in this environment, especially if you are new to writing such apps.
5-Apply UI design, and handle multiple resolutions for each platform
Again, this is completely under your control, how well you can master things like media queries and such. The App Designer tool can help you tremendously in this regard, but it is NOT required. If you have your own layout tools you can use them and utilize the HTML/CSS they generate in your project. Or, you can write your layout by hand. For example, if you like to use Zurb Foundation as a responsive web design tool you can use it here.
6-Download file from server to device
Again, what you can do with that file when you get to the device is platform dependent.
7-Use maps for a given longitude and latitude
Not XDK dependent, use whatever network mapping service you prefer. You can get Lat and Long numbers by using the geo APIs that are extensions to the normal webview.
8-Swipe images by fingers
XDK does not dictate how you handle touch events, this is up to you to design how such events and actions are handled.
9-Package the app for Android & iOS
We provide packaging services for Android, iOS and several other mobile targets.
10-Push notification configuration
There is a push notification service built-in from AppMobi. However, we are moving to a 100% compatible Cordova contain that will allow you to (in the near future) include any push notification service that has the appropriate Cordova plugin.
11-Capture image from camera, save it, and upload it to server
There are APIs present for such actions.
12-Share text to social networks(Facebook,Twitter) using their apis
These can all be done using standard HTML5 programming techniques and do not require special services from the XDK.
13-Share text to social networks using intent
Intents depend on the specific platform.
14-Call XML webservice, and parse response
Use your favorite JS library to parse XML data, the XDK does not restrict this.
15-Call SOAP webservice, and parse response
Again, if you have a favorite JS library to parse SOAP data, the XDK does not restrict your use of such a library.
16-Handle device rotation(landscape)
Events are present in the standard webviews (precise behavior varies by platform) to help you deal with rotation.
There is a piece of code that does DNS lookups using CFHostStartInfoResolution(). However this is synchronously and thus blocks anything before it returns - it's bad and I also think it causes crashes due to timeouts when connection is weak (when its bad it fails out safely directly)
So I want to do this asynchronously, as it's supposed to in the docs https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFHostRef/Reference/reference.html
New docs URL 20190227: https://developer.apple.com/documentation/cfnetwork/cfhostref
Specifically it says:
If you want to resolve the host asynchronously. call CFHostSetClient
to associate your client context and user-defined callback function
with the host. Then call CFHostScheduleWithRunLoop to schedule the
host on a run loop.
However this put me off because I haven't coded C in ages and can't get callbacks and runloops/threading right.
How am I supposed to call CFHostSetClient, CFHostScheduleWithRunLoop, and how do I implement those callbacks? Do I need to start a new thread?
Actually CFHost has a bug since on macOS since 10.7. Up to 10.7 it was possible to cancel a synchronous lookup calling CFHostCancelInfoResolution() on a second thread but since 10.7 this is not possible any longer (it just won't cancel the lookup). I reported that to Apple in 2013 (bug number is 13672880) but despite confirming it, Apple has never fixed it up to today.
Yet the more interesting part was what Apple suggested in their reply:
The best API for host name resolution is DNSServiceGetAddrInfo
and that's asynchronous and cancelable.
This API is documented to exist on macOS since 10.11.4, on iOS since 9.3, on tvOS since 9.2 and on watchOS since 2.2 - yet I think this cannot be correct, it must have existed, otherwise how could Apple recommend it in 2013 (10.11 was released 2015). I can confirm that this API also existed on iOS 8 and on macOS 10.9 and probably even earlier on both systems.
This API is internally using an undocumented asynchronous version of the otherwise synchronous C call getaddrinfo() which is found on all POSIX like systems today.
One advantage over other APIs is that you can choose if you only want to retrieve IPv4, IPv6, or both kind of addresses or you can let the system decide to pick the address family for you, depending on which addresses the system considers reachable at the moment (this is the default for most other resolving APIs).
Also in case a system has multiple active network interfaces (e.g. cable + WiFi or WiFi + mobile), you can pick the interface to use as different DNS settings may be set on different interfaces (and different DNS servers can deliver different results for the same domain name). If you don't pick one, the system will always use the current default server (this is the default for most other resolving APIs).
Should be something like this
CFHostSetClient(host, callbackFunction, hostContext);
CFHostScheduleWithRunLoop(host, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
CFHostStartInfoResolution(host, kCFHostAddresses, 0);
And callbackFunction
void callbackFunction(CFHostRef theHost, CFHostInfoType typeInfo, const CFStreamError *error, void *info) {
// Do something
}
You don't need to start a new thread, system will do it for you.
I'd like to create a virtual HID device (emulate it with a driver).
It must be visible to clients that implement standard HID detection:
Call HidD_GetHidGuid() – Get the HID
device class GUID
Call SetupDiGetClassDevs() – Get a
handle to a set of devices which
implement the HID interface
Call SetupDiEnumDeviceInterfaces() –
For each device in the returned set
of devices, obtain the interface
information for all exposed HID
interfaces.
Call
SetupDiGetDeviceInterfaceDetail() –
For each interface obtained in the
previous call, get the detailed
information block for that interface.
This detailed information includes
the string that can be passed to
CreateFile() to open a handle to the
device
Call SetupDiDestroyDeviceInfoList() –
Free up the device information set
that was obtained in the call to
SetupDiGetClassDevs().
The device should also support reading, so CreateFile / ReadFile would return data supplied by me from the driver.
I don't really know where to begin, as I don't have a lot of exp. in kernel dev. :(
Some people have had luck with the vmulti project as a base http://code.google.com/p/vmulti/
You sholud write a driver, then use DevCon (Device Console Tool) with install option.
cmdInstall:
A variation of cmdUpdate to install a driver when there is no associated hardware. It creates a new root-enumerated device instance and associates it with a made up hardware ID specified on the command line (which should correspond to a hardware ID in the INF). This cannot be done on a remote machine or in the context of Wow64.
http://code.msdn.microsoft.com/windowshardware/DevCon-Sample-4e95d71c
http://msdn.microsoft.com/en-us/library/windows/hardware/ff544707%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/hardware/ff544780%28v=vs.85%29.aspx
see the vhidmini ddk sample driver. It was in the version 1830 DDK but is not in the latest version. alternatively the hidfake sample in Oney's book.
See http://www.microsoft.com/mspress/books/sampchap/6262.aspx