MCPcopy Create free account
hub / github.com/F-Stack/f-stack / AddLink

Function AddLink

freebsd/netinet/libalias/alias_db.c:913–1047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

911}
912
913struct alias_link *
914AddLink(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr,
915 struct in_addr alias_addr, u_short src_port, u_short dst_port,
916 int alias_port_param, int link_type)
917{
918 u_int start_point;
919 struct alias_link *lnk;
920
921 LIBALIAS_LOCK_ASSERT(la);
922 lnk = malloc(sizeof(struct alias_link));
923 if (lnk != NULL) {
924 /* Basic initialization */
925 lnk->la = la;
926 lnk->src_addr = src_addr;
927 lnk->dst_addr = dst_addr;
928 lnk->alias_addr = alias_addr;
929 lnk->proxy_addr.s_addr = INADDR_ANY;
930 lnk->src_port = src_port;
931 lnk->dst_port = dst_port;
932 lnk->proxy_port = 0;
933 lnk->server = NULL;
934 lnk->link_type = link_type;
935#ifndef NO_USE_SOCKETS
936 lnk->sockfd = -1;
937#endif
938 lnk->flags = 0;
939 lnk->pflags = 0;
940 lnk->timestamp = la->timeStamp;
941
942 /* Expiration time */
943 switch (link_type) {
944 case LINK_ICMP:
945 lnk->expire_time = ICMP_EXPIRE_TIME;
946 break;
947 case LINK_UDP:
948 lnk->expire_time = UDP_EXPIRE_TIME;
949 break;
950 case LINK_TCP:
951 lnk->expire_time = TCP_EXPIRE_INITIAL;
952 break;
953 case LINK_PPTP:
954 lnk->flags |= LINK_PERMANENT; /* no timeout. */
955 break;
956 case LINK_FRAGMENT_ID:
957 lnk->expire_time = FRAGMENT_ID_EXPIRE_TIME;
958 break;
959 case LINK_FRAGMENT_PTR:
960 lnk->expire_time = FRAGMENT_PTR_EXPIRE_TIME;
961 break;
962 case LINK_ADDR:
963 break;
964 default:
965 lnk->expire_time = PROTO_EXPIRE_TIME;
966 break;
967 }
968
969 /* Determine alias flags */
970 if (dst_addr.s_addr == INADDR_ANY)

Callers 15

AliasHandleFtpInFunction · 0.85
NewFtpMessageFunction · 0.85
ReLinkFunction · 0.85
FindIcmpInFunction · 0.85
FindIcmpOutFunction · 0.85
FindFragmentIn1Function · 0.85
AddFragmentPtrLinkFunction · 0.85
FindProtoInFunction · 0.85
FindProtoOutFunction · 0.85
FindUdpTcpInFunction · 0.85
FindUdpTcpOutFunction · 0.85
AddPptpFunction · 0.85

Calls 6

mallocFunction · 0.85
GetNewPortFunction · 0.85
StartPointOutFunction · 0.85
StartPointInFunction · 0.85
ShowAliasStatsFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected