How to get the user-set "custom name" of IOUSBDeviceInterface - macos

If I use the IOKit methods to list USB devices, I can get something like "AirPod Case", but I don't know how to get "Francisco's AirPods". I've looked around a the various keys you can ask for, but none I've found bring up these "settable" names, only the standard "product names".

I don't know the answer as a fact, but I can give you some ideas for chasing it down:
The customised name is probably transferred as part of a higher-level protocol, or via vendor specific requests, not via standardised USB device descriptors. There is a small chance it might be advertised via a vendor specific descriptor, but this seems unlikely
I don't own any AirPods, so I don't know what kind of data protocol the AirPod case uses for communicating with a Mac, but you can try to find documentation or source code for that protocol, for example in case anyone has worked out how to use them from Linux and written a tool or library for that.
Finally, you can reverse engineer it yourself, by logging the USB traffic to and from the device when using existing software that is capable of reading the name you are after. On macOS, it's possible to do this using Wireshark. Start logging USB traffic, launch the software that talks to the device, then trawl through the logs to see if you can spot the string, then work out what request caused it to be returned.

Related

Detect network connection availability changes

I am writing a Go application for Mac and Windows, which will perform some action whenever there is a network change( Client move from Wi-fi 1 to Wi-fi 2 or to 3G to LAN). I am aware of a solution for Application running on mac in swift language but I am looking for a platform-agnostic solution here.
So far I have tried checking for an event on an interface but I am not sure if that is sufficient.
I expect that on a network change (moving from Wifi-1 to Wifi-2 or 3G or LAN) my Go app should be able to know to take some action.
I doubt there would be such a solution.
Every project which tries to provide some platform-agnostic solution to an inherently OS-tied problem inevitably hides the platform-specific details behind a common API.
Look at https://github.com/fsnotify/fsnotify for a good example.
So, I'd take that route and would have put up a package which would have two platform-specific "backends" which would be compiled conditionally using build tags.
To get notified about network-related events under Windows,
you should probably start here.
Unfortunately, this stuff is COM-oriented, but you could use https://github.com/go-ole/go-ole to help with that.
You might also ask a non-Go-specific question tagged winapi to ask about what would be the best way to hook into the kernel to get notified about the availability of the networks.
There is no platform agnostic solution that exists, however platforms like OSx,Linux,Windiws has ways to get network events with their platform specific limitations.
OSx: Raw socket SOCK_RAW of AF_ROUTE type can be used to detect any network events that occurs in user machine. there are various types of network event that can be detected.
This thread talk about an example on BSD for network event
Windows : Windows has its APIs given as part of iphlpapi library. APIs like NotifyAddrChange, NotifyRouteChange allows you to have almost all network events( apart from metric change etc.) this git repo has a working example NotifyAddrChange, which gives back and event whenever a interface goes down or comes up.
Linux : In Linux netlink sockets allows a user space application to receive network events using netlink sockets.

How to get Mac address of system using snmp?

