~ubuntu-branches/ubuntu/maverick/bind9/maverick

« back to all changes in this revision

Viewing changes to lib/bind/resolv/res_mkupdate.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, LaMont Jones, Internet Software Consortium, Inc, localization folks
  • Date: 2008-08-02 14:20:20 UTC
  • mfrom: (1.2.1 upstream) (6.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080802142020-l1hon9jy8lbbjxmg
[LaMont Jones]

* default to using resolvconf if it is installed
* fix sonames and dependencies.  Closes: #149259, #492418
* Do not build-depend libcap2-dev on non-linux.  Closes: #493392
* drop unused query-loc manpage.  Closes: #492564
* lwresd: Deliver /etc/bind directory.  Closes: #490027
* fix query-source comment in default install

[Internet Software Consortium, Inc]

* 9.5.0-P2.  Closes: #492949

[localization folks]

* l10n: Spanish debconf translation.  Closes: #492425 (Ignacio Mondino)
* l10n: Swedish debconf templates.  Closes: #491369 (Martin Ågren)
* l10n: Japanese debconf translations.  Closes: #492048 (Hideki Yamane
  (Debian-JP))
* l10n: Finnish translation.  Closes: #490630 (Esko Arajärvi)
* l10n: Italian debconf translations.  Closes: #492587 (Alessandro Vietta)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
16
 */
17
17
 
18
 
/*
 
18
/*! \file
 
19
 * \brief
19
20
 * Based on the Dynamic DNS reference implementation by Viraj Bais
20
 
 * <viraj_bais@ccm.fm.intel.com>
 
21
 * &lt;viraj_bais@ccm.fm.intel.com>
21
22
 */
22
23
 
23
24
#if !defined(lint) && !defined(SABER)
24
 
static const char rcsid[] = "$Id: res_mkupdate.c,v 1.1.2.1.4.5 2005/10/14 05:43:47 marka Exp $";
 
25
static const char rcsid[] = "$Id: res_mkupdate.c,v 1.8 2005/10/14 05:44:26 marka Exp $";
25
26
#endif /* not lint */
26
27
 
27
28
#include "port_before.h"
62
63
int res_protocolnumber(const char *);
63
64
int res_servicenumber(const char *);
64
65
 
65
 
/*
 
66
/*%
66
67
 * Form update packets.
67
68
 * Returns the size of the resulting packet if no error
 
69
 *
68
70
 * On error,
69
 
 *      returns -1 if error in reading a word/number in rdata
 
71
 *      returns 
 
72
 *\li              -1 if error in reading a word/number in rdata
70
73
 *                 portion for update packets
71
 
 *              -2 if length of buffer passed is insufficient
72
 
 *              -3 if zone section is not the first section in
 
74
 *\li           -2 if length of buffer passed is insufficient
 
75
 *\li           -3 if zone section is not the first section in
73
76
 *                 the linked list, or section order has a problem
74
 
 *              -4 on a number overflow
75
 
 *              -5 unknown operation or no records
 
77
 *\li           -4 on a number overflow
 
78
 *\li           -5 unknown operation or no records
76
79
 */
77
80
int
78
81
res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
189
192
                }
190
193
                ShrinkBuffer(INT32SZ + INT16SZ);
191
194
                PUTLONG(rttl, cp);
192
 
                sp2 = cp;  /* save pointer to length byte */
 
195
                sp2 = cp;  /*%< save pointer to length byte */
193
196
                cp += INT16SZ;
194
197
                if (rrecp->r_size == 0) {
195
198
                        if (section == S_UPDATE && rclass != C_ANY)
395
398
                        }
396
399
                        break;
397
400
                case T_X25:
398
 
                        /* RFC 1183 */
 
401
                        /* RFC1183 */
399
402
                        if ((n = getstr_str(buf2, sizeof buf2, &startp,
400
403
                                         endp)) < 0)
401
404
                                return (-1);
407
410
                        cp += n;
408
411
                        break;
409
412
                case T_ISDN:
410
 
                        /* RFC 1183 */
 
413
                        /* RFC1183 */
411
414
                        if ((n = getstr_str(buf2, sizeof buf2, &startp,
412
415
                                         endp)) < 0)
413
416
                                return (-1);
708
711
        return (cp - buf);
709
712
}
710
713
 
711
 
/*
 
714
/*%
712
715
 * Get a whitespace delimited word from a string (not file)
713
716
 * into buf. modify the start pointer to point after the
714
717
 * word in the string.
721
724
        for (cp = buf; *startpp <= endp; ) {
722
725
                c = **startpp;
723
726
                if (isspace(c) || c == '\0') {
724
 
                        if (cp != buf) /* trailing whitespace */
 
727
                        if (cp != buf) /*%< trailing whitespace */
725
728
                                break;
726
 
                        else { /* leading whitespace */
 
729
                        else { /*%< leading whitespace */
727
730
                                (*startpp)++;
728
731
                                continue;
729
732
                        }
737
740
        return (cp != buf);
738
741
}
739
742
 
740
 
/*
 
743
/*%
741
744
 * get a white spae delimited string from memory.  Process quoted strings
742
 
 * and \DDD escapes.  Return length or -1 on error.  Returned string may
 
745
 * and \\DDD escapes.  Return length or -1 on error.  Returned string may
743
746
 * contain nulls.
744
747
 */
745
748
static char digits[] = "0123456789";
816
819
        *cp = '\0';
817
820
        return ((cp == buf)?  (seen_quote? 0: -1): (cp - buf));
818
821
}
819
 
/*
 
822
 
 
823
/*%
820
824
 * Get a whitespace delimited base 16 number from a string (not file) into buf
821
825
 * update the start pointer to point after the number in the string.
822
826
 */
