0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifndef EXNETPROTO_H
0037 #define EXNETPROTO_H
0038
0039
0040 #include <ndrx_config.h>
0041 #include <ubfview.h>
0042
0043
0044
0045 #define PMSGMAX -2
0046
0047 #define TAG_BYTES 2
0048 #define LEN_BYTES 4
0049
0050 #define MKSIGN char sign = '0';\
0051 if (*tmp<0)\
0052 {\
0053 sign = '1';\
0054 }
0055
0056 #define OFSZ(s,e) EXOFFSET(s,e), EXELEM_SIZE(s,e)
0057 #define OFSZ0 0,0
0058
0059
0060
0061
0062
0063
0064 #define XFLD 0x01
0065 #define XSUB 0x02
0066 #define XSBL 0x03
0067 #define XINC 0x04
0068 #define XLOOP 0x05
0069 #define XATMIBUF 0x06
0070 #define XMASTERBUF 0x07
0071 #define XFLDPTR 0x08
0072 #define XATMIBUFPTR 0x09
0073 #define XSUBPTR 0x0B
0074 #define XTYPE(X) (X & 0xff)
0075
0076
0077
0078
0079
0080
0081
0082
0083 #define XFLAST 0x0100
0084
0085
0086
0087 #define XTAB1(e1) 1, e1, NULL, NULL, NULL
0088 #define XTAB2(e1,e2) 2, e1, e2, NULL, NULL
0089 #define XTAB3(e1,e2,e3) 3, e1, e2, e3, NULL
0090 #define XTAB4(e1,e2,e3,e4) 4, e1, e2, e3, e4
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 #define UBF_TAG_BFLD_SHORT 0x1113
0101 #define UBF_TAG_BFLD_LONG 0x111D
0102 #define UBF_TAG_BFLD_CHAR 0x1127
0103 #define UBF_TAG_BFLD_FLOAT 0x1131
0104 #define UBF_TAG_BFLD_DOUBLE 0x113B
0105 #define UBF_TAG_BFLD_STRING 0x1145
0106 #define UBF_TAG_BFLD_CARRAY 0x114F
0107 #define UBF_TAG_BFLD_INT 0x1150
0108 #define UBF_TAG_BFLD_RFU0 0x1151
0109 #define UBF_TAG_BFLD_PTR 0x1152
0110 #define UBF_TAG_BFLD_UBF 0x1153
0111 #define UBF_TAG_BFLD_VIEW 0x1154
0112
0113 #define UBF_TAG_BFLDID 0x10FF
0114 #define UBF_TAG_BFLDLEN 0x1109
0115
0116 #define VIEW_TAG_CNAME 0x134D
0117 #define VIEW_TAG_BFLDLEN 0x1357
0118
0119
0120 #define VIEW_TAG_SHORT 0x1360
0121 #define VIEW_TAG_LONG 0x1361
0122 #define VIEW_TAG_CHAR 0x1362
0123 #define VIEW_TAG_FLOAT 0x1363
0124 #define VIEW_TAG_DOUBLE 0x1364
0125 #define VIEW_TAG_STRING 0x1365
0126 #define VIEW_TAG_CARRAY 0x1366
0127 #define VIEW_TAG_INT 0x1367
0128
0129
0130
0131
0132 #define CHECK_PROTO_BUFSZ(RET, CURSIZE, MAXSIZE, TO_WRITE) \
0133 if ((CURSIZE) + TO_WRITE > MAXSIZE) \
0134 {\
0135 NDRX_LOG(log_error, "ERROR ! EX2NET: Message size in bytes max: %ld, at "\
0136 "current state: %ld, about "\
0137 "to write: %ld (new total: %d) - EXCEEDS message size. "\
0138 "Please increase NDRX_MSGSIZEMAX!", \
0139 (long)MAXSIZE, (long)(CURSIZE), (long)TO_WRITE, (long)(CURSIZE) + (long)TO_WRITE);\
0140 userlog("ERROR ! EX2NET: Message size in bytes max: %ld, at current state: %ld, about "\
0141 "to write: %ld (new total: %d) - EXCEEDS message size. "\
0142 "Please increase NDRX_MSGSIZEMAX!", \
0143 (long)MAXSIZE, (long)(CURSIZE), (long)TO_WRITE, (long)(CURSIZE) + (long)TO_WRITE);\
0144 EXFAIL_OUT(RET);\
0145 }
0146
0147
0148
0149 #define CHECK_EX_BUFSZ(RET, CUROFFSZ, FLD_OFFSZ, MAXSIZE, TO_WRITE) \
0150 if ((CUROFFSZ) + (FLD_OFFSZ) + (TO_WRITE) > MAXSIZE) \
0151 {\
0152 NDRX_LOG(log_error, "ERROR ! NET2EX: Incomming buffer size in bytes: %ld, incoming "\
0153 "message is larger %ld (offset: %ld, fld_offs: %ld, "\
0154 "datasize: %ld) - dropping, please increase NDRX_MSGSIZEMAX!",\
0155 (long)MAXSIZE, (long)((CUROFFSZ) + (FLD_OFFSZ) + (TO_WRITE)),\
0156 (long)(CUROFFSZ), (long)(FLD_OFFSZ), (long)(TO_WRITE)\
0157 );\
0158 userlog("ERROR ! NET2EX: Incomming buffer size in bytes: %ld, incoming "\
0159 "message is larger %ld (offset: %ld, fld_offs: %ld, "\
0160 "datasize: %ld) - dropping, please increase NDRX_MSGSIZEMAX!",\
0161 (long)MAXSIZE, (long)((CUROFFSZ) + (FLD_OFFSZ) + (TO_WRITE)),\
0162 (long)(CUROFFSZ), (long)(FLD_OFFSZ), (long)(TO_WRITE));\
0163 EXFAIL_OUT(RET);\
0164 }
0165
0166 #define CHECK_EX_BUFSZ_SIMPLE(RET, MAXSIZE, TO_WRITE) \
0167 if ((TO_WRITE) > MAXSIZE) \
0168 {\
0169 NDRX_LOG(log_error, "ERROR ! NET2EX: Incomming buffer size in bytes: %ld "\
0170 "data size: %ld - dropping, please increase NDRX_MSGSIZEMAX!",\
0171 MAXSIZE, (TO_WRITE));\
0172 userlog( "ERROR ! NET2EX: Incomming buffer size in bytes: %ld "\
0173 "data size: %ld - dropping, please increase NDRX_MSGSIZEMAX!",\
0174 MAXSIZE, (TO_WRITE));\
0175 EXFAIL_OUT(RET);\
0176 }
0177
0178
0179
0180
0181
0182
0183 typedef struct cproto cproto_t;
0184 typedef struct xmsg xmsg_t;
0185
0186 struct cproto
0187 {
0188 int tableid;
0189 long tag;
0190 char* cname;
0191 long offset;
0192 int len;
0193 int fld_type;
0194 short type;
0195 int min_len;
0196 int max_len;
0197 cproto_t *include;
0198 long counter_offset;
0199 long elem_size;
0200
0201 xmsg_t * (*p_classify_fn) (char *ex_buf, long ex_len);
0202
0203 size_t buftype_offset;
0204 };
0205
0206
0207 struct xmsg
0208 {
0209 char msg_type;
0210 int command;
0211 char *descr;
0212
0213 int tabcnt;
0214 cproto_t *tab[4];
0215 };
0216
0217
0218 struct ptinfo
0219 {
0220 int idx;
0221 int dim;
0222 };
0223 typedef struct ptinfo ptinfo_t;
0224
0225
0226 typedef struct proto_ufb_fld proto_ufb_fld_t;
0227 struct proto_ufb_fld
0228 {
0229 int bfldid;
0230 int bfldlen;
0231 unsigned typetag;
0232 long typelen;
0233 char cname [NDRX_VIEW_CNAME_LEN+1];
0234 Bfld_loc_info_t next_fld;
0235 ndrx_typedview_t *v;
0236 ndrx_viewocc_t *vocc;
0237
0238 char buf[0];
0239 };
0240
0241
0242
0243 extern cproto_t ndrx_G_ndrx_mbuf_tlv_x[];
0244 extern short ndrx_G_ubf_proto_tag_map[];
0245 extern short ndrx_G_view_proto_tag_map[];
0246 extern cproto_t ndrx_G_view_field[];
0247 extern cproto_t ndrx_G_view[];
0248
0249
0250
0251
0252 extern int ndrx_write_tag(short tag, char *buf, long *proto_buf_offset,
0253 long proto_bufsz);
0254
0255 extern int ndrx_write_len(int len, char *buf, long *proto_buf_offset,
0256 long proto_bufsz);
0257
0258 extern int _exproto_proto2ex_mbuf(cproto_t *fld, char *proto_buf, long proto_len,
0259 char *ex_buf, long ex_offset, long *max_struct, int level,
0260 UBFH *p_x_fb, proto_ufb_fld_t *p_ub_data, long ex_bufsz);
0261
0262 extern int exproto_build_ex2proto_mbuf(cproto_t *fld, int level, long offset,
0263 char *ex_buf, long ex_len, char *proto_buf, long *proto_buf_offset,
0264 short *accept_tags, proto_ufb_fld_t *p_ub_data,
0265 long proto_bufsz);
0266
0267 extern int exproto_build_ex2proto(xmsg_t *cv, int level, long offset,
0268 char *ex_buf, long ex_len, char *proto_buf, long *proto_buf_offset,
0269 short *accept_tags, proto_ufb_fld_t *p_ub_data,
0270 long proto_bufsz);
0271
0272 extern long _exproto_proto2ex(cproto_t *cur, char *proto_buf, long proto_len,
0273 char *ex_buf, long ex_offset, long *max_struct, int level,
0274 char *p_typedbuf, proto_ufb_fld_t *p_ub_data, long ex_bufsz);
0275
0276
0277 extern ndrx_typedview_t * ndrx_view_get_init(char *vname);
0278
0279 extern int exproto_build_ex2proto_view(cproto_t *fld, int level, long offset,
0280 char *ex_buf, long ex_len, char *proto_buf, long *proto_buf_offset,
0281 long proto_bufsz);
0282
0283 #endif
0284
0285