42#include <sys/socket.h>
43#include <netinet/in.h>
52static void *add_filter_option(
pcp_flow_t *f,
void *cur)
69static void *add_prefer_failure_option(
void *cur)
81static void *add_third_party_option(
pcp_flow_t *f,
void *cur)
94#ifdef PCP_EXPERIMENTAL
95static void *add_userid_option(
pcp_flow_t *f,
void *cur)
107static void *add_location_option(
pcp_flow_t *f,
void *cur)
119static void *add_deviceid_option(
pcp_flow_t *f,
void *cur)
134#ifdef PCP_FLOW_PRIORITY
135static void *add_flowp_option(
pcp_flow_t *f,
void *cur)
141 flowp_op->
dscp_up=f->flowp_dscp_up;
149#ifdef PCP_EXPERIMENTAL
153 size_t len_md=md->val_len;
154 uint32_t padding=(4 - (len_md % 4)) % 4;
164 memcpy(md_opt->
metadata, md->val_buf, len_md);
170static void *add_md_options(
pcp_flow_t *f,
void *cur)
176 for (i=f->md_val_count, md=f->md_vals; i>0 && md!=NULL; --i, ++md)
179 md_opt = add_md_option(f, md_opt, md);
188#ifdef PCP_FLOW_PRIORITY
189 if (flow->flowp_option_present) {
190 cur=add_flowp_option(flow, cur);
194 cur=add_filter_option(flow, cur);
198 cur=add_prefer_failure_option(cur);
201 cur=add_third_party_option(flow, cur);
203#ifdef PCP_EXPERIMENTAL
204 if (flow->f_deviceid.deviceid[0] !=
'\0') {
205 cur=add_deviceid_option(flow, cur);
208 if (flow->f_userid.userid[0] !=
'\0') {
209 cur=add_userid_option(flow, cur);
212 if (flow->f_location.location[0] !=
'\0') {
213 cur=add_location_option(flow, cur);
216 if (flow->md_val_count>0) {
217 cur=add_md_options(flow, cur);
240 sizeof(peer_info->
ext_ip));
252 sizeof(peer_info->
ext_ip));
260 return build_pcp_options(flow, next);
275 sizeof(map_info->
ext_ip));
284 sizeof(map_info->
ext_ip));
291 return build_pcp_options(flow, next);
310 fill_len=(4-((flow->sadscp.app_name_length+2)%4))%4;
313 if (flow->sadscp_app_name) {
314 memcpy(sadscp->
app_name, flow->sadscp_app_name,
315 flow->sadscp.app_name_length);
318 flow->sadscp.app_name_length);
327 return build_pcp_options(flow, next);
331#ifndef PCP_DISABLE_NATPMP
376 void *next_data=NULL;
394 "Malloc can't allocate enough memory for the pcp_flow.");
404#ifndef PCP_DISABLE_NATPMP
405 ret=build_natpmp_msg(flow);
414 memcpy(&req->ip, &flow->
kd.
src_ip, 16);
416 next_data=req->next_data;
421 ret=build_pcp_peer(
pcp_server, flow, next_data);
424 ret=build_pcp_map(
pcp_server, flow, next_data);
428 ret=build_pcp_sadscp(
pcp_server, flow, next_data);
464 "Received packet without response bit set");
470 "Received PCP msg using unsupported PCP version %d", resp->
ver);
499 return parse_options(f, m + 1);
521 return parse_options(f, m + 1);
544 return parse_options(f, m + 1);
568 return parse_options(f, m + 1);
590#ifndef PCP_DISABLE_NATPMP
619 IPPROTO_TCP : IPPROTO_UDP);
655 return parse_v1_peer(f, resp->
next_data);
676 return parse_v2_peer(f, resp->
next_data);
692 memset(&f->
kd, 0,
sizeof(f->
kd));
700#ifndef PCP_DISABLE_NATPMP
702 return parse_v0_resp(f, resp);
706 return parse_v1_resp(f, resp);
709 return parse_v2_resp(f, resp);
#define PCP_MAX_SUPPORTED_VERSION
pcp_server_t * get_pcp_server(pcp_ctx_t *ctx, int pcp_server_index)
#define PCP_LOG_END(level)
#define PCP_LOG_BEGIN(level)
#define PCP_LOG(level, fmt,...)
int validate_pcp_msg(pcp_recv_msg_t *f)
void * build_pcp_msg(pcp_flow_t *flow)
pcp_errno parse_response(pcp_recv_msg_t *f)
#define NATPMP_OPCODE_MAP_UDP
@ PCP_OPTION_FLOW_PRIORITY
#define NATPMP_OPCODE_ANNOUNCE
#define PCP_RES_UNSUPP_OPCODE
#define PCP_OPCODE_ANNOUNCE
struct pcp_sadscp_req pcp_sadscp_req_t
#define NATPMP_OPCODE_MAP_TCP
#define PCP_RES_UNSUPP_PROTOCOL
#define PCP_OPCODE_SADSCP
struct flow_key_data::mp_keydata map_peer
char deviceid[MAX_DEVICE_ID]
uint32_t filter_peer_ip[4]
uint16_t filter_peer_port
uint8_t third_party_option_present
uint8_t filter_option_present
struct in6_addr third_party_ip
struct in6_addr filter_ip
struct pcp_flow_s::@6::@8 map_peer
uint8_t pfailure_option_present
char location[MAX_GEO_STR]
char pcp_msg_buffer[PCP_MAX_LEN]
uint16_t assigned_ext_port
struct in6_addr assigned_ext_ip