diff --git a/src/dns.c b/src/dns.c index 6eecab2..be6559d 100644 --- a/src/dns.c +++ b/src/dns.c @@ -50,7 +50,7 @@ int dnsc_use_edns0 = 1; #define CHECKLEN(x) if (buflen < (x) + (unsigned)(p-buf)) return 0 int -dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_t datalen) +dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, const char *data, size_t datalen) { HEADER *header; short name; @@ -120,7 +120,7 @@ dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_ For SRV, see RFC2782. */ - char *mxdata = data; + const char *mxdata = data; char *startp; int namelen; diff --git a/src/dns.h b/src/dns.h index b5d83b2..ce48d1a 100644 --- a/src/dns.h +++ b/src/dns.h @@ -27,7 +27,7 @@ typedef enum { extern int dnsc_use_edns0; -int dns_encode(char *, size_t, struct query *, qr_t, char *, size_t); +int dns_encode(char *, size_t, struct query *, qr_t, const char *, size_t); int dns_encode_ns_response(char *buf, size_t buflen, struct query *q, char *topdomain); int dns_encode_a_response(char *buf, size_t buflen, struct query *q); unsigned short dns_get_id(char *packet, size_t packetlen); diff --git a/src/encoding.c b/src/encoding.c index 4906a6b..55b9e2e 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -22,7 +22,7 @@ int build_hostname(char *buf, size_t buflen, const char *data, const size_t datalen, - const char *topdomain, struct encoder *encoder, int maxlen) + const char *topdomain, const struct encoder *encoder, int maxlen) { size_t space; char *b; @@ -56,7 +56,7 @@ build_hostname(char *buf, size_t buflen, } int -unpack_data(char *buf, size_t buflen, char *data, size_t datalen, struct encoder *enc) +unpack_data(char *buf, size_t buflen, char *data, size_t datalen, const struct encoder *enc) { if (!enc->eats_dots()) datalen = inline_undotify(data, datalen); diff --git a/src/encoding.h b/src/encoding.h index abb82da..a75a312 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -26,7 +26,7 @@ #define DOWNCODECCHECK1_LEN 48 struct encoder { - char name[8]; + const char name[8]; int (*encode) (char *, size_t *, const void *, size_t); int (*decode) (void *, size_t *, const char *, size_t); int (*places_dots) (void); @@ -35,10 +35,9 @@ struct encoder { int (*blocksize_encoded)(void); }; -int build_hostname(char *, size_t, const char *, const size_t, const char *, struct encoder *, int); -int unpack_data(char *, size_t, char *, size_t, struct encoder *); +int build_hostname(char *, size_t, const char *, const size_t, const char *, const struct encoder *, int); +int unpack_data(char *, size_t, char *, size_t, const struct encoder *); int inline_dotify(char *, size_t); int inline_undotify(char *, size_t); - #endif /* _ENCODING_H_ */ diff --git a/src/iodined.c b/src/iodined.c index 2fd0611..bd5afdb 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -119,7 +119,7 @@ struct dnsfd { }; static int read_dns(int fd, struct dnsfd *dns_fds, int tun_fd, struct query *q); -static void write_dns(int fd, struct query *q, char *data, int datalen, char downenc); +static void write_dns(int fd, struct query *q, const char *data, int datalen, char downenc); static void handle_full_packet(int tun_fd, struct dnsfd *dns_fds, int userid); static int @@ -2118,7 +2118,7 @@ read_dns(int fd, struct dnsfd *dns_fds, int tun_fd, struct query *q) } static size_t -write_dns_nameenc(char *buf, size_t buflen, char *data, int datalen, char downenc) +write_dns_nameenc(char *buf, size_t buflen, const char *data, int datalen, char downenc) /* Returns #bytes of data that were encoded */ { static int td1 = 0; @@ -2188,7 +2188,7 @@ write_dns_nameenc(char *buf, size_t buflen, char *data, int datalen, char downen } static void -write_dns(int fd, struct query *q, char *data, int datalen, char downenc) +write_dns(int fd, struct query *q, const char *data, int datalen, char downenc) { char buf[64*1024]; int len = 0; diff --git a/src/read.c b/src/read.c index 51c3bb0..1890359 100644 --- a/src/read.c +++ b/src/read.c @@ -230,7 +230,7 @@ putlong(char **dst, uint32_t value) } int -putdata(char **dst, char *data, size_t len) +putdata(char **dst, const char *data, size_t len) { memcpy(*dst, data, len); @@ -239,7 +239,7 @@ putdata(char **dst, char *data, size_t len) } int -puttxtbin(char **buf, size_t bufremain, char *from, size_t fromremain) +puttxtbin(char **buf, size_t bufremain, const char *from, size_t fromremain) { unsigned char uc; unsigned char *ucp = &uc; diff --git a/src/read.h b/src/read.h index 5da474d..a727c0e 100644 --- a/src/read.h +++ b/src/read.h @@ -28,7 +28,7 @@ int putname(char **, size_t, const char *); int putbyte(char **, unsigned char); int putshort(char **, unsigned short); int putlong(char **, uint32_t); -int putdata(char **, char *, size_t); -int puttxtbin(char **, size_t, char *, size_t); +int putdata(char **, const char *, size_t); +int puttxtbin(char **, size_t, const char *, size_t); #endif diff --git a/src/user.c b/src/user.c index db76e39..b6a48e6 100644 --- a/src/user.c +++ b/src/user.c @@ -161,7 +161,7 @@ int find_available_user(void) return ret; } -void user_switch_codec(int userid, struct encoder *enc) +void user_switch_codec(int userid, const struct encoder *enc) { if (userid < 0 || userid >= usercount) return; diff --git a/src/user.h b/src/user.h index c6aa523..6612bc8 100644 --- a/src/user.h +++ b/src/user.h @@ -51,7 +51,7 @@ struct tun_user { struct packet inpacket; struct packet outpacket; int outfragresent; - struct encoder *encoder; + const struct encoder *encoder; char downenc; int out_acked_seqno; int out_acked_fragment; @@ -84,7 +84,7 @@ const char* users_get_first_ip(void); int find_user_by_ip(uint32_t); int all_users_waiting_to_send(void); int find_available_user(void); -void user_switch_codec(int userid, struct encoder *enc); +void user_switch_codec(int userid, const struct encoder *enc); void user_set_conn_type(int userid, enum connection c); #endif