Added PCP third party option and made it's use an option.

This commit is contained in:
Markus Stenberg 2014-05-03 07:04:45 +03:00 committed by Thomas Bernard
parent 6d379d54f5
commit c801138c63
6 changed files with 10 additions and 4 deletions

View File

@ -995,6 +995,9 @@ init(int argc, char * * argv, struct runtime_vars * v)
max_lifetime = 86400;
}
break;
case UPNPPCPALLOWTHIRDPARTY:
allow_thirdparty = true;
break;
#endif
#ifdef PF_ENABLE_FILTER_RULES
case UPNPQUICKRULES:

View File

@ -65,6 +65,7 @@ static const struct {
#ifdef ENABLE_PCP
{ UPNPPCPMINLIFETIME, "min_lifetime"},
{ UPNPPCPMAXLIFETIME, "max_lifetime"},
{ UPNPPCPALLOWTHIRDPARTY, "allow_thirdparty"},
#endif
{ UPNPENABLE, "enable_upnp"},
#ifdef USE_PF

View File

@ -44,6 +44,7 @@ enum upnpconfigoptions {
UPNPENABLENATPMP, /* enable_natpmp */
UPNPPCPMINLIFETIME, /* minimum lifetime for PCP mapping */
UPNPPCPMAXLIFETIME, /* maximum lifetime for PCP mapping */
UPNPPCPALLOWTHIRDPARTY, /* allow third-party requests */
#ifdef USE_NETFILTER
UPNPFORWARDCHAIN,
UPNPNATCHAIN,

View File

@ -118,7 +118,7 @@ typedef struct pcp_info {
#endif
uint8_t is_map_op;
uint8_t is_peer_op;
int thirdp_present; /* indicate presence of the options */
const struct in6_addr *thirdp_ip;
int pfailure_present;
char senderaddrstr[INET_ADDRSTRLEN]; /* only if IPv4 sender */
@ -437,13 +437,13 @@ static int parsePCPOptions(void* pcp_buf, int* remainingSize,
syslog(LOG_DEBUG, "Third PARTY IP: \t %s\n", inet_ntop(AF_INET6,
&(opt_3rd->ip), third_addr, INET6_ADDRSTRLEN));
#endif
if (pcp_msg_info->thirdp_present != 0 ) {
if (pcp_msg_info->thirdp_ip ) {
syslog(LOG_ERR, "PCP: THIRD PARTY OPTION was already present. \n");
pcp_msg_info->result_code = PCP_ERR_MALFORMED_OPTION;
}
else {
pcp_msg_info->thirdp_present = 1;
pcp_msg_info->thirdp_ip = &opt_3rd -> ip;
}
processed += sizeof(pcp_3rd_party_option_t);

View File

@ -34,6 +34,7 @@ time_t startup_time = 0;
/* for PCP */
unsigned long int min_lifetime = 120;
unsigned long int max_lifetime = 86400;
int allow_thirdparty = 0;
#endif
int runtime_flags = 0;

View File

@ -34,7 +34,7 @@ extern time_t startup_time;
extern unsigned long int min_lifetime;
extern unsigned long int max_lifetime;
extern int allow_thirdparty;
/* runtime boolean flags */
extern int runtime_flags;