I am using snmpwalk for retrieve my system(localhost) or remote system's mac address and I am using this command:
snmpwalk -v2c -c public localhost .1.3.6.1.2.1.2.2.1.6
and get an error like noSuchObject.
How can I solve this error? Is there another way to get system mac address using snmp?
There is no such thing as "system MAC address". Systems do not have MAC addresses; network interfaces do, and a system may have zero, one, two or more network interfaces.
That's why you use snmpwalk: because .1.3.6.1.2.1.2.2.1.6 (i.e. ifPhysAddress) is a column in a table of interfaces and you don't know in advance how many conceptual rows you'll get back (and what unique numerical index each row will use as its key).
So, you're using the command properly. But next we have to consider that times have changed since the SNMP and SMI RFCs were written, well before the dot-com boom and back when the internet was a relatively pleasant and happy place. Nowadays, implementations tend to be far more conservative in the information they disclose, because every piece of information you disclose is potentially another way to attack your system. Why does anyone need access to know your system's MAC address? They probably don't. I created an SNMP Agent recently and its support for "standard" objects doesn't go anywhere near listing network interfaces. And many of the RFC1213 packet/status counters in snmp were deliberately made obsolete when a "safe" subset was adopted into RFC1907.
What does this mean for you? Well, the remote system must have a network interface otherwise you wouldn't be able to talk to it. So, the SNMP Agent you're polling/querying (you didn't say which) is either hardcoded or configured not to provide this information. You can't get around that, except by talking to the person who created the software and asking whether it is configurable; prepare for the answer to be "no".

Add protocol to gammu

By default gammu have support for most standard modem. I have a very particular modem with some special requirements and I would like to add a protocol to gammu.
Is there a guide for this somewhere or someone who can list the basic steps for me?
EDIT: #user1664784 recommended to look att Kannel, and actually any system able to handle incoming and outgoing SMS is acceptable as long as it is stable. But I need to know how to modify the system so that I can handle a specific protocol. It is AT-based but a slight dialect. So any suggestion of a system handling SMS from a device connected over serial port is interesting. I need to find a system where someone can give me information on where in the source code I can begin adding a new AT-based protocol.
If someone have done some sample code in this area it would also be greatly appreciated.
It really depends how much different it is from standard AT commands.
If the difference is minor (eg. needs custom initialization), it can be easily achieved by feature flags. This can be seein ATGEN_PostConnect which handles initialization for ZTE or Huawei devices.
If the differences are big, you will probably need to write own driver, which will fall back to AT in some cases. Something similar can be seen in the AT OBEX driver which switches Bluetooth connection between OBEX and IrMC modes.
I think we used to have documentation on adding support for new devices, but I'm unable to find it right now.

URL filtering using driver for OS X

I have an requirement for my client, where in i need to block particular URL based on the user input.
I was thinking to implement this by building a driver, From which i can get the packet response with all the details through this I can block/allow by building an application.(THIS is similar to what "netfilter" driver does in windows)
But as i read through the docs and websites i did not get enough information to proceed with for this particular requirement.(I found about bpf but there was not enough details to proceed with)
As I am very much NEW to the driver field,Can someone suggest me how to proceed in this case.(Steps how to proceed)
Note:I found lot of projects/docs related to USB drivers and all but they were not giving enough idea to proceed for further.
"URL" is very broad, and depending on the kinds of URL (what protocols? What about encryption?) and required granularity, some other solution than a custom kext might be a better approach. Not knowing your requirements, I can't say whether that's the case.
What I can answer, however, is that if you do decide to do this from a kext, Network Kernel Extensions are what you need to look into.
Apple also provides the enetlognke example code to illustrate how to use the NKE APIs.

Where to begin with SNMP agent implementation?

before I start I realise there are a few SNMP related questions here already but not many seem to have been answered - that could mean I'm asking in the wrong place but I don't know where else to go at the moment.
I've been reading up as best I can on SNMP for a couple of days but am finding it difficult to get my head around what is meant to be happening. The idea is eventually we will integrate SNMP into our Java application server which will allow the end users to incorporate it into their pre-existing Network Management Systems(NMS).
Unfortunately I'm feeling entirely confused by what is meant to be going on. From what I understood from talking to the end users (which was unfortunately before any research) was that the monitoring allows their existing NMS to give their admin guys a view of the vital statistics in a tree type display, giving them feedback regarding different parts of the system at a high level and allowing them to dig down into specific subsystems.
From reading around we would implement an 'Agent' which has several defined interfaces allowing for GET requests etc to be processed and responded to. That makes sense but I am at a loss to work out what the format of the communication is - there don't seem to be any specific examples of what any of the messages look like, how the information is encoded.
More of my confusion though is regarding Management Information Base(MIB). I had, wrongly, assumed that the interface of the agent would allow for the monitored attributes to be requested and then in turn the values for those attributes requested. Allowing any new Agent to be started and detected without any configuration on the NMS end (with the exception of authentication in v3). This, if I understand correctly, is not the case and the Agent must instead define MIBs which can be used by the NMS to determine those attributes. My confusion is increased when people start referring to thousands of existing MIBs and that they can be reused which I don't understand. Is the intention that a single MIB definition can be used to say describe how a particular attribute of a network device (something simple like internet connected on a router:yes/no) for many different devices? If so I don't believe that our software would allow the monitoring of anything common to any other device/system but should we be looking for already exising MIBs? At the moment I don't really see any good rational for such a system, surely it would be easier for the Agent to export that information - so I'd appreciate it if someone could enlighten me!
I think it would help if I was able to setup a simple SNMP agent and some sort of client, I could begin to see the process and eventually inspect the communication between the two but am finding it difficult to find anywhere that provides any information on doing such a thing. Nagios has been recommended to us as a test 'client'/NMS but their 'get started quick' section recommends downloading a 600Mb virtual machine - surely there is a quicker way to get started?
Any help or suggestions will be appreciated, I have been through the Wiki page but it doesn't seem to go into much detail about the MIBs and the having not had to deal with anything like the referenced RFCs before, while they may contain all of the information they seem completely impenetrable to me at the moment. Or if there are any books that can be recommended for an overview and implementation of v3?
Thanks for reading and even more thanks if you think you can help!
It seems to me that you read all SNMP information piece by piece in an disorganized way. This is highly not recommended and of course lead you to confusion.
What about forgetting what you have learnt so far and dive into a good book such as Essential SNMP?
http://shop.oreilly.com/product/9780596008406.do
Click the Google Preview icon to preview it please.
You could not depend on a network forum to tell you the ABCs, as that's impractical I find out.
The communications interface is SNMP. That's the protocol used for transmission (usually on top of UDP). The thing that services information requests is an SNMP Agent. The thing that sends information requests is an SNMP Manager.
The definition of what information should be made available by the Agent, and requested by the Manager, goes in a MIB. A MIB is the "glue", a directory of what sort of things any particular system can/should offer. It maps numeric codes to names and types that allow us to make sense of the data, much like how a phone directory maps phone numbers to people's names and addresses.
Generally you would create and ship and use your own MIBs that can describe aspects specific to your own product, but you are supposed to service some standard information requests as well, which are defined in existing MIBs. Yes there are thousands of other pre-existing MIBs and the likelihood that you need more than one or two of these is remote. They are typically published versions of MIBs for existing products.
The conventional way to "toy around" is to install Net-SNMP (a software suite that includes an agent implementation and allows you to "bolt on" your own logic and your own MIBs fairly easily) then examine the results using a packet capturer like Wireshark.
For a fuller implementation in production you may stick with Net-SNMP, or write your own Agent software, or do what I did and create a hybrid of the two that's a little more flexible and performant but uses Net-SNMP's backend for handling all the low-level SNMP stuff.
Your first step, though, is to read a book or some other teaching material that can clear all your misconceptions, because guesswork won't cut it.
I had success using the samples from this page. Both the shell and Perl NetSNMP code was very straightforward to implement and query.

Resources