Skip to main content

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Elsewhere in the forum there is posted code that shows how to get the mac address of an adapter on Windows.

http://www.acucorp.com/support/supported/customer_forum/showthread.php?threadid=594

If you are not on Windows, you will have to find a counterpart to the api function used for your particular host.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Thanks Gisle
that works like a charm.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Hey all,

one question:
how do allocate the memory in windows when using acuthin?
@[display]:m$alloc produces an error.

CALL "@[display]:IpHlpAPI.DLL".
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.
CALL "M$ALLOC" USING AllocSize
AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.


thx bli

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Hey all,

one question:
how do allocate the memory in windows when using acuthin?
@[display]:m$alloc produces an error.

CALL "@[display]:IpHlpAPI.DLL".
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.
CALL "M$ALLOC" USING AllocSize
AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.


thx bli

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Hey all,

one question:
how do allocate the memory in windows when using acuthin?
@[display]:m$alloc produces an error.

CALL "@[display]:IpHlpAPI.DLL".
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.
CALL "M$ALLOC" USING AllocSize
AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.


thx bli

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
I do not believe that the "display" side of thin client supports calling M$ALLOC. The thin client display side was architected to handle the display and printing aspects that an application needs but not manipulating the client machine memory.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Dilbert is right.

However, you can use the LocalAlloc in the kernel32.dll from the Windows API.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Problem: if LocalAlloc works right
strcpy copy?s no data to ip-adapter-info
any idea? or totally the wrong way?


CALL "@[display]:kernel.DLL".
CALL "@[display]:msvcrt.DLL".
CALL "@[display]:IpHlpAPI.DLL".

CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE Allocsize.
INITIALIZE uFlag.
CALL "@[display]:LocalAlloc" USING
by value uFlag
by value AllocSize
giving AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.

SET ENVIRONMENT "DLL-CONVENTION" TO "0"
CALL "@[display]:strcpy" USING
BY reference ip-adapter-info
BY value AllocPtr.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Problem: if LocalAlloc works right
strcpy copy?s no data to ip-adapter-info
any idea? or totally the wrong way?


CALL "@[display]:kernel.DLL".
CALL "@[display]:msvcrt.DLL".
CALL "@[display]:IpHlpAPI.DLL".

CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE Allocsize.
INITIALIZE uFlag.
CALL "@[display]:LocalAlloc" USING
by value uFlag
by value AllocSize
giving AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.

SET ENVIRONMENT "DLL-CONVENTION" TO "0"
CALL "@[display]:strcpy" USING
BY reference ip-adapter-info
BY value AllocPtr.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Problem: if LocalAlloc works right
strcpy copy?s no data to ip-adapter-info
any idea? or totally the wrong way?


CALL "@[display]:kernel.DLL".
CALL "@[display]:msvcrt.DLL".
CALL "@[display]:IpHlpAPI.DLL".

CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE Allocsize.
INITIALIZE uFlag.
CALL "@[display]:LocalAlloc" USING
by value uFlag
by value AllocSize
giving AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.

SET ENVIRONMENT "DLL-CONVENTION" TO "0"
CALL "@[display]:strcpy" USING
BY reference ip-adapter-info
BY value AllocPtr.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Two issues:

First, use kernel32, not kernel.

Second, strcpy is to copy a string, not a struct (group in COBOL), so you should use memcpy instead, strcpy will terminate on the first occurence of ascii 0 in the data. I believe there are quite a few of those in this.

May be this was a bad idea.

Perhaps you should use malloc(), free() and memcpy() from the VC runtime library instead. After all, you already have msvcrt loaded so...

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
It is kernel32.
Your are right with strcpy, i knew that but i didn?t saw the coherence.
Now i use memcpy and everything works fine.

Thank?s for help.

Andreas

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Excellent!

Perhaps you would care to post a little demo, would be nice to show how to accomplish this in a TC environment, alternatively also as a guide on how to use remote DLLs.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Excellent!

Perhaps you would care to post a little demo, would be nice to show how to accomplish this in a TC environment, alternatively also as a guide on how to use remote DLLs.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Excellent!

Perhaps you would care to post a little demo, would be nice to show how to accomplish this in a TC environment, alternatively also as a guide on how to use remote DLLs.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
be careful, no error handling

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Thanks, your contribution to the forum is appreciated!

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
New Problem

I need the name of the adapters which is shown in ipconfig.
I tried GetInterfaceInfo not sure that the function returns the
full name.

Next I don`t understand the structure of IP_ADAPTER_INDEX_MAP

any ideas

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
New Problem

I need the name of the adapters which is shown in ipconfig.
I tried GetInterfaceInfo not sure that the function returns the
full name.

Next I don`t understand the structure of IP_ADAPTER_INDEX_MAP

any ideas

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
New Problem

I need the name of the adapters which is shown in ipconfig.
I tried GetInterfaceInfo not sure that the function returns the
full name.

Next I don`t understand the structure of IP_ADAPTER_INDEX_MAP

any ideas

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
GetInterfaceInfo is the correct function, and yes, I can understand that you have a problem with translating the IP_ADAPTER_INDEX_MAP. It is absolutely doable, a little tricky, but doable in COBOL as well.

If it helps, you have to remember that the array here is a C Array and as such, you have to iterate it by incrementing a pointer.

I am sorry, but I don't have the time to make you a full example on this one. I would recommend you contact Acucorp Professional Services, they can help you make a COBOL counterpart of this.

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
Gisle,

maybe it?s better if I post a sample, so you can take a look and find a minute
to help me. I don`t know how to get the name (ip_name). On MSDN ip_name (adapter_name) is described
as "Pointer to a Unicode string that contains the name of the adapter". I tried to copy out a string from this
pointer, but with no result. next I tried this sample, same result.

thx for help


78 MAX_ADAPTER_NAME VALUE 127

01 numadapters pic x(04) comp-n.
01 ip-interface-info.
03 ip-adapter-index pic x(04) comp-n.
03 ip-name pic x(max_adapter_name).
* 03 ip-name-ptr pic x(04) comp-n.


initialize ipifptr ipifsize.
call "@[display]:GetInterfaceInfo" using
by value ipifptr
by reference ipifsize.
SET ENVIRONMENT "DLL-CONVENTION" TO "0"

CALL "@[display]:malloc" USING
BY VALUE ipifSIZE
GIVING ipifptr.
SET ENVIRONMENT "DLL-CONVENTION" TO "1"

call "@[display]:GetInterfaceInfo" using
by value ipifptr
by reference ipifsize.
SET ENVIRONMENT "DLL-CONVENTION" TO "0"

set ipifstructsize to size of numadapters.
CALL "@[display]:memcpy" USING
BY reference numadapters
BY value ipifptr
BY value ipifstructsize.

set ipifstructsize to size of ip-interface-info.
add 4 to ipifptr.
perform numadapters times
CALL "@[display]:memcpy" USING
BY reference ip-interface-info
BY value ipifptr
BY value ipifstructsize
end-call;
add max_adapter_name to ipifptr
end-perform.