Skip to content

Commit

Permalink
Move MAX_DNS_NAME where it belongs. Shuffle headers to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Nov 30, 2023
1 parent 6931535 commit 1624a5f
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 50 deletions.
1 change: 1 addition & 0 deletions core_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "action.h"
#include "dprint.h"
#include "proxy.h"
#include "net/host_sock_info.h"
#include "forward.h"
#include "parser/msg_parser.h"
#include "parser/parse_uri.h"
Expand Down
1 change: 1 addition & 0 deletions forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "sl_cb.h"
#include "net/trans.h"
#include "socket_info.h"
#include "net/host_sock_info.h"

struct socket_info* get_send_socket(struct sip_msg* msg,
const union sockaddr_union* su, int proto);
Expand Down
2 changes: 0 additions & 2 deletions ip_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@

#include "dprint.h"

#define MAX_DNS_NAME 256

#define MAX_RECV_BUFFER_SIZE 256*1024
#define MAX_SEND_BUFFER_SIZE 512*1024
#define BUFFER_INCREMENT 2048
Expand Down
1 change: 1 addition & 0 deletions modules/load_balancer/lb_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "../../mem/shm_mem.h"
#include "../../evi/evi.h"
#include "../../rw_locking.h"
#include "../../net/host_sock_info.h"
#include "lb_parser.h"
#include "lb_data.h"
#include "lb_clustering.h"
Expand Down
2 changes: 1 addition & 1 deletion net/host_sock_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <stddef.h>

#include "../ip_addr.h"
#include "../resolve.h"

struct host_sock_info{
union sockaddr_union su;
Expand Down
44 changes: 42 additions & 2 deletions proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <netdb.h>
#include "ip_addr.h"
#include "str.h"
#include "net/host_sock_info.h"

struct dns_node;

Expand Down Expand Up @@ -75,5 +74,46 @@ struct proxy_l* clone_proxy(struct proxy_l *sp);

#include "resolve.h"

#endif
static inline struct proxy_l* shm_clone_proxy(struct proxy_l *sp,
unsigned int move_dn)
{
struct proxy_l *dp;

dp = (struct proxy_l*)shm_malloc(sizeof(struct proxy_l));
if (dp==NULL) {
LM_ERR("no more shm memory\n");
return 0;
}
memset( dp , 0 , sizeof(struct proxy_l));

dp->port = sp->port;
dp->proto = sp->proto;
dp->addr_idx = sp->addr_idx;
dp->flags = PROXY_SHM_FLAG;

/* clone the hostent */
if (hostent_shm_cpy( &dp->host, &sp->host)!=0)
goto error0;

/* clone the dns resolver */
if (sp->dn) {
if (move_dn) {
dp->dn = sp->dn;
sp->dn = 0;
} else {
dp->dn = dns_res_copy(sp->dn);
if (dp->dn==NULL)
goto error1;
}
}

return dp;
error1:
free_shm_hostent(&dp->host);
error0:
shm_free(dp);
return 0;
}


#endif
2 changes: 2 additions & 0 deletions resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
#include "mem/mem.h"
#include "mem/shm_mem.h"
#include "net/trans.h"
#include "net/host_sock_info.h"
#include "resolve.h"
#include "proxy.h"
#include "dprint.h"
#include "ut.h"
#include "ip_addr.h"
Expand Down
49 changes: 4 additions & 45 deletions resolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

#include "mem/shm_mem.h"
#include "ip_addr.h"
#include "proxy.h"

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
Expand All @@ -54,11 +53,15 @@
#define MAX_QUERY_SIZE 8192
#define ANS_SIZE 8192
#define DNS_HDR_SIZE 12
#define MAX_DNS_NAME 256
#define MAX_DNS_STRING (MAX_DNS_NAME-1)

/*! \brief this is not official yet */
#define T_EBL 65300

struct proxy_l;
struct host_sock_info;

typedef void* (fetch_dns_cache_f)(char *name,int r_type,int name_len);
typedef int (put_dns_cache_f)(char *name,int r_type,void *record,int rdata_len,
int failure,int ttl);
Expand Down Expand Up @@ -189,48 +192,4 @@ int resolv_init();
int resolv_blacklist_init();



static inline struct proxy_l* shm_clone_proxy(struct proxy_l *sp,
unsigned int move_dn)
{
struct proxy_l *dp;

dp = (struct proxy_l*)shm_malloc(sizeof(struct proxy_l));
if (dp==NULL) {
LM_ERR("no more shm memory\n");
return 0;
}
memset( dp , 0 , sizeof(struct proxy_l));

dp->port = sp->port;
dp->proto = sp->proto;
dp->addr_idx = sp->addr_idx;
dp->flags = PROXY_SHM_FLAG;

/* clone the hostent */
if (hostent_shm_cpy( &dp->host, &sp->host)!=0)
goto error0;

/* clone the dns resolver */
if (sp->dn) {
if (move_dn) {
dp->dn = sp->dn;
sp->dn = 0;
} else {
dp->dn = dns_res_copy(sp->dn);
if (dp->dn==NULL)
goto error1;
}
}

return dp;
error1:
free_shm_hostent(&dp->host);
error0:
shm_free(dp);
return 0;
}



#endif

0 comments on commit 1624a5f

Please sign in to comment.