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

Function LibAliasProxyRule

freebsd/netinet/libalias/alias_proxy.c:520–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518*/
519
520int
521LibAliasProxyRule(struct libalias *la, const char *cmd)
522{
523/*
524 * This function takes command strings of the form:
525 *
526 * server <addr>[:<port>]
527 * [port <port>]
528 * [rule n]
529 * [proto tcp|udp]
530 * [src <addr>[/n]]
531 * [dst <addr>[/n]]
532 * [type encode_tcp_stream|encode_ip_hdr|no_encode]
533 *
534 * delete <rule number>
535 *
536 * Subfields can be in arbitrary order. Port numbers and addresses
537 * must be in either numeric or symbolic form. An optional rule number
538 * is used to control the order in which rules are searched. If two
539 * rules have the same number, then search order cannot be guaranteed,
540 * and the rules should be disjoint. If no rule number is specified,
541 * then 0 is used, and group 0 rules are always checked before any
542 * others.
543 */
544 int i, n, len, ret;
545 int cmd_len;
546 int token_count;
547 int state;
548 char *token;
549 char buffer[256];
550 char str_port[sizeof(buffer)];
551 char str_server_port[sizeof(buffer)];
552 char *res = buffer;
553
554 int rule_index;
555 int proto;
556 int proxy_type;
557 int proxy_port;
558 int server_port;
559 struct in_addr server_addr;
560 struct in_addr src_addr, src_mask;
561 struct in_addr dst_addr, dst_mask;
562 struct proxy_entry *proxy_entry;
563
564 LIBALIAS_LOCK(la);
565 ret = 0;
566/* Copy command line into a buffer */
567 cmd += strspn(cmd, " \t");
568 cmd_len = strlen(cmd);
569 if (cmd_len > (int)(sizeof(buffer) - 1)) {
570 ret = -1;
571 goto getout;
572 }
573 strcpy(buffer, cmd);
574
575/* Convert to lower case */
576 len = strlen(buffer);
577 for (i = 0; i < len; i++)

Callers 1

ng_nat_rcvmsgFunction · 0.85

Calls 11

strspnFunction · 0.85
tolowerFunction · 0.85
IpMaskFunction · 0.85
strsepFunction · 0.85
strcmpFunction · 0.85
IpAddrFunction · 0.85
sscanfFunction · 0.85
RuleNumberDeleteFunction · 0.85
IpPortFunction · 0.85
mallocFunction · 0.85
RuleAddFunction · 0.85

Tested by

no test coverage detected