mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-30 20:10:53 +00:00
Permit unregister of all names for port.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3160 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
76c8b1c762
commit
11e77a91fd
2 changed files with 66 additions and 12 deletions
|
@ -425,6 +425,44 @@ map_by_name(uptr n, int s)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name - map_by_port()
|
||||||
|
* Purpose - Search the map for an entry for a particular port
|
||||||
|
*/
|
||||||
|
static map_ent*
|
||||||
|
map_by_port(unsigned p, unsigned char t)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
|
||||||
|
if (debug > 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Searching map for %u:%x\n", p, t);
|
||||||
|
}
|
||||||
|
for (index = 0; index < map_used; index++)
|
||||||
|
{
|
||||||
|
map_ent *e = map[index];
|
||||||
|
|
||||||
|
if (e->port == p && (e->net | e->svc) == t)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index < map_used)
|
||||||
|
{
|
||||||
|
if (debug > 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Found port %d with name %.*s\n",
|
||||||
|
map[index]->port, map[index]->name);
|
||||||
|
}
|
||||||
|
return(map[index]);
|
||||||
|
}
|
||||||
|
if (debug > 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to find map entry for %u:%x\n", p, t);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name - map_del()
|
* Name - map_del()
|
||||||
* Purpose - Remove a mapping entry from the map and release
|
* Purpose - Remove a mapping entry from the map and release
|
||||||
|
@ -1885,6 +1923,8 @@ handle_request(int desc)
|
||||||
clear_chan(desc);
|
clear_chan(desc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (port == 0 || size > 0)
|
||||||
|
{
|
||||||
m = map_by_name(buf, size);
|
m = map_by_name(buf, size);
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
|
@ -1892,7 +1932,7 @@ handle_request(int desc)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Attempt to unregister with wrong type\n");
|
fprintf(stderr, "Attempted unregister with wrong type\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1909,6 +1949,16 @@ handle_request(int desc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(unsigned long*)w_info[desc].buf = 0;
|
||||||
|
while ((m = map_by_port(port, ptype)) != 0)
|
||||||
|
{
|
||||||
|
*(unsigned long*)w_info[desc].buf = htonl(m->port);
|
||||||
|
map_del(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (type == GDO_SERVERS)
|
else if (type == GDO_SERVERS)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -2783,13 +2833,13 @@ doregister(const char *name, int port, int ptype)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unregister(const char *name, int ptype)
|
unregister(const char *name, int port, int ptype)
|
||||||
{
|
{
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
int found;
|
int found;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
found = nameServer(name, 0, GDO_UNREG, ptype, &sin, 0, 1);
|
found = nameServer(name, 0, GDO_UNREG, ptype, &sin, port, 1);
|
||||||
for (i = 0; i < found; i++)
|
for (i = 0; i < found; i++)
|
||||||
{
|
{
|
||||||
printf("Unregistered %s on '%s' port %d\n", name,
|
printf("Unregistered %s on '%s' port %d\n", name,
|
||||||
|
@ -2943,7 +2993,7 @@ printf(
|
||||||
fprintf(stderr, "-M flag is ignored for unregistration.\n");
|
fprintf(stderr, "-M flag is ignored for unregistration.\n");
|
||||||
fprintf(stderr, "Operation will take place locally.\n");
|
fprintf(stderr, "Operation will take place locally.\n");
|
||||||
}
|
}
|
||||||
unregister(optarg, ptype);
|
unregister(optarg, port, ptype);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
|
|
|
@ -65,10 +65,14 @@
|
||||||
* or zero if the named server was already registered.
|
* or zero if the named server was already registered.
|
||||||
*
|
*
|
||||||
* GDO_UNREG Un-register the server name and return old port number.
|
* GDO_UNREG Un-register the server name and return old port number.
|
||||||
|
* If the server name is of length zero, and the port is
|
||||||
|
* non-zero then all names for the port are unregistered.
|
||||||
* This service is only available to a process on the
|
* This service is only available to a process on the
|
||||||
* same host as this name server.
|
* same host as this name server.
|
||||||
* Response is the old port number in network byte order,
|
* Response is the old port number in network byte order,
|
||||||
* or zero if the name could not be un-registered.
|
* or zero if the name could not be un-registered.
|
||||||
|
* If multiple names were unregistered the response is
|
||||||
|
* the port for those names.
|
||||||
*
|
*
|
||||||
* GDO_SERVERS Return a list of the known servers on the local net.
|
* GDO_SERVERS Return a list of the known servers on the local net.
|
||||||
* Response is an unsigned long (in network byte order)
|
* Response is an unsigned long (in network byte order)
|
||||||
|
|
Loading…
Reference in a new issue