832
836
        for (n = 0; *startpp <= endp; ) {
833
837
                c = **startpp;
834
838
                if (isspace(c) || c == '\0') {
835
 
                        if (seendigit) /* trailing whitespace */
 
839
                        if (seendigit) /*%< trailing whitespace */
836
840
                                break;
837
 
                        else { /* leading whitespace */
 
841
                        else { /*%< leading whitespace */
838
842
                                (*startpp)++;
839
843
                                continue;
840
844
                        }
864
868
        return (n + m);
865
869
}
866
870
 
867
 
/*
 
871
/*%
868
872
 * Get a whitespace delimited base 10 number from a string (not file) into buf
869
873
 * update the start pointer to point after the number in the string.
870
874
 */
877
881
        for (n = 0; *startpp <= endp; ) {
878
882
                c = **startpp;
879
883
                if (isspace(c) || c == '\0') {
880
 
                        if (seendigit) /* trailing whitespace */
 
884
                        if (seendigit) /*%< trailing whitespace */
881
885
                                break;
882
 
                        else { /* leading whitespace */
 
886
                        else { /*%< leading whitespace */
883
887
                                (*startpp)++;
884
888
                                continue;
885
889
                        }
906
910
        return (n + m);
907
911
}
908
912
 
909
 
/*
 
913
/*%
910
914
 * Allocate a resource record buffer & save rr info.
911
915
 */
912
916
ns_updrec *
928
932
        return (rrecp);
929
933
}
930
934
 
931
 
/*
 
935
/*%
932
936
 * Free a resource record buffer created by res_mkupdrec.
933
937
 */
934
938
void
970
974
                        free(slp);
971
975
                        break;
972
976
                }
973
 
                slp->port = ntohs((u_int16_t)sp->s_port);  /* host byt order */
 
977
                slp->port = ntohs((u_int16_t)sp->s_port);  /*%< host byt order */
974
978
                slp->next = servicelist;
975
979
                slp->prev = NULL;
976
980
                if (servicelist)
1012
1016
                        free(slp);
1013
1017
                        break;
1014
1018
                }
1015
 
                slp->port = pp->p_proto;        /* host byte order */
 
1019
                slp->port = pp->p_proto;        /*%< host byte order */
1016
1020
                slp->next = protolist;
1017
1021
                slp->prev = NULL;
1018
1022
                if (protolist)
1049
1053
                                lp->next = *list;
1050
1054
                                *list = lp;
1051
1055
                        }
1052
 
                        return (lp->port);      /* host byte order */
 
1056
                        return (lp->port);      /*%< host byte order */
1053
1057
                }
1054
1058
        if (sscanf(s, "%d", &n) != 1 || n <= 0)
1055
1059
                n = -1;
1056
1060
        return (n);
1057
1061
}
1058
1062
 
1059
 
/*
 
1063
/*%
1060
1064
 * Convert service name or (ascii) number to int.
1061
1065
 */
1062
1066
int
1066
1070
        return (findservice(p, &servicelist));
1067
1071
}
1068
1072
 
1069
 
/*
 
1073
/*%
1070
1074
 * Convert protocol name or (ascii) number to int.
1071
1075
 */
1072
1076
int
1077
1081
}
1078
1082
 
1079
1083
static struct servent *
1080
 
cgetservbyport(u_int16_t port, const char *proto) {     /* Host byte order. */
 
1084
cgetservbyport(u_int16_t port, const char *proto) {     /*%< Host byte order. */
1081
1085
        struct valuelist **list = &servicelist;
1082
1086
        struct valuelist *lp = *list;
1083
1087
        static struct servent serv;
1084
1088
 
1085
1089
        port = ntohs(port);
1086
1090
        for (; lp != NULL; lp = lp->next) {
1087
 
                if (port != (u_int16_t)lp->port)        /* Host byte order. */
 
1091
                if (port != (u_int16_t)lp->port)        /*%< Host byte order. */
1088
1092
                        continue;
1089
1093
                if (strcasecmp(lp->proto, proto) == 0) {
1090
1094
                        if (lp != *list) {
1105
1109
}
1106
1110
 
1107
1111
static struct protoent *
1108
 
cgetprotobynumber(int proto) {                          /* Host byte order. */
 
1112
cgetprotobynumber(int proto) {                          /*%< Host byte order. */
1109
1113
        struct valuelist **list = &protolist;
1110
1114
        struct valuelist *lp = *list;
1111
1115
        static struct protoent prot;
1112
1116
 
1113
1117
        for (; lp != NULL; lp = lp->next)
1114
 
                if (lp->port == proto) {                /* Host byte order. */
 
1118
                if (lp->port == proto) {                /*%< Host byte order. */
1115
1119
                        if (lp != *list) {
1116
1120
                                lp->prev->next = lp->next;
1117
1121
                                if (lp->next)
1121
1125
                                *list = lp;
1122
1126
                        }
1123
1127
                        prot.p_name = lp->name;
1124
 
                        prot.p_proto = lp->port;        /* Host byte order. */
 
1128
                        prot.p_proto = lp->port;        /*%< Host byte order. */
1125
1129
                        return (&prot);
1126
1130
                }
1127
1131
        return (0);
1143
1147
}
1144
1148
 
1145
1149
const char *
1146
 
res_servicename(u_int16_t port, const char *proto) {    /* Host byte order. */
 
1150
res_servicename(u_int16_t port, const char *proto) {    /*%< Host byte order. */
1147
1151
        static char number[8];
1148
1152
        struct servent *ss;
1149
1153