Skip to content

Commit

Permalink
automatic commit at releng box
Browse files Browse the repository at this point in the history
  • Loading branch information
mc36 committed Mar 3, 2022
1 parent be66ae7 commit 07b51f8
Show file tree
Hide file tree
Showing 8 changed files with 686 additions and 309 deletions.
27 changes: 27 additions & 0 deletions misc/native/p4fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,16 @@ void adjustMss(unsigned char *bufD, int bufT, int mss) {
put16msb(bufD, bufP, ethtyp);


#define putGtpHeader \
*bufP -= 10; \
put16msb(bufD, *bufP + 0, 0x32ff); \
tmp = *bufS - *bufP + preBuff - 8; \
put16msb(bufD, *bufP + 2, tmp); \
put32msb(bufD, *bufP + 4, neigh_res->tid); \
neigh_res->seq++; \
put16msb(bufD, *bufP + 8, neigh_res->seq); \
put16msb(bufD, *bufP + 10, 0);



int macsec_apply(int prt, EVP_CIPHER_CTX *encrCtx, EVP_MD_CTX *hashCtx, unsigned char *bufD, int *bufP, int *bufS, unsigned char *bufH, int *ethtyp, int sgt) {
Expand Down Expand Up @@ -795,6 +805,16 @@ int send2neigh(struct neigh_entry *neigh_res, EVP_CIPHER_CTX *encrCtx, EVP_MD_CT
putUdpHeader(*bufP, *bufS, neigh_res->sprt, neigh_res->dprt, neigh_res->sip1, neigh_res->sip2, neigh_res->sip3, neigh_res->sip4, neigh_res->dip1, neigh_res->dip2, neigh_res->dip3, neigh_res->dip4);
putIpv6header(*bufP, *bufS, *ethtyp, 17, neigh_res->sip1, neigh_res->sip2, neigh_res->sip3, neigh_res->sip4, neigh_res->dip1, neigh_res->dip2, neigh_res->dip3, neigh_res->dip4);
break;
case 17: // gtp4
putGtpHeader;
putUdpHeader(*bufP, *bufS, neigh_res->sprt, neigh_res->dprt, neigh_res->sip1, 0, 0, 0, neigh_res->dip1, 0, 0, 0);
putIpv4header(*bufP, *bufS, *ethtyp, 17, neigh_res->sip1, neigh_res->dip1);
break;
case 18: // gtp6
putGtpHeader;
putUdpHeader(*bufP, *bufS, neigh_res->sprt, neigh_res->dprt, neigh_res->sip1, neigh_res->sip2, neigh_res->sip3, neigh_res->sip4, neigh_res->dip1, neigh_res->dip2, neigh_res->dip3, neigh_res->dip4);
putIpv6header(*bufP, *bufS, *ethtyp, 17, neigh_res->sip1, neigh_res->sip2, neigh_res->sip3, neigh_res->sip4, neigh_res->dip1, neigh_res->dip2, neigh_res->dip3, neigh_res->dip4);
break;
default:
doDropper;
}
Expand Down Expand Up @@ -998,6 +1018,13 @@ void doFlood(struct table_head flood, EVP_CIPHER_CTX *encrCtx, EVP_MD_CTX *hashC
bufP -= 2; \
put16msb(bufD, bufP, ethtyp); \
break; \
case 11: \
bufP = bufT + 8; \
bufP += 12; \
guessEthtyp; \
bufP -= 2; \
put16msb(bufD, bufP, ethtyp); \
break; \
default: \
doDropper; \
} \
Expand Down
58 changes: 58 additions & 0 deletions misc/native/p4msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,64 @@ int doOneCommand(unsigned char* buf) {
else table_add(&vrf2rib_res->tun, &tun6_ntry);
return 0;
}
if (strcmp(arg[0], "gtp4") == 0) {
neigh_ntry.id = atoi(arg[2]);
tun4_ntry.aclport = neigh_ntry.aclport = atoi(arg[3]);
neigh_ntry.port = atoi(arg[4]);
inet_pton(AF_INET, arg[5], buf2);
tun4_ntry.trgAddr = neigh_ntry.sip1 = get32msb(buf2, 0);
inet_pton(AF_INET, arg[6], buf2);
tun4_ntry.srcAddr = neigh_ntry.dip1 = get32msb(buf2, 0);
vrf2rib_ntry.vrf = neigh_ntry.vrf = atoi(arg[8]);
vrf2rib_res = vrf2rib_init4;
str2mac(neigh_ntry.dmac, arg[7]);
str2mac(neigh_ntry.smac, arg[9]);
neigh_ntry.command = 17;
neigh_ntry.sprt = atoi(arg[10]);
neigh_ntry.dprt = atoi(arg[11]);
neigh_ntry.tid = atoi(arg[12]);
tun4_ntry.srcPort = neigh_ntry.dprt;
tun4_ntry.trgPort = neigh_ntry.sprt;
tun4_ntry.prot = 17;
tun4_ntry.command = 11;
if (del == 0) table_del(&neigh_table, &neigh_ntry);
else table_add(&neigh_table, &neigh_ntry);
if (del == 0) table_del(&vrf2rib_res->tun, &tun4_ntry);
else table_add(&vrf2rib_res->tun, &tun4_ntry);
return 0;
}
if (strcmp(arg[0], "gtp6") == 0) {
neigh_ntry.id = atoi(arg[2]);
tun6_ntry.aclport = neigh_ntry.aclport = atoi(arg[3]);
neigh_ntry.port = atoi(arg[4]);
inet_pton(AF_INET6, arg[5], buf2);
tun6_ntry.trgAddr1 = neigh_ntry.sip1 = get32msb(buf2, 0);
tun6_ntry.trgAddr2 = neigh_ntry.sip2 = get32msb(buf2, 4);
tun6_ntry.trgAddr3 = neigh_ntry.sip3 = get32msb(buf2, 8);
tun6_ntry.trgAddr4 = neigh_ntry.sip4 = get32msb(buf2, 12);
inet_pton(AF_INET6, arg[6], buf2);
tun6_ntry.srcAddr1 = neigh_ntry.dip1 = get32msb(buf2, 0);
tun6_ntry.srcAddr2 = neigh_ntry.dip2 = get32msb(buf2, 4);
tun6_ntry.srcAddr3 = neigh_ntry.dip3 = get32msb(buf2, 8);
tun6_ntry.srcAddr4 = neigh_ntry.dip4 = get32msb(buf2, 12);
vrf2rib_ntry.vrf = neigh_ntry.vrf = atoi(arg[8]);
vrf2rib_res = vrf2rib_init6;
str2mac(neigh_ntry.dmac, arg[7]);
str2mac(neigh_ntry.smac, arg[9]);
neigh_ntry.command = 18;
neigh_ntry.sprt = atoi(arg[10]);
neigh_ntry.dprt = atoi(arg[11]);
neigh_ntry.tid = atoi(arg[12]);
tun6_ntry.srcPort = neigh_ntry.dprt;
tun6_ntry.trgPort = neigh_ntry.sprt;
tun6_ntry.prot = 17;
tun6_ntry.command = 11;
if (del == 0) table_del(&neigh_table, &neigh_ntry);
else table_add(&neigh_table, &neigh_ntry);
if (del == 0) table_del(&vrf2rib_res->tun, &tun6_ntry);
else table_add(&vrf2rib_res->tun, &tun6_ntry);
return 0;
}
if (strcmp(arg[0], "sgttag") == 0) {
port2vrf_ntry.port = atoi(arg[2]);
port2vrf_res = port2vrf_init(&port2vrf_ntry);
Expand Down
6 changes: 3 additions & 3 deletions misc/native/p4tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ int route6_bitter(void *ptr, int pos) {
struct neigh_entry {
int id;
int vrf;
int command; // 1=rawip, 2=pppoe, 3=gre4, 4=gre6, 5=l2tp4, 6=l2tp6, 7=ipip4, 8=ipip6, 9=esp4, 10=esp6, 11=ovpn4, 12=ovpn6, 13=wg4. 14=wg6, 15=amt4, 16=amt6
int command; // 1=rawip, 2=pppoe, 3=gre4, 4=gre6, 5=l2tp4, 6=l2tp6, 7=ipip4, 8=ipip6, 9=esp4, 10=esp6, 11=ovpn4, 12=ovpn6, 13=wg4. 14=wg6, 15=amt4, 16=amt6, 17=gtp4, 18=gtp6
int port;
int aclport;
int session;
Expand Down Expand Up @@ -814,7 +814,7 @@ struct tun4_entry {
int trgAddr;
int srcPort;
int trgPort;
int command; // 1=gre, 2=l2tp, 3=vxlan, 4=ip4ip, 5=ip6ip, 6=esp, 7=pckoudp, 8=openvpn, 9=wireguard, 10=amt
int command; // 1=gre, 2=l2tp, 3=vxlan, 4=ip4ip, 5=ip6ip, 6=esp, 7=pckoudp, 8=openvpn, 9=wireguard, 10=amt, 11=gtp
int aclport;
int spi;
unsigned char encrKeyDat[256];
Expand Down Expand Up @@ -860,7 +860,7 @@ struct tun6_entry {
int trgAddr4;
int srcPort;
int trgPort;
int command; // 1=gre, 2=l2tp, 3=vxlan, 4=ip4ip, 5=ip6ip, 6=esp, 7=pckoudp, 8=openvpn, 9=wireguard, 10=amt
int command; // 1=gre, 2=l2tp, 3=vxlan, 4=ip4ip, 5=ip6ip, 6=esp, 7=pckoudp, 8=openvpn, 9=wireguard, 10=amt, 11=gtp
int aclport;
int spi;
unsigned char encrKeyDat[256];
Expand Down
63 changes: 60 additions & 3 deletions src/net/freertr/clnt/clntGtp.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,20 @@ public clntGtp() {

private prtGenConn connD;

private int teidLoc;
/**
* local tunnel id
*/
public int teidLoc;

private int teidDat;
/**
* data tunnel id
*/
public int teidDat;

private int teidCtr;
/**
* control tunnel id
*/
public int teidCtr;

private int seqCtr;

Expand All @@ -127,6 +136,54 @@ public String toString() {
return "gtp to " + target;
}

/**
* get remote address
*
* @return address
*/
public addrIP getRemAddr() {
if (teidDat == 0) {
return null;
}
return connD.peerAddr.copyBytes();
}

/**
* get local address
*
* @return address
*/
public addrIP getLocAddr() {
if (teidDat == 0) {
return null;
}
return connD.iface.addr.copyBytes();
}

/**
* get remote port
*
* @return address
*/
public int getRemPort() {
if (teidDat == 0) {
return 0;
}
return connD.portRem;
}

/**
* get local port
*
* @return address
*/
public int getLocPort() {
if (teidDat == 0) {
return 0;
}
return connD.portLoc;
}

/**
* get hw address
*
Expand Down

0 comments on commit 07b51f8

Please sign in to comment.