06-19-2014
There's a couple things that make it hard to just give you a suggested solution...
First, the structure you're talking about it generally not just one structure. It's a linked list of structures, each one describing one address info "chunk" of information. So do you just want to copy one link in the chain, or the whole thing?
Second, a "struct sockaddr" might seem like a simple, friendly little thing. But it's not. It's really a placeholder structure for another structure, usually either a "struct sockaddr_in" or a "struct sockaddr_in6". So copying it requires you to do more work than you would have to do for a static structure with a consistent format.
And third, which is really minor compared to the other two, is that even if you just one this one particular chain in the link, some of the fields are pointers. So the logic just has to allocate separate chunks of memory for the various pieces.
Maybe if you explain a bit more about what you're trying to do it would help? Obviously this has something to do with some sort of host/service lookup and scanning through the results. But that doesn't narrow things down very much.
This User Gave Thanks to cnamejj For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I want to copy the durectory structure having subdirectories in it ... would be greatful if anyone could let me know ..
thanks in advance (6 Replies)
Discussion started by: myelvis
6 Replies
2. UNIX for Dummies Questions & Answers
i have a text file as.
/database/sp/NTR_Update_Imsi_List.sql
/database/sp/NTR_Update_Imsi_Range_List.sql
/database/sp/NTR_Vlr_Upload.sql
/database/tables/StatsTables.sql
/mib/ntr.mib
/mib/ntr.v2.mib
/scripts/operations/ntr/IMSITracer.ph
/scripts/operations/ntr/IMSITracer.pl ... (3 Replies)
Discussion started by: adddy
3 Replies
3. Shell Programming and Scripting
I have the below code to recurse through a given file path. I am able to go to the leaf level once recursively but traversing out is not possible as the required varaibles don't have the values on return. Both typeset and local don't work for my variable definitions. I have the o/p of the sample... (2 Replies)
Discussion started by: avrkiran
2 Replies
4. Shell Programming and Scripting
I am trying to write a script which has to copy the directory structure from my system to another system on the network. But I dont want the files to be copied.
I think I have to start with copying all subdirectories names in a directory to a system on the network.
Here's the case:
Source... (1 Reply)
Discussion started by: firefox211
1 Replies
5. Shell Programming and Scripting
Hello,
I am not sure how feasible is it, but trying to copy/create the folders from one box to another. I dont want to copy the content of folder otherwise it'd be too much of data..
The folder structure is quite complex (in deep hierarchy) and its a big effort manually ..
Please... (5 Replies)
Discussion started by: navsha
5 Replies
6. Shell Programming and Scripting
Hello,
i am having a source directory which consist of multiple sub directories and my destination folder is a empty directory.
if try to copy a file source->test->1.txt from source to destination test2 using the commaind.
cp source/test/1.txt desti/
It will copy the 1.txt under desti... (1 Reply)
Discussion started by: tsaravanan
1 Replies
7. UNIX for Advanced & Expert Users
Hi
I want to copy the structure from one place to another.
-> cd /hol/;
-> find . -type d | cpio -pvdm /abc/cat;
while copying the structure I want to exclude some directories like test1 and Test.
I have read somewhere that this can be done with -prune option.
Could anyone... (2 Replies)
Discussion started by: soumodeep123
2 Replies
8. Shell Programming and Scripting
hi,
I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE.
Note that i will have other files and directories which i dont want to copy to destination.
For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies
9. Shell Programming and Scripting
Hello All,
I have got a dev server and a production server will call it as D server and P server.
I have a dir structure in my D server and i need to create the same dir structure in P server also using a shell script.
If i do a find . in my D server, i am getting an o/p like :-
.
./vio... (9 Replies)
Discussion started by: Renjesh
9 Replies
10. Shell Programming and Scripting
HI All,
please help , i got same case . i want copy folder and directory create yesterday.
for sample below :
drwxr-xr-x 4 apps apps 33 Nov 23 04:00 xxxxxx@gmai.com
drwxr-xr-x 4 apps apps 33 Nov 23 04:00 yyyyyyy@gmail.com
drwxr-xr-x 4 apps apps 33 Nov 24 04:00... (2 Replies)
Discussion started by: fajar_3t3
2 Replies
LEARN ABOUT OSX
getifmaddrs
GETIFMADDRS(3) BSD Library Functions Manual GETIFMADDRS(3)
NAME
getifmaddrs -- get multicast group memberships
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
int
getifmaddrs(struct ifmaddrs **ifmap);
void
freeifmaddrs(struct ifmaddrs *ifmp);
DESCRIPTION
The getifmaddrs() function stores a reference to a linked list of the multicast memberships on the local machine in the memory referenced by
ifmap. The list consists of ifmaddrs structures, as defined in the include file <ifaddrs.h>. The ifmaddrs structure contains at least the
following entries:
struct ifmaddrs *ifma_next; /* Pointer to next struct */
struct sockaddr *ifma_name; /* Interface name (AF_LINK) */
struct sockaddr *ifma_addr; /* Multicast address */
struct sockaddr *ifma_lladdr; /* Link-layer translation, if any */
The ifma_next field contains a pointer to the next structure on the list. This field is NULL in last structure on the list.
The ifma_name field references an AF_LINK address structure, containing the name of the interface where the membership exists.
The ifma_addr references the address that this membership is for.
The ifma_lladdr field references a link-layer translation for the protocol-level address in ifma_addr, if one is set, otherwise it is NULL.
The data returned by getifmaddrs() is dynamically allocated and should be freed using freeifmaddrs() when no longer needed.
RETURN VALUES
The getifmaddrs() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to
indicate the error.
ERRORS
The getifmaddrs() may fail and set errno for any of the errors specified for the library routines malloc(3) or sysctl(3).
SEE ALSO
sysctl(3), networking(4), ifconfig(8)
HISTORY
The getifmaddrs() function first appeared in FreeBSD 5.2.
BUGS
If both <net/if.h> and <ifaddrs.h> are being included, <net/if.h> must be included before <ifaddrs.h>.
BSD
November 14, 2003 BSD