I need to find the IP address of my node in my code. Currently, I have this line:this line:
IPv4Address addr = nb_ipv4->GetAddress (maininterface , 0);
In this line, I expect to get the IP address for my main interface, but instead I see this error:
error:conversion from 'ns3::Ipv4InterfaceAddress' to non-scalar type 'ns3::Ipv4Address'
Can anyone help me to solve this error?
I think that must be tagged as C++, and (if it is The ns-3 network simulator) you must do this:
IPv4Address addr = nb_ipv4->GetAddress(maininterface).GetLocal();
Related
Just want to ask if there's a way of getting your local machine's Mac address as String.
I need to save my local machine's mac address into a domain class. I tried using this code to get my Mac address:
String address = "ifconfig".execute().text()
But this line it also returns a lot of details about my ip address, all I need to get is the Mac Address which is found after the substring "HWaddr". I'm thinking if i could extract this substring using regex but I am not sure how to do it.
You can get the MAC address for an interface using java.net.NetworkInterface. Note that it is possible to have multiple hardware network interfaces, so it's possible to have more than one MAC address. In addition, most machines will have at least one interface without a hardware address: the loopback interface.
This will get a list of all the MAC addresses as Strings, including nulls for interfaces without a MAC address:
import java.net.NetworkInterface
def macs = NetworkInterface.networkInterfaces.collect { iface ->
iface.hardwareAddress?.encodeHex().toString()
}
You can use the NetworkInterface to get this information, especially the getHardwareAddress() method which return a byte array
I got an address such as 0x7fc9e401a02a in my log file, and I know that this address is a pointer of type Connection.
Then I start GDB, what I wanna know is: how to convert this address to a temporary variable of type Connection*, and display relevant information of Connection*?
How to do this, any hints?
Because my Connection class has a namespace, so what I should do is as bellow:
print * ('MyNameSpace::Connection' *) 0x7fc9e401a02a
Thanks JaredC and dbrank0 for your answers.
I've lifted a piece of code from somewhere on the internet it looks like this
ip = Regex.Replace(ip, #"^(?<Prefix>(\d{1,3}\.){3})\d{1,3}$", "${Prefix}*");
What it does is takes an IP address and replaces the last section with a asterisk. For example 192.168.0.1 would become 192.168.0.*
I'm useless with RegEx, I've tried to understand what the above is actually doing, but not having any success.
What I'm after is 2 more Regex.Replace code so that 192.168.0.1 becomes
192.168.*.*
192.*.*.*
Can anyone help me?
192.168.*.* = ip = Regex.Replace(ip, #"^(?<Prefix>(\d{1,3}\.){2})\d{1,3}\.\d{1,3}$", "${Prefix}*.*");
192.*.*.* = ip = Regex.Replace(ip, #"^(?<Prefix>(\d{1,3}\.))\d{1,3}\.\d{1,3}\.\d{1,3}$", "${Prefix}*.*.*");
Give that a shot, see what happens.
I am debugging C++ code and I have problems when trying to access to an std::list.
The problem is that I cannot get the address associated to the head node ($3 refers to the list):
p $3._M_impl._M_node
$21 = {
_M_next = 0x240ee70,
_M_prev = 0x240ee70
}
I get the following error message when I try to get the head node address:
(gdb) p &($3._M_impl._M_node)
Attempt to take address of value not located in memory.
I also have tried with the STL extension available from the Internet and it also fails at the same point.
set $head = &$arg0._M_impl._M_node
I have looked at Google an this is all I can find about the problem:
http://permalink.gmane.org/gmane.comp.gdb.devel/9496
But it doesn't solve my problem. Any suggestions are more than welcomed.
Thanks in advance
I have a windows mobile 6 application using TAPI 2.0. lineGetAddressID() is needed to get the address identifier used by several calls in the telephone api, but I can't get it to work.
I have tried the following to no avail:
HLINE line; // valid handle from lineOpen();
DWORD addr_id = 0;
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"1234", 5 );
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"5551234", 8 );
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"1115551234", 11 );
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"11115551234", 12 );
All of them return LINEERR_INVALADDRESS. Can anybody point out what I may be doing wrong?
As a side question, how can I programmaticly get the address? It appears in the LINEADDRESSCAPS structure returned by lineGetAddressCaps(), but that requires an address identifier (which would need to come from lineGetAddressID(), which requires an address...).
Note: I realize I could use 0 as the address ID and it will probably work, but I have no guarantee it will work for every platform. I would like to get this solved 'right'.
Thanks,
PaulH
When you invoke lineGetDevCaps one of the members of the LINEDEVCAPS structure, dwNumAddresses, is a count of the number of addresses associated with the line device.
TAPI states that the value of address identifiers are defined as the following:
Address identifiers range from zero to one less than the value indicated by dwNumAddresses.
So you can iterate through each address identifier value in the range [0 .. (dwNumAddresses - 1)] and invoke lineGetAddressCaps as you have provided a valid address identifier. There is no need to use lineGetAddressID in this case as the address identifier is known and valid.
If you do this, do any of the addresses specified in the LINEADDRESSCAPS structure match the string being used in your calls to lineGetAddressID? Noting that your application is configured to use Unicode rather than ANSI.