Lines 67-74
Link Here
|
67 |
struct porttab *next; |
67 |
struct porttab *next; |
68 |
}; |
68 |
}; |
69 |
|
69 |
|
70 |
|
70 |
#if defined(HASNOTRPC) |
|
|
71 |
static struct porttab **Pth[2] = { NULL, NULL }; |
72 |
#else /* !defined(HASNOTRPC) */ |
71 |
static struct porttab **Pth[4] = { NULL, NULL, NULL, NULL }; |
73 |
static struct porttab **Pth[4] = { NULL, NULL, NULL, NULL }; |
|
|
74 |
#endif /* !defined(HASNOTRPC) */ |
72 |
/* port hash buckets: |
75 |
/* port hash buckets: |
73 |
* Pth[0] for TCP service names |
76 |
* Pth[0] for TCP service names |
74 |
* Pth[1] for UDP service names |
77 |
* Pth[1] for UDP service names |
Lines 78-89
Link Here
|
78 |
#define HASHPORT(p) (((((int)(p)) * 31415) >> 3) & (PORTHASHBUCKETS - 1)) |
81 |
#define HASHPORT(p) (((((int)(p)) * 31415) >> 3) & (PORTHASHBUCKETS - 1)) |
79 |
|
82 |
|
80 |
|
83 |
|
|
|
84 |
#if !defined(HASNOTRPC) |
81 |
_PROTOTYPE(static void fill_portmap,(void)); |
85 |
_PROTOTYPE(static void fill_portmap,(void)); |
|
|
86 |
_PROTOTYPE(static void update_portmap,(struct porttab *pt, char *pn)); |
87 |
#endif /* !defined(HASNOTRPC) */ |
82 |
_PROTOTYPE(static void fill_porttab,(void)); |
88 |
_PROTOTYPE(static void fill_porttab,(void)); |
83 |
_PROTOTYPE(static char *lkup_port,(int p, int pr, int src)); |
89 |
_PROTOTYPE(static char *lkup_port,(int p, int pr, int src)); |
84 |
_PROTOTYPE(static char *lkup_svcnam,(int h, int p, int pr, int ss)); |
90 |
_PROTOTYPE(static char *lkup_svcnam,(int h, int p, int pr, int ss)); |
85 |
_PROTOTYPE(static int printinaddr,(void)); |
91 |
_PROTOTYPE(static int printinaddr,(void)); |
86 |
_PROTOTYPE(static void update_portmap,(struct porttab *pt, char *pn)); |
|
|
87 |
|
92 |
|
88 |
|
93 |
|
89 |
/* |
94 |
/* |
Lines 104-109
Link Here
|
104 |
} |
109 |
} |
105 |
|
110 |
|
106 |
|
111 |
|
|
|
112 |
#if !defined(HASNOTRPC) |
107 |
/* |
113 |
/* |
108 |
* fill_portmap() -- fill the RPC portmap program name table via a conversation |
114 |
* fill_portmap() -- fill the RPC portmap program name table via a conversation |
109 |
* with the portmapper |
115 |
* with the portmapper |
Lines 267-272
Link Here
|
267 |
} |
273 |
} |
268 |
clnt_destroy(c); |
274 |
clnt_destroy(c); |
269 |
} |
275 |
} |
|
|
276 |
#endif /* !defined(HASNOTRPC) */ |
270 |
|
277 |
|
271 |
|
278 |
|
272 |
/* |
279 |
/* |
Lines 468-475
Link Here
|
468 |
* If the hash buckets haven't been allocated, do so. |
475 |
* If the hash buckets haven't been allocated, do so. |
469 |
*/ |
476 |
*/ |
470 |
if (!Pth[0]) { |
477 |
if (!Pth[0]) { |
|
|
478 |
#if defined(HASNOTRPC) |
479 |
for (h = 0; h < 2; h++) { |
480 |
#else /* !defined(HASNOTRPC) */ |
471 |
nh = FportMap ? 4 : 2; |
481 |
nh = FportMap ? 4 : 2; |
472 |
for (h = 0; h < nh; h++) { |
482 |
for (h = 0; h < nh; h++) { |
|
|
483 |
#endif /* !defined(HASNOTRPC) */ |
473 |
if (!(Pth[h] = (struct porttab **)calloc(PORTHASHBUCKETS, |
484 |
if (!(Pth[h] = (struct porttab **)calloc(PORTHASHBUCKETS, |
474 |
sizeof(struct porttab *)))) |
485 |
sizeof(struct porttab *)))) |
475 |
{ |
486 |
{ |
Lines 483-488
Link Here
|
483 |
} |
494 |
} |
484 |
} |
495 |
} |
485 |
} |
496 |
} |
|
|
497 |
#if !defined(HASNOTRPC) |
486 |
/* |
498 |
/* |
487 |
* If we're looking up program names for portmapped ports, make sure the |
499 |
* If we're looking up program names for portmapped ports, make sure the |
488 |
* portmap table has been loaded. |
500 |
* portmap table has been loaded. |
Lines 491-501
Link Here
|
491 |
(void) fill_portmap(); |
503 |
(void) fill_portmap(); |
492 |
pm++; |
504 |
pm++; |
493 |
} |
505 |
} |
|
|
506 |
#endif /* !defined(HASNOTRPC) */ |
494 |
/* |
507 |
/* |
495 |
* Hash the port and see if its name has been cached. Look for a local |
508 |
* Hash the port and see if its name has been cached. Look for a local |
496 |
* port first in the portmap, if portmap searching is enabled. |
509 |
* port first in the portmap, if portmap searching is enabled. |
497 |
*/ |
510 |
*/ |
498 |
h = HASHPORT(p); |
511 |
h = HASHPORT(p); |
|
|
512 |
#if !defined(HASNOTRPC) |
499 |
if (!src && FportMap) { |
513 |
if (!src && FportMap) { |
500 |
for (pt = Pth[pr+2][h]; pt; pt = pt->next) { |
514 |
for (pt = Pth[pr+2][h]; pt; pt = pt->next) { |
501 |
if (pt->port != p) |
515 |
if (pt->port != p) |
Lines 511-516
Link Here
|
511 |
return(pt->name); |
525 |
return(pt->name); |
512 |
} |
526 |
} |
513 |
} |
527 |
} |
|
|
528 |
#endif /* !defined(HASNOTRPC) */ |
514 |
for (pt = Pth[pr][h]; pt; pt = pt->next) { |
529 |
for (pt = Pth[pr][h]; pt; pt = pt->next) { |
515 |
if (pt->port == p) |
530 |
if (pt->port == p) |
516 |
return(pt->name); |
531 |
return(pt->name); |
Lines 1154-1160
Link Here
|
1154 |
* Process the port number. |
1169 |
* Process the port number. |
1155 |
*/ |
1170 |
*/ |
1156 |
if (Lf->li[i].p > 0) { |
1171 |
if (Lf->li[i].p > 0) { |
1157 |
if (Fport || FportMap) { |
1172 |
if (Fport |
|
|
1173 |
#if !defined(HASNOTRPC) |
1174 |
|| FportMap |
1175 |
#endif /* !defined(HASNOTRPC) */ |
1176 |
) { |
1158 |
|
1177 |
|
1159 |
/* |
1178 |
/* |
1160 |
* If converting port numbers to service names, or looking |
1179 |
* If converting port numbers to service names, or looking |
Lines 1167-1175
Link Here
|
1167 |
* loopback address 127.0.0.1. (Test 2 may not always work |
1186 |
* loopback address 127.0.0.1. (Test 2 may not always work |
1168 |
* -- e.g., on hosts with multiple interfaces.) |
1187 |
* -- e.g., on hosts with multiple interfaces.) |
1169 |
*/ |
1188 |
*/ |
|
|
1189 |
#if !defined(HASNOTRPC) |
1170 |
if ((src = i) && FportMap) { |
1190 |
if ((src = i) && FportMap) { |
1171 |
|
1191 |
|
1172 |
#if defined(HASIPv6) |
1192 |
# if defined(HASIPv6) |
1173 |
if (Lf->li[0].af == AF_INET6) { |
1193 |
if (Lf->li[0].af == AF_INET6) { |
1174 |
if (IN6_IS_ADDR_LOOPBACK(&Lf->li[i].ia.a6) |
1194 |
if (IN6_IS_ADDR_LOOPBACK(&Lf->li[i].ia.a6) |
1175 |
|| IN6_ARE_ADDR_EQUAL(&Lf->li[0].ia.a6, |
1195 |
|| IN6_ARE_ADDR_EQUAL(&Lf->li[0].ia.a6, |
Lines 1177-1183
Link Here
|
1177 |
) |
1197 |
) |
1178 |
src = 0; |
1198 |
src = 0; |
1179 |
} else |
1199 |
} else |
1180 |
#endif /* defined(HASIPv6) */ |
1200 |
# endif /* defined(HASIPv6) */ |
1181 |
|
1201 |
|
1182 |
if (Lf->li[0].af == AF_INET) { |
1202 |
if (Lf->li[0].af == AF_INET) { |
1183 |
if (Lf->li[i].ia.a4.s_addr == htonl(INADDR_LOOPBACK) |
1203 |
if (Lf->li[i].ia.a4.s_addr == htonl(INADDR_LOOPBACK) |
Lines 1186-1191
Link Here
|
1186 |
src = 0; |
1206 |
src = 0; |
1187 |
} |
1207 |
} |
1188 |
} |
1208 |
} |
|
|
1209 |
#endif /* !defined(HASNOTRPC) */ |
1189 |
if (strcasecmp(Lf->iproto, "TCP") == 0) |
1210 |
if (strcasecmp(Lf->iproto, "TCP") == 0) |
1190 |
port = lkup_port(Lf->li[i].p, 0, src); |
1211 |
port = lkup_port(Lf->li[i].p, 0, src); |
1191 |
else if (strcasecmp(Lf->iproto, "UDP") == 0) |
1212 |
else if (strcasecmp(Lf->iproto, "UDP") == 0) |
Lines 2748-2753
Link Here
|
2748 |
} |
2769 |
} |
2749 |
|
2770 |
|
2750 |
|
2771 |
|
|
|
2772 |
#if !defined(HASNOTRPC) |
2751 |
/* |
2773 |
/* |
2752 |
* update_portmap() - update a portmap entry with its port number or service |
2774 |
* update_portmap() - update a portmap entry with its port number or service |
2753 |
* name |
2775 |
* name |
Lines 2780-2782
Link Here
|
2780 |
pt->nl = nl; |
2802 |
pt->nl = nl; |
2781 |
pt->ss = 1; |
2803 |
pt->ss = 1; |
2782 |
} |
2804 |
} |
|
|
2805 |
#endif /* !defined(HASNOTRPC) */ |