mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-04 05:53:26 +00:00 
			
		
		
		
	nat: Add hook for rewriting a setup message
Create a new function, hand the data to this function, take back a possible modified msgb and invalidate parsed at this point.
This commit is contained in:
		@@ -343,4 +343,6 @@ struct gsm48_hdr *bsc_unpack_dtap(struct bsc_nat_parsed *parsed, struct msgb *ms
 | 
				
			|||||||
int bsc_ussd_init(struct bsc_nat *nat);
 | 
					int bsc_ussd_init(struct bsc_nat *nat);
 | 
				
			||||||
int bsc_check_ussd(struct sccp_connections *con, struct bsc_nat_parsed *parsed, struct msgb *msg);
 | 
					int bsc_check_ussd(struct sccp_connections *con, struct bsc_nat_parsed *parsed, struct msgb *msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct msgb *bsc_nat_rewrite_setup(struct bsc_nat *nat, struct msgb *msg, struct bsc_nat_parsed *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -858,6 +858,15 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
 | 
				
			|||||||
					/* hand data to a side channel */
 | 
										/* hand data to a side channel */
 | 
				
			||||||
					if (bsc_check_ussd(con, parsed, msg) == 1) 
 | 
										if (bsc_check_ussd(con, parsed, msg) == 1) 
 | 
				
			||||||
						con->con_local = 2;
 | 
											con->con_local = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										/*
 | 
				
			||||||
 | 
										 * Optionally rewrite setup message. This can
 | 
				
			||||||
 | 
										 * replace the msg and the parsed structure becomes
 | 
				
			||||||
 | 
										 * invalid.
 | 
				
			||||||
 | 
										 */
 | 
				
			||||||
 | 
										msg = bsc_nat_rewrite_setup(bsc->nat, msg, parsed);
 | 
				
			||||||
 | 
										talloc_free(parsed);
 | 
				
			||||||
 | 
										parsed = NULL;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				con_bsc = con->bsc;
 | 
									con_bsc = con->bsc;
 | 
				
			||||||
@@ -913,6 +922,7 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* send the non-filtered but maybe modified msg */
 | 
						/* send the non-filtered but maybe modified msg */
 | 
				
			||||||
	queue_for_msc(con_msc, msg);
 | 
						queue_for_msc(con_msc, msg);
 | 
				
			||||||
 | 
						if (parsed)
 | 
				
			||||||
		talloc_free(parsed);
 | 
							talloc_free(parsed);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -721,3 +721,10 @@ int bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg)
 | 
				
			|||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Rewrite non global numbers... according to rules based on the IMSI
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct msgb *bsc_nat_rewrite_setup(struct bsc_nat *nat, struct msgb *msg, struct bsc_nat_parsed *pa)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return msg;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user