|
|
1.1 root 1: /* nrs_info.c - nRSInformation attribute */
2:
3: /*
4: * NOTICE
5: *
6: * Acquisition, use, and distribution of this module and related
7: * materials are subject to the restrictions of a license agreement.
8: * Consult the Preface in the User's Manual for the full terms of
9: * this agreement.
10: *
11: */
12:
13:
14: /*
15: SYNTAX
16: nrs_info ::= <context> "$" <addr_sp_id> "$" <routes>
17: context ::= <integer> | <context_str>
18: context_str ::= "x29" | "ts29" | "niftp" | "mail-niftp" | "mail-telex"
19: | "jtmp" | "jtmp-files" | "jtmp-reg" | "ybts-node" | "ybts"
20: | "ftam" | "jtm" | "jtm-reg" | "vt" | "motis"
21: addr_sp_id ::= <integer> | <addr_sp_id_str>
22: addr_sp_id_str ::= "pss" | "janet" | "telex" | "osi-cons"
23: routes ::= <route> "|" <routes> | empty
24: route ::= <cost> "#" <addressing_info>
25: cost ::= <asn> | empty -- empty implies cost is ASN.1 NULL
26: addressing_info ::=
27: "dte_only" ":" <dte_number>
28: | "dte_applic_info" ":" <dte_number> "#" <applic_info>
29: | "dte_cudf" ":" <dte_number> "#" <cudf>
30: | "dte_cudf_applic_info" ":" <dte_number> "#" <cudf> "#" <applic_info>
31: | "dte_ybts" ":" <dte_number> "#" <ybts_string>
32: | "dte_ybts_applic_info" ":" <dte_number> "#" <ybts_string> "#" <applic_info>
33: | "dte_ybts_applic_relay" ":" <dte_number> "#" <ybts_string> "#" <applic_relay>
34: | "none_needed" ":"
35: | "osi_addressing" ":" <nsap> "#" <tsel> "#" <ssel> "#" <psel>
36: "#" <place_holder> "#" <application_title> "#" <per_app_context_info>
37: | "osi_nsap_only" ":" <nsap>
38: | "osi_nsap_applic_info" ":" <nsap> "#" <applic_info>
39: | "osi_nsap_applic_relay" ":" <nsap> "#" <applic_relay>
40: | "dte_ybts_osi_addressing" ":" <dte_number> "#" <ybts_string>
41: "#" <tsel> "#" <ssel> "#" <psel> "#" <place_holder>
42: "#" <application_title> "#" <per_app_context_info>
43:
44: dte_number ::= <numeric_string>
45: cudf ::= <octet_string>
46: ybts ::= <visible_string>
47: nsap ::= <numeric_string>
48: tselector ::= <octet_string>
49: sselector ::= <octet_string>
50: pselector ::= <octet_string>
51: place_holder ::= <asn>
52: application_title ::= <asn>
53: per_app_context_info ::= <asn>
54: applic_info ::= <vis_str_seq>
55: applic_relay ::= <vis_str_seq>
56: vis_str_seq ::= <visible_string> | <str_seq> "$" <visible_string>
57:
58: EXAMPLES
59: */
60:
61: /* LINTLIBRARY */
62:
63: #include "quipu/util.h"
64: #include "quipu/attr.h" /* Def.s for READOUT etc */
65: #include "quipu/nrs_info.h"
66:
67: extern LLog * log_dsap;
68: PE asn2pe();
69:
70: PE asnstr2pe (orig)
71: char * orig;
72: {
73: PE result;
74: char * str;
75:
76: if (orig == NULLCP)
77: return(NULLPE);
78:
79: str = SkipSpace(orig);
80:
81: if ((*str) == '\0')
82: return(NULLPE);
83:
84: if (strncmp (str, "{ASN}", 5) == 0)
85: {
86: result = asn2pe ((char *)(orig + 5));
87: }
88: else
89: {
90: parse_error ("Malformed ASN string '%s'", orig);
91: result = NULLPE;
92: }
93:
94: return(result);
95: }
96:
97: static str_seq_free (arg)
98: struct str_seq * arg;
99: {
100: if (arg == (struct str_seq *)NULL)
101: return;
102:
103: if (arg->ss_str)
104: free (arg->ss_str);
105:
106: if (arg->ss_next)
107: str_seq_free (arg->ss_next);
108:
109: free ((char *)arg);
110: }
111:
112: static struct str_seq * str_seq_cpy (arg)
113: struct str_seq * arg;
114: {
115: struct str_seq * ret;
116:
117: if (arg == (struct str_seq *)NULL)
118: return ((struct str_seq *)NULL);
119:
120: ret = (struct str_seq *) smalloc (sizeof (struct str_seq));
121:
122: ret->ss_str = strdup (arg->ss_str);
123:
124: ret->ss_next = str_seq_cpy (arg->ss_next);
125:
126: return (ret);
127: }
128:
129: static str_seq_cmp (arg1, arg2)
130: struct str_seq * arg1;
131: struct str_seq * arg2;
132: {
133: int ret;
134:
135: if (arg1 == (struct str_seq *)NULL)
136: if (arg2 == (struct str_seq *)NULL)
137: return (0);
138: else
139: return (-1);
140:
141: if (arg2 == (struct str_seq *)NULL)
142: return (1);
143:
144: if ((ret = lexequ (arg1->ss_str, arg2->ss_str)) != 0)
145: return (ret);
146:
147: return (str_seq_cmp (arg1->ss_next, arg2->ss_next));
148: }
149:
150: static str_seq_print (ps, strseq, format)
151: register PS ps;
152: struct str_seq * strseq;
153: int format;
154: {
155: struct str_seq * ss;
156:
157: for (ss=strseq; ss != (struct str_seq *)NULL; ss = ss->ss_next)
158: {
159: if (ss != strseq)
160: if (format == READOUT)
161: ps_printf (ps, "//");
162: else
163: ps_printf (ps, "$");
164:
165: ps_printf (ps, "%s", ss->ss_str);
166: }
167: }
168:
169: static struct str_seq * str2str_seq (orig)
170: char * orig;
171: {
172: struct str_seq * result;
173: struct str_seq **ss;
174: char * ptr_prev;
175: char * ptr_next;
176:
177: if (((ptr_prev = orig) == NULLCP) || ((*ptr_prev) == '\0'))
178: {
179: return ((struct str_seq *)NULL);
180: }
181:
182: ss = &(result);
183:
184: while ( (ptr_next=index (ptr_prev, '$')) != NULLCP)
185: {
186: *ptr_next = '\0';
187: ptr_next++;
188: (*ss) = (struct str_seq *) smalloc (sizeof (struct str_seq));
189:
190: (*ss)->ss_str = strdup (ptr_prev);
191:
192: ss = &((*ss)->ss_next);
193: ptr_prev = ptr_next;
194: }
195:
196: (*ss) = (struct str_seq *) smalloc (sizeof (struct str_seq));
197:
198: (*ss)->ss_str = strdup (ptr_prev);
199:
200: (*ss)->ss_next = (struct str_seq *)NULL;
201:
202: return (result);
203: }
204:
205: static addr_info_free (arg)
206: struct addr_info * arg;
207: {
208: if (arg == (struct addr_info *)NULL)
209: return;
210:
211: if (arg->dte_number)
212: free (arg->dte_number);
213:
214: if (arg->cudf)
215: free (arg->cudf);
216:
217: if (arg->ybts_string)
218: free (arg->ybts_string);
219:
220: if (arg->nsap)
221: free (arg->nsap);
222:
223: if (arg->tselector)
224: free (arg->tselector);
225:
226: if (arg->sselector)
227: free (arg->sselector);
228:
229: if (arg->pselector)
230: free (arg->pselector);
231:
232: if (arg->place_holder)
233: pe_free (arg->place_holder);
234:
235: if (arg->application_title)
236: pe_free (arg->application_title);
237:
238: if (arg->per_app_context_info)
239: pe_free (arg->per_app_context_info);
240:
241: if (arg->applic_info)
242: str_seq_free (arg->applic_info);
243:
244: if (arg->applic_relay)
245: str_seq_free (arg->applic_relay);
246:
247: free ((char *) arg);
248: }
249:
250: static struct addr_info * addr_info_cpy (arg)
251: struct addr_info * arg;
252: {
253: struct addr_info * ret;
254:
255: if (arg == (struct addr_info *)NULL)
256: return ((struct addr_info *)NULL);
257:
258: ret = (struct addr_info *) calloc (1, sizeof (struct addr_info));
259:
260: switch (ret->addr_info_type = arg->addr_info_type)
261: {
262: case ADDR_INFO_DTE_ONLY:
263: ret->dte_number = strdup (arg->dte_number);
264: break;
265: case ADDR_INFO_DTE_APPLIC_INFO:
266: ret->dte_number = strdup (arg->dte_number);
267: ret->applic_info = str_seq_cpy (arg->applic_info);
268: break;
269: case ADDR_INFO_DTE_CUDF:
270: ret->dte_number = strdup (arg->dte_number);
271: ret->cudf = strdup (arg->cudf);
272: break;
273: case ADDR_INFO_DTE_CUDF_APPLIC_INFO:
274: ret->dte_number = strdup (arg->dte_number);
275: ret->cudf = strdup (arg->cudf);
276: ret->applic_info = str_seq_cpy (arg->applic_info);
277: break;
278: case ADDR_INFO_DTE_YBTS:
279: ret->dte_number = strdup (arg->dte_number);
280: ret->ybts_string = strdup (arg->ybts_string);
281: break;
282: case ADDR_INFO_DTE_YBTS_APPLIC_INFO:
283: ret->dte_number = strdup (arg->dte_number);
284: ret->ybts_string = strdup (arg->ybts_string);
285: ret->applic_info = str_seq_cpy (arg->applic_info);
286: break;
287: case ADDR_INFO_DTE_YBTS_APPLIC_RELAY:
288: ret->dte_number = strdup (arg->dte_number);
289: ret->ybts_string = strdup (arg->ybts_string);
290: ret->applic_relay = str_seq_cpy (arg->applic_relay);
291: break;
292: case ADDR_INFO_NONE_NEEDED:
293: break;
294: case ADDR_INFO_OSI_ADDRESSING:
295: ret->nsap = strdup (arg->nsap);
296: ret->tselector = strdup (arg->tselector);
297: ret->sselector = strdup (arg->sselector);
298: ret->pselector = strdup (arg->pselector);
299:
300: if (arg->place_holder == NULLPE)
301: ret->place_holder = NULLPE;
302: else
303: ret->place_holder = pe_cpy (arg->place_holder);
304:
305: if (arg->application_title == NULLPE)
306: ret->application_title = NULLPE;
307: else
308: ret->application_title = pe_cpy (arg->application_title);
309:
310: if (arg->per_app_context_info == NULLPE)
311: ret->per_app_context_info = NULLPE;
312: else
313: ret->per_app_context_info = pe_cpy (arg->per_app_context_info);
314:
315: break;
316: case ADDR_INFO_OSI_NSAP_ONLY:
317: ret->nsap = strdup (arg->nsap);
318: break;
319: case ADDR_INFO_OSI_NSAP_APPLIC_INFO:
320: ret->nsap = strdup (arg->nsap);
321: ret->applic_info = str_seq_cpy (arg->applic_info);
322: break;
323: case ADDR_INFO_OSI_NSAP_APPLIC_RELAY:
324: ret->nsap = strdup (arg->nsap);
325: ret->applic_relay = str_seq_cpy (arg->applic_relay);
326: break;
327: case ADDR_INFO_DTE_YBTS_OSI_ADDRESSING:
328: ret->dte_number = strdup (arg->dte_number);
329: ret->ybts_string = strdup (arg->ybts_string);
330: ret->tselector = strdup (arg->tselector);
331: ret->sselector = strdup (arg->sselector);
332: ret->pselector = strdup (arg->pselector);
333:
334: if (arg->place_holder == NULLPE)
335: ret->place_holder = NULLPE;
336: else
337: ret->place_holder = pe_cpy (arg->place_holder);
338:
339: if (arg->application_title == NULLPE)
340: ret->application_title = NULLPE;
341: else
342: ret->application_title = pe_cpy (arg->application_title);
343:
344: if (arg->per_app_context_info == NULLPE)
345: ret->per_app_context_info = NULLPE;
346: else
347: ret->per_app_context_info = pe_cpy (arg->per_app_context_info);
348:
349: break;
350: default:
351: LLOG (log_dsap, LLOG_EXCEPTIONS, ("addr_info_cpy(): Unknown addressing info type %d", arg->addr_info_type));
352: break;
353: }
354:
355: return (ret);
356: }
357:
358: static addr_info_cmp (arg1, arg2)
359: struct addr_info * arg1;
360: struct addr_info * arg2;
361: {
362: int ret;
363:
364: if (arg1 == (struct addr_info *)NULL)
365: if (arg2 == (struct addr_info *)NULL)
366: return (0);
367: else
368: return (-1);
369:
370: if (arg2 == (struct addr_info *)NULL)
371: return (1);
372:
373: if (arg1->addr_info_type < arg2->addr_info_type)
374: return (-1);
375:
376: if (arg1->addr_info_type > arg2->addr_info_type)
377: return (1);
378:
379: switch (arg1->addr_info_type)
380: {
381: case ADDR_INFO_DTE_ONLY:
382: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
383: return (ret);
384: break;
385: case ADDR_INFO_DTE_APPLIC_INFO:
386: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
387: return (ret);
388: if ((ret = str_seq_cmp (arg1->applic_info, arg2->applic_info)) != 0)
389: return (ret);
390: break;
391: case ADDR_INFO_DTE_CUDF:
392: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
393: return (ret);
394: if ((ret = lexequ (arg1->cudf, arg2->cudf)) != 0)
395: return (ret);
396: break;
397: case ADDR_INFO_DTE_CUDF_APPLIC_INFO:
398: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
399: return (ret);
400: if ((ret = lexequ (arg1->cudf, arg2->cudf)) != 0)
401: return (ret);
402: if ((ret = str_seq_cmp (arg1->applic_info, arg2->applic_info)) != 0)
403: return (ret);
404: break;
405: case ADDR_INFO_DTE_YBTS:
406: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
407: return (ret);
408: if ((ret = lexequ (arg1->ybts_string, arg2->ybts_string)) != 0)
409: return (ret);
410: break;
411: case ADDR_INFO_DTE_YBTS_APPLIC_INFO:
412: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
413: return (ret);
414: if ((ret = lexequ (arg1->ybts_string, arg2->ybts_string)) != 0)
415: return (ret);
416: if ((ret = str_seq_cmp (arg1->applic_info, arg2->applic_info)) != 0)
417: return (ret);
418: break;
419: case ADDR_INFO_DTE_YBTS_APPLIC_RELAY:
420: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
421: return (ret);
422: if ((ret = lexequ (arg1->ybts_string, arg2->ybts_string)) != 0)
423: return (ret);
424: if ((ret = str_seq_cmp (arg1->applic_relay, arg2->applic_relay)) != 0)
425: return (ret);
426: break;
427: case ADDR_INFO_NONE_NEEDED:
428: break;
429: case ADDR_INFO_OSI_ADDRESSING:
430: if ((ret = lexequ (arg1->nsap, arg2->nsap)) != 0)
431: return (ret);
432: if ((ret = lexequ (arg1->tselector, arg2->tselector)) != 0)
433: return (ret);
434: if ((ret = lexequ (arg1->sselector, arg2->sselector)) != 0)
435: return (ret);
436: if ((ret = lexequ (arg1->pselector, arg2->pselector)) != 0)
437: return (ret);
438: if ((ret = quipu_pe_cmp (arg1->place_holder, arg2->place_holder)) != 0)
439: return (ret);
440: if ((ret = quipu_pe_cmp (arg1->application_title, arg2->application_title)) != 0)
441: return (ret);
442: if ((ret = quipu_pe_cmp (arg1->per_app_context_info, arg2->per_app_context_info)) != 0)
443: return (ret);
444: break;
445: case ADDR_INFO_OSI_NSAP_ONLY:
446: if ((ret = lexequ (arg1->nsap, arg2->nsap)) != 0)
447: return (ret);
448: break;
449: case ADDR_INFO_OSI_NSAP_APPLIC_INFO:
450: if ((ret = lexequ (arg1->nsap, arg2->nsap)) != 0)
451: return (ret);
452: if ((ret = str_seq_cmp (arg1->applic_info, arg2->applic_info)) != 0)
453: return (ret);
454: break;
455: case ADDR_INFO_OSI_NSAP_APPLIC_RELAY:
456: if ((ret = lexequ (arg1->nsap, arg2->nsap)) != 0)
457: return (ret);
458: if ((ret = str_seq_cmp (arg1->applic_relay, arg2->applic_relay)) != 0)
459: return (ret);
460: break;
461: case ADDR_INFO_DTE_YBTS_OSI_ADDRESSING:
462: if ((ret = lexequ (arg1->dte_number, arg2->dte_number)) != 0)
463: return (ret);
464: if ((ret = lexequ (arg1->ybts_string, arg2->ybts_string)) != 0)
465: return (ret);
466: if ((ret = lexequ (arg1->tselector, arg2->tselector)) != 0)
467: return (ret);
468: if ((ret = lexequ (arg1->sselector, arg2->sselector)) != 0)
469: return (ret);
470: if ((ret = lexequ (arg1->pselector, arg2->pselector)) != 0)
471: return (ret);
472: if ((ret = quipu_pe_cmp (arg1->place_holder, arg2->place_holder)) != 0)
473: return (ret);
474: if ((ret = quipu_pe_cmp (arg1->application_title, arg2->application_title)) != 0)
475: return (ret);
476: if ((ret = quipu_pe_cmp (arg1->per_app_context_info, arg2->per_app_context_info)) != 0)
477: return (ret);
478: break;
479: default:
480: LLOG (log_dsap, LLOG_EXCEPTIONS, ("addr_info_cmp(): Unknown addressing info type %d", arg1->addr_info_type));
481: break;
482: }
483:
484: return (0);
485: }
486:
487: static addr_info_print (ps, info, format)
488: register PS ps;
489: struct addr_info * info;
490: int format;
491: {
492: switch (info->addr_info_type)
493: {
494: case ADDR_INFO_DTE_ONLY:
495: ps_printf (ps, "%s", "dte_only");
496: ps_printf (ps, ":");
497: ps_printf (ps, "%s", info->dte_number);
498: break;
499: case ADDR_INFO_DTE_APPLIC_INFO:
500: ps_printf (ps, "%s", "dte_applic_info");
501: ps_printf (ps, ":");
502: ps_printf (ps, "%s", info->dte_number);
503: ps_printf (ps, "#");
504: str_seq_print (ps, info->applic_info, format);
505: break;
506: case ADDR_INFO_DTE_CUDF:
507: ps_printf (ps, "%s", "dte_cudf");
508: ps_printf (ps, ":");
509: ps_printf (ps, "%s", info->dte_number);
510: ps_printf (ps, "#");
511: ps_printf (ps, "%s", info->cudf);
512: break;
513: case ADDR_INFO_DTE_CUDF_APPLIC_INFO:
514: ps_printf (ps, "%s", "dte_cudf_applic_info");
515: ps_printf (ps, ":");
516: ps_printf (ps, "%s", info->dte_number);
517: ps_printf (ps, "#");
518: ps_printf (ps, "%s", info->cudf);
519: ps_printf (ps, "#");
520: str_seq_print (ps, info->applic_info, format);
521: break;
522: case ADDR_INFO_DTE_YBTS:
523: ps_printf (ps, "%s", "dte_ybts");
524: ps_printf (ps, ":");
525: ps_printf (ps, "%s", info->dte_number);
526: ps_printf (ps, "#");
527: ps_printf (ps, "%s", info->ybts_string);
528: break;
529: case ADDR_INFO_DTE_YBTS_APPLIC_INFO:
530: ps_printf (ps, "%s", "dte_ybts_applic_info");
531: ps_printf (ps, ":");
532: ps_printf (ps, "%s", info->dte_number);
533: ps_printf (ps, "#");
534: ps_printf (ps, "%s", info->ybts_string);
535: ps_printf (ps, "#");
536: str_seq_print (ps, info->applic_info, format);
537: break;
538: case ADDR_INFO_DTE_YBTS_APPLIC_RELAY:
539: ps_printf (ps, "%s", "dte_ybts_applic_relay");
540: ps_printf (ps, ":");
541: ps_printf (ps, "%s", info->dte_number);
542: ps_printf (ps, "#");
543: ps_printf (ps, "%s", info->ybts_string);
544: ps_printf (ps, "#");
545: str_seq_print (ps, info->applic_relay, format);
546: break;
547: case ADDR_INFO_NONE_NEEDED:
548: ps_printf (ps, "%s", "none_needed");
549: ps_printf (ps, ":");
550: break;
551: case ADDR_INFO_OSI_ADDRESSING:
552: ps_printf (ps, "%s", "osi_addressing");
553: ps_printf (ps, ":");
554: ps_printf (ps, "%s", info->nsap);
555: ps_printf (ps, "#");
556: if (info->tselector)
557: ps_printf (ps, "%s", info->tselector);
558: ps_printf (ps, "#");
559: if (info->sselector)
560: ps_printf (ps, "%s", info->sselector);
561: ps_printf (ps, "#");
562: if (info->pselector)
563: ps_printf (ps, "%s", info->pselector);
564: ps_printf (ps, "#");
565: if (info->place_holder)
566: pe_print (ps, info->place_holder, format);
567: ps_printf (ps, "#");
568: if (info->application_title)
569: pe_print (ps, info->application_title, format);
570: ps_printf (ps, "#");
571: if (info->per_app_context_info)
572: pe_print (ps, info->per_app_context_info, format);
573: break;
574: case ADDR_INFO_OSI_NSAP_ONLY:
575: ps_printf (ps, "%s", "osi_nsap_only");
576: ps_printf (ps, ":");
577: ps_printf (ps, "%s", info->nsap);
578: break;
579: case ADDR_INFO_OSI_NSAP_APPLIC_INFO:
580: ps_printf (ps, "%s", "osi_nsap_applic_info");
581: ps_printf (ps, ":");
582: ps_printf (ps, "%s", info->nsap);
583: ps_printf (ps, "#");
584: str_seq_print (ps, info->applic_info, format);
585: break;
586: case ADDR_INFO_OSI_NSAP_APPLIC_RELAY:
587: ps_printf (ps, "%s", "osi_nsap_applic_relay");
588: ps_printf (ps, ":");
589: ps_printf (ps, "%s", info->nsap);
590: ps_printf (ps, "#");
591: str_seq_print (ps, info->applic_relay, format);
592: break;
593: case ADDR_INFO_DTE_YBTS_OSI_ADDRESSING:
594: ps_printf (ps, "%s", "dte_ybts_osi_addressing");
595: ps_printf (ps, ":");
596: ps_printf (ps, "%s", info->dte_number);
597: ps_printf (ps, "#");
598: ps_printf (ps, "%s", info->ybts_string);
599: ps_printf (ps, "#");
600: if (info->tselector)
601: ps_printf (ps, "%s", info->tselector);
602: ps_printf (ps, "#");
603: if (info->sselector)
604: ps_printf (ps, "%s", info->sselector);
605: ps_printf (ps, "#");
606: if (info->pselector)
607: ps_printf (ps, "%s", info->pselector);
608: ps_printf (ps, "#");
609: if (info->place_holder)
610: pe_print (ps, info->place_holder, format);
611: ps_printf (ps, "#");
612: if (info->application_title)
613: pe_print (ps, info->application_title, format);
614: ps_printf (ps, "#");
615: if (info->per_app_context_info)
616: pe_print (ps, info->per_app_context_info, format);
617: break;
618: default:
619: ps_printf (ps, "%s", "addr_info print error");
620: LLOG (log_dsap, LLOG_EXCEPTIONS, ("addr_info_print(): Unknown addressing info type %d", info->addr_info_type));
621: break;
622: }
623: }
624:
625: static struct addr_info * str2addr_info (orig)
626: char * orig;
627: {
628: struct addr_info * result;
629: char * copy;
630: char * ptr_prev;
631: char * ptr_next;
632: char * eraser;
633:
634: result = (struct addr_info *) calloc (1, sizeof (struct addr_info));
635:
636: copy = strdup (orig);
637: ptr_prev = SkipSpace (copy);
638:
639: if ( (ptr_next=index (ptr_prev, ':')) == NULLCP)
640: {
641: parse_error ("first separator(:) missing in addr_info '%s'", orig);
642: free (copy);
643: free ((char *) result);
644: return ((struct addr_info *) NULL);
645: }
646: *ptr_next = '\0';
647:
648: /* Eliminate trailing spaces so that strcmp succeeds */
649: eraser = ptr_next;
650: for (eraser--; (*eraser) == ' '; eraser--)
651: {
652: (*eraser) = '\0';
653: }
654:
655: ptr_next++;
656:
657: if (strcmp (ptr_prev, "dte_only") == 0)
658: {
659: result->addr_info_type = ADDR_INFO_DTE_ONLY;
660: ptr_prev = SkipSpace (ptr_next);
661: result->dte_number = strdup (ptr_prev);
662: }
663: else if (strcmp (ptr_prev, "dte_applic_info") == 0)
664: {
665: result->addr_info_type = ADDR_INFO_DTE_APPLIC_INFO;
666: ptr_prev = SkipSpace (ptr_next);
667: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
668: {
669: parse_error ("second separator(#) missing in addr_info '%s'", orig);
670: free (copy);
671: free ((char *) result);
672: return ((struct addr_info *) NULL);
673: }
674: *ptr_next = '\0';
675: ptr_next++;
676:
677: result->dte_number = strdup (ptr_prev);
678:
679: ptr_prev = SkipSpace (ptr_next);
680:
681: result->applic_info = str2str_seq (ptr_prev);
682: }
683: else if (strcmp (ptr_prev, "dte_cudf") == 0)
684: {
685: result->addr_info_type = ADDR_INFO_DTE_CUDF;
686: ptr_prev = SkipSpace (ptr_next);
687: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
688: {
689: parse_error ("second separator(#) missing in addr_info '%s'", orig);
690: free (copy);
691: free ((char *) result);
692: return ((struct addr_info *) NULL);
693: }
694: *ptr_next = '\0';
695: ptr_next++;
696:
697: result->dte_number = strdup (ptr_prev);
698:
699: ptr_prev = SkipSpace (ptr_next);
700:
701: result->cudf = strdup (ptr_prev);
702: }
703: else if (strcmp (ptr_prev, "dte_cudf_applic_info") == 0)
704: {
705: result->addr_info_type = ADDR_INFO_DTE_CUDF_APPLIC_INFO;
706: ptr_prev = SkipSpace (ptr_next);
707: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
708: {
709: parse_error ("second separator(#) missing in addr_info '%s'", orig);
710: free (copy);
711: free ((char *) result);
712: return ((struct addr_info *) NULL);
713: }
714: *ptr_next = '\0';
715: ptr_next++;
716:
717: result->dte_number = strdup (ptr_prev);
718:
719: ptr_prev = SkipSpace (ptr_next);
720: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
721: {
722: parse_error ("third separator(#) missing in addr_info '%s'", orig);
723: free (copy);
724: free ((char *) result);
725: return ((struct addr_info *) NULL);
726: }
727: *ptr_next = '\0';
728: ptr_next++;
729:
730: result->cudf = strdup (ptr_prev);
731:
732: ptr_prev = SkipSpace (ptr_next);
733:
734: result->applic_info = str2str_seq (ptr_prev);
735: }
736: else if (strcmp (ptr_prev, "dte_ybts") == 0)
737: {
738: result->addr_info_type = ADDR_INFO_DTE_YBTS;
739: ptr_prev = SkipSpace (ptr_next);
740: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
741: {
742: parse_error ("second separator(#) missing in addr_info '%s'", orig);
743: free (copy);
744: free ((char *) result);
745: return ((struct addr_info *) NULL);
746: }
747: *ptr_next = '\0';
748: ptr_next++;
749:
750: result->dte_number = strdup (ptr_prev);
751:
752: ptr_prev = SkipSpace (ptr_next);
753:
754: result->ybts_string = strdup (ptr_prev);
755: }
756: else if (strcmp (ptr_prev, "dte_ybts_applic_info") == 0)
757: {
758: result->addr_info_type = ADDR_INFO_DTE_YBTS_APPLIC_INFO;
759: ptr_prev = SkipSpace (ptr_next);
760: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
761: {
762: parse_error ("second separator(#) missing in addr_info '%s'", orig);
763: free (copy);
764: free ((char *) result);
765: return ((struct addr_info *) NULL);
766: }
767: *ptr_next = '\0';
768: ptr_next++;
769:
770: result->dte_number = strdup (ptr_prev);
771:
772: ptr_prev = SkipSpace (ptr_next);
773: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
774: {
775: parse_error ("third separator(#) missing in addr_info '%s'", orig);
776: free (copy);
777: free ((char *) result);
778: return ((struct addr_info *) NULL);
779: }
780: *ptr_next = '\0';
781: ptr_next++;
782:
783: result->ybts_string = strdup (ptr_prev);
784:
785: ptr_prev = SkipSpace (ptr_next);
786:
787: result->applic_info = str2str_seq (ptr_prev);
788: }
789: else if (strcmp (ptr_prev, "dte_ybts_applic_relay") == 0)
790: {
791: result->addr_info_type = ADDR_INFO_DTE_YBTS_APPLIC_RELAY;
792: ptr_prev = SkipSpace (ptr_next);
793: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
794: {
795: parse_error ("second separator(#) missing in addr_info '%s'", orig);
796: free (copy);
797: free ((char *) result);
798: return ((struct addr_info *) NULL);
799: }
800: *ptr_next = '\0';
801: ptr_next++;
802:
803: result->dte_number = strdup (ptr_prev);
804:
805: ptr_prev = SkipSpace (ptr_next);
806: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
807: {
808: parse_error ("third separator(#) missing in addr_info '%s'", orig);
809: free (copy);
810: free ((char *) result);
811: return ((struct addr_info *) NULL);
812: }
813: *ptr_next = '\0';
814: ptr_next++;
815:
816: result->ybts_string = strdup (ptr_prev);
817:
818: ptr_prev = SkipSpace (ptr_next);
819:
820: result->applic_relay = str2str_seq (ptr_prev);
821: }
822: else if (strcmp (ptr_prev, "none_needed") == 0)
823: {
824: result->addr_info_type = ADDR_INFO_NONE_NEEDED;
825: }
826: else if (strcmp (ptr_prev, "osi_addressing") == 0)
827: {
828: result->addr_info_type = ADDR_INFO_OSI_ADDRESSING;
829: ptr_prev = SkipSpace (ptr_next);
830: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
831: {
832: parse_error ("second separator(#) missing in addr_info '%s'", orig);
833: free (copy);
834: free ((char *) result);
835: return ((struct addr_info *) NULL);
836: }
837: *ptr_next = '\0';
838: ptr_next++;
839:
840: result->nsap = strdup (ptr_prev);
841:
842: ptr_prev = ptr_next;
843:
844: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
845: {
846: parse_error ("third separator(#) missing in addr_info '%s'", orig);
847: free (copy);
848: free ((char *) result);
849: return ((struct addr_info *) NULL);
850: }
851: *ptr_next = '\0';
852: ptr_next++;
853:
854: result->tselector = strdup (ptr_prev);
855:
856: ptr_prev = ptr_next;
857:
858: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
859: {
860: parse_error ("fourth separator(#) missing in addr_info '%s'", orig);
861: free (copy);
862: free ((char *) result);
863: return ((struct addr_info *) NULL);
864: }
865: *ptr_next = '\0';
866: ptr_next++;
867:
868: result->sselector = strdup (ptr_prev);
869:
870: ptr_prev = ptr_next;
871:
872: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
873: {
874: parse_error ("fifth separator(#) missing in addr_info '%s'", orig);
875: free (copy);
876: free ((char *) result);
877: return ((struct addr_info *) NULL);
878: }
879: *ptr_next = '\0';
880: ptr_next++;
881:
882: result->pselector = strdup (ptr_prev);
883:
884: ptr_prev = ptr_next;
885:
886: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
887: {
888: parse_error ("sixth separator(#) missing in addr_info '%s'", orig);
889: free (copy);
890: free ((char *) result);
891: return ((struct addr_info *) NULL);
892: }
893: *ptr_next = '\0';
894: ptr_next++;
895:
896: result->place_holder = asnstr2pe (ptr_prev);
897:
898: ptr_prev = ptr_next;
899:
900: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
901: {
902: parse_error ("seventh separator(#) missing in addr_info '%s'", orig);
903: free (copy);
904: free ((char *) result);
905: return ((struct addr_info *) NULL);
906: }
907: *ptr_next = '\0';
908: ptr_next++;
909:
910: result->application_title = asnstr2pe (ptr_prev);
911:
912: ptr_prev = ptr_next;
913:
914: result->per_app_context_info = asnstr2pe (ptr_prev);
915: }
916: else if (strcmp (ptr_prev, "osi_nsap_only") == 0)
917: {
918: result->addr_info_type = ADDR_INFO_OSI_NSAP_ONLY;
919: ptr_prev = SkipSpace (ptr_next);
920: result->nsap = strdup (ptr_prev);
921: }
922: else if (strcmp (ptr_prev, "osi_nsap_applic_info") == 0)
923: {
924: result->addr_info_type = ADDR_INFO_OSI_NSAP_APPLIC_INFO;
925: ptr_prev = SkipSpace (ptr_next);
926: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
927: {
928: parse_error ("second separator(#) missing in addr_info '%s'", orig);
929: free (copy);
930: free ((char *) result);
931: return ((struct addr_info *) NULL);
932: }
933: *ptr_next = '\0';
934: ptr_next++;
935:
936: result->nsap = strdup (ptr_prev);
937:
938: ptr_prev = SkipSpace (ptr_next);
939:
940: result->applic_info = str2str_seq (ptr_prev);
941: }
942: else if (strcmp (ptr_prev, "osi_nsap_applic_relay") == 0)
943: {
944: result->addr_info_type = ADDR_INFO_OSI_NSAP_APPLIC_RELAY;
945: ptr_prev = SkipSpace (ptr_next);
946: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
947: {
948: parse_error ("second separator(#) missing in addr_info '%s'", orig);
949: free (copy);
950: free ((char *) result);
951: return ((struct addr_info *) NULL);
952: }
953: *ptr_next = '\0';
954: ptr_next++;
955:
956: result->nsap = strdup (ptr_prev);
957:
958: ptr_prev = SkipSpace (ptr_next);
959:
960: result->applic_relay = str2str_seq (ptr_prev);
961: }
962: else if (strcmp (ptr_prev, "dte_ybts_osi_addressing") == 0)
963: {
964: result->addr_info_type = ADDR_INFO_DTE_YBTS_OSI_ADDRESSING;
965: ptr_prev = SkipSpace (ptr_next);
966: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
967: {
968: parse_error ("second separator(#) missing in addr_info '%s'", orig);
969: free (copy);
970: free ((char *) result);
971: return ((struct addr_info *) NULL);
972: }
973: *ptr_next = '\0';
974: ptr_next++;
975:
976: result->dte_number = strdup (ptr_prev);
977:
978: ptr_prev = ptr_next;
979:
980: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
981: {
982: parse_error ("third separator(#) missing in addr_info '%s'", orig);
983: free (copy);
984: free ((char *) result);
985: return ((struct addr_info *) NULL);
986: }
987: *ptr_next = '\0';
988: ptr_next++;
989:
990: result->ybts_string = strdup (ptr_prev);
991:
992: ptr_prev = ptr_next;
993:
994: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
995: {
996: parse_error ("fourth separator(#) missing in addr_info '%s'", orig);
997: free (copy);
998: free ((char *) result);
999: return ((struct addr_info *) NULL);
1000: }
1001: *ptr_next = '\0';
1002: ptr_next++;
1003:
1004: result->tselector = strdup (ptr_prev);
1005:
1006: ptr_prev = ptr_next;
1007:
1008: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
1009: {
1010: parse_error ("fifth separator(#) missing in addr_info '%s'", orig);
1011: free (copy);
1012: free ((char *) result);
1013: return ((struct addr_info *) NULL);
1014: }
1015: *ptr_next = '\0';
1016: ptr_next++;
1017:
1018: result->sselector = strdup (ptr_prev);
1019:
1020: ptr_prev = ptr_next;
1021:
1022: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
1023: {
1024: parse_error ("sixth separator(#) missing in addr_info '%s'", orig);
1025: free (copy);
1026: free ((char *) result);
1027: return ((struct addr_info *) NULL);
1028: }
1029: *ptr_next = '\0';
1030: ptr_next++;
1031:
1032: result->pselector = strdup (ptr_prev);
1033:
1034: ptr_prev = ptr_next;
1035:
1036: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
1037: {
1038: parse_error ("seventh separator(#) missing in addr_info '%s'", orig);
1039: free (copy);
1040: free ((char *) result);
1041: return ((struct addr_info *) NULL);
1042: }
1043: *ptr_next = '\0';
1044: ptr_next++;
1045:
1046: result->place_holder = asnstr2pe (ptr_prev);
1047:
1048: ptr_prev = ptr_next;
1049:
1050: if ( (ptr_next=index (ptr_prev, '#')) == NULLCP)
1051: {
1052: parse_error ("eighth separator(#) missing in addr_info '%s'", orig);
1053: free (copy);
1054: free ((char *) result);
1055: return ((struct addr_info *) NULL);
1056: }
1057: *ptr_next = '\0';
1058: ptr_next++;
1059:
1060: result->application_title = asnstr2pe (ptr_prev);
1061:
1062: ptr_prev = ptr_next;
1063:
1064: result->per_app_context_info = asnstr2pe (ptr_prev);
1065: }
1066: else
1067: {
1068: parse_error ("unknown addr_info type: '%s'", ptr_prev);
1069: free (copy);
1070: free ((char *) result);
1071: return ((struct addr_info *) NULL);
1072: }
1073:
1074: return (result);
1075: }
1076:
1077: static nrs_routes_free (arg)
1078: struct nrs_routes * arg;
1079: {
1080: if (arg == (struct nrs_routes *)NULL)
1081: return;
1082:
1083: if (arg->cost)
1084: pe_free (arg->cost);
1085:
1086: if (arg->addr_info)
1087: addr_info_free (arg->addr_info);
1088:
1089: if (arg->next)
1090: nrs_routes_free (arg->next);
1091:
1092: free ((char *) arg);
1093: }
1094:
1095: static struct nrs_routes * nrs_routes_cpy (arg)
1096: struct nrs_routes * arg;
1097: {
1098: struct nrs_routes * ret;
1099:
1100: if (arg == (struct nrs_routes *)NULL)
1101: return ((struct nrs_routes *)NULL);
1102:
1103: ret = (struct nrs_routes *) smalloc (sizeof (struct nrs_routes));
1104:
1105: if (arg->cost == NULLPE)
1106: ret->cost = NULLPE;
1107: else
1108: ret->cost = pe_cpy (arg->cost);
1109:
1110: ret->addr_info = addr_info_cpy (arg->addr_info);
1111:
1112: ret->next = nrs_routes_cpy (arg->next);
1113:
1114: return (ret);
1115: }
1116:
1117: static nrs_routes_cmp (arg1, arg2)
1118: struct nrs_routes * arg1;
1119: struct nrs_routes * arg2;
1120: {
1121: int ret;
1122:
1123: if (arg1 == (struct nrs_routes *)NULL)
1124: if (arg2 == (struct nrs_routes *)NULL)
1125: return (0);
1126: else
1127: return (-1);
1128:
1129: if (arg2 == (struct nrs_routes *)NULL)
1130: return (1);
1131:
1132: if ((ret = pe_cmp (arg1->cost, arg2->cost)) != 0)
1133: return (ret);
1134:
1135: if ((ret = addr_info_cmp (arg1->addr_info, arg2->addr_info)) != 0)
1136: return (ret);
1137:
1138: return (nrs_routes_cmp (arg1->next, arg2->next));
1139: }
1140:
1141: static nrs_routes_print (ps, routes, format)
1142: register PS ps;
1143: struct nrs_routes * routes;
1144: int format;
1145: {
1146: struct nrs_routes * rt;
1147:
1148: for (rt=routes; rt != (struct nrs_routes *)NULL; rt = rt->next)
1149: {
1150: if (format == READOUT)
1151: ps_printf (ps, "\n---> ");
1152:
1153: if (rt->cost)
1154: pe_print (ps, rt->cost, format);
1155:
1156: ps_printf (ps, "#");
1157:
1158: if (rt->addr_info)
1159: addr_info_print (ps, rt->addr_info, format);
1160:
1161: if (rt->next != (struct nrs_routes *)NULL)
1162: ps_printf (ps, "|");
1163: }
1164: }
1165:
1166: static struct nrs_routes * str2nrs_routes (orig)
1167: char * orig;
1168: {
1169: struct nrs_routes * result;
1170: struct nrs_routes **rt;
1171: char * copy;
1172: char * ptr_prev;
1173: char * ptr_next;
1174: char * ptr_mid;
1175:
1176: result = (struct nrs_routes *) smalloc (sizeof (struct nrs_routes));
1177:
1178: ptr_prev = SkipSpace(orig);
1179:
1180: if ((ptr_prev == NULLCP) || ((*ptr_prev) == '\0'))
1181: {
1182: return ((struct nrs_routes *)NULL);
1183: }
1184:
1185: rt = &(result);
1186:
1187: while ( (ptr_next=index (ptr_prev, '|')) != NULLCP)
1188: {
1189: *ptr_next = '\0';
1190: ptr_next++;
1191: (*rt) = (struct nrs_routes *) smalloc (sizeof (struct nrs_routes));
1192:
1193: copy = strdup (ptr_prev);
1194:
1195: if ( (ptr_mid=index (ptr_prev, '#')) == NULLCP)
1196: {
1197: parse_error ("separator(#) missing in nrs_route '%s'", copy);
1198: free (copy);
1199: free ((char *) result);
1200: return ((struct nrs_routes *) NULL);
1201: }
1202: *ptr_mid = '\0';
1203: ptr_mid++;
1204:
1205: /*
1206: * route-cost is not optional - use encoding of NULL
1207: * when this element is absent
1208: */
1209: if ((*ptr_prev) == '\0')
1210: {
1211: (*rt)->cost = pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_NULL);
1212: }
1213: else if (((*rt)->cost = asnstr2pe (ptr_prev)) == NULLPE)
1214: {
1215: parse_error ("route-cost ASN malformed in nrs_route '%s'", copy);
1216: free (copy);
1217: free ((char *) result);
1218: return ((struct nrs_routes *) NULL);
1219: }
1220:
1221: ptr_prev = SkipSpace (ptr_mid);
1222:
1223: (*rt)->addr_info = str2addr_info (ptr_prev);
1224:
1225: rt = &((*rt)->next);
1226: ptr_prev = SkipSpace(ptr_next);
1227: }
1228:
1229: (*rt) = (struct nrs_routes *) smalloc (sizeof (struct nrs_routes));
1230:
1231: copy = strdup (ptr_prev);
1232:
1233: if ( (ptr_mid=index (ptr_prev, '#')) == NULLCP)
1234: {
1235: parse_error ("separator(#) missing in nrs_route '%s'", copy);
1236: free (copy);
1237: free ((char *) result);
1238: return ((struct nrs_routes *) NULL);
1239: }
1240: *ptr_mid = '\0';
1241: ptr_mid++;
1242:
1243: /*
1244: * route-cost is not optional - use encoding of NULL
1245: * when this element is absent
1246: */
1247: if ((ptr_prev == NULLCP) || ((*ptr_prev) == '\0'))
1248: {
1249: (*rt)->cost = pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_NULL);
1250: }
1251: else if (((*rt)->cost = asnstr2pe (ptr_prev)) == NULLPE)
1252: {
1253: parse_error ("route-cost ASN malformed in nrs_route '%s'", copy);
1254: free (copy);
1255: free ((char *) result);
1256: return ((struct nrs_routes *) NULL);
1257: }
1258:
1259: ptr_prev = SkipSpace (ptr_mid);
1260:
1261: (*rt)->addr_info = str2addr_info (ptr_prev);
1262:
1263: (*rt)->next = (struct nrs_routes *)NULL;
1264:
1265: return (result);
1266: }
1267:
1268: static nrs_info_free (arg)
1269: struct nrs_info * arg;
1270: {
1271: if (arg == (struct nrs_info *)NULL)
1272: return;
1273:
1274: if (arg->routes)
1275: nrs_routes_free (arg->routes);
1276:
1277: free ((char *) arg);
1278: }
1279:
1280: static struct nrs_info * nrs_info_cpy (arg)
1281: struct nrs_info * arg;
1282: {
1283: struct nrs_info * result;
1284:
1285: if (arg == (struct nrs_info *)NULL)
1286: return ((struct nrs_info *)NULL);
1287:
1288: result = (struct nrs_info *) smalloc (sizeof (struct nrs_info));
1289:
1290: result->context = arg->context;
1291:
1292: result->addr_sp_id = arg->addr_sp_id;
1293:
1294: result->routes = nrs_routes_cpy (arg->routes);
1295:
1296: return (result);
1297: }
1298:
1299: static nrs_info_cmp (arg1, arg2)
1300: struct nrs_info * arg1;
1301: struct nrs_info * arg2;
1302: {
1303: if (arg1 == (struct nrs_info *) NULL)
1304: if (arg2 == (struct nrs_info *) NULL)
1305: return (0);
1306: else
1307: return (-1);
1308:
1309: if (arg2 == (struct nrs_info *) NULL)
1310: return (1);
1311:
1312: if (arg1->context < arg2->context)
1313: return (-1);
1314:
1315: if (arg1->context > arg2->context)
1316: return (1);
1317:
1318: if (arg1->addr_sp_id < arg2->addr_sp_id)
1319: return (-1);
1320:
1321: if (arg1->addr_sp_id > arg2->addr_sp_id)
1322: return (1);
1323:
1324: return (nrs_routes_cmp (arg1->routes, arg2->routes));
1325: }
1326:
1327: static context_print (ps, ctx, format)
1328: register PS ps;
1329: int ctx;
1330: int format;
1331: {
1332: if (format != READOUT)
1333: {
1334: ps_printf (ps, "%d", ctx);
1335: return;
1336: }
1337:
1338: switch(ctx)
1339: {
1340: case NRS_Context_X29:
1341: ps_printf (ps, "x29");
1342: break;
1343: case NRS_Context_TS29:
1344: ps_printf (ps, "ts29");
1345: break;
1346: case NRS_Context_NIFTP:
1347: ps_printf (ps, "niftp");
1348: break;
1349: case NRS_Context_MAIL_NIFTP:
1350: ps_printf (ps, "mail-niftp");
1351: break;
1352: case NRS_Context_MAIL_TELEX:
1353: ps_printf (ps, "mail-telex");
1354: break;
1355: case NRS_Context_JTMP:
1356: ps_printf (ps, "jtmp");
1357: break;
1358: case NRS_Context_JTMP_FILES:
1359: ps_printf (ps, "jtmp-files");
1360: break;
1361: case NRS_Context_JTMP_REG:
1362: ps_printf (ps, "jtmp-reg");
1363: break;
1364: case NRS_Context_YBTS_NODE:
1365: ps_printf (ps, "ybts-node");
1366: break;
1367: case NRS_Context_YBTS:
1368: ps_printf (ps, "ybts");
1369: break;
1370: case NRS_Context_FTAM:
1371: ps_printf (ps, "ftam");
1372: break;
1373: case NRS_Context_JTM:
1374: ps_printf (ps, "jtm");
1375: break;
1376: case NRS_Context_JTM_REG:
1377: ps_printf (ps, "jtm-reg");
1378: break;
1379: case NRS_Context_VT:
1380: ps_printf (ps, "vt");
1381: break;
1382: case NRS_Context_MOTIS:
1383: ps_printf (ps, "motis");
1384: break;
1385: default:
1386: ps_printf (ps, "%d", ctx);
1387: break;
1388: }
1389: }
1390:
1391: static addr_sp_id_print (ps, asi, format)
1392: register PS ps;
1393: int asi;
1394: int format;
1395: {
1396: if (format != READOUT)
1397: {
1398: ps_printf (ps, "%d", asi);
1399: return;
1400: }
1401:
1402: switch(asi)
1403: {
1404: case NRS_Address_Space_Id_PSS:
1405: ps_printf (ps, "pss");
1406: break;
1407: case NRS_Address_Space_Id_JANET:
1408: ps_printf (ps, "janet");
1409: break;
1410: case NRS_Address_Space_Id_TELEX:
1411: ps_printf (ps, "telex");
1412: break;
1413: case NRS_Address_Space_Id_OSI_CONS:
1414: ps_printf (ps, "osi-cons");
1415: break;
1416: default:
1417: ps_printf (ps, "%d", asi);
1418: break;
1419: }
1420: }
1421:
1422: static nrs_info_print (ps, nrs, format)
1423: register PS ps;
1424: struct nrs_info * nrs;
1425: int format;
1426: {
1427: context_print (ps, nrs->context, format);
1428:
1429: ps_printf (ps, "$");
1430:
1431: addr_sp_id_print (ps, nrs->addr_sp_id, format);
1432:
1433: ps_printf (ps, "$");
1434:
1435: if (nrs->routes)
1436: nrs_routes_print (ps, nrs->routes, format);
1437: }
1438:
1439: static str2context (orig)
1440: char * orig;
1441: {
1442: char * str;
1443: char * cc;
1444: int its_all_digits;
1445:
1446: str = SkipSpace(orig);
1447: its_all_digits = 1;
1448:
1449: if ((str == NULLCP) || ((*str) == '\0'))
1450: {
1451: parse_error ("no context string", NULLCP);
1452: return(-1);
1453: }
1454:
1455: /* Check for numeric-ness and strip trailing spaces */
1456: for (cc=str; (*cc)!='\0'; cc++)
1457: {
1458: if (isspace(*cc))
1459: {
1460: (*cc) = '\0';
1461: cc++;
1462: break;
1463: }
1464:
1465: if (!isdigit(*cc))
1466: {
1467: its_all_digits = 0;
1468: }
1469: }
1470:
1471: while (isspace(*cc))
1472: cc++;
1473: if ((*cc) != '\0')
1474: {
1475: parse_error ("malformed context string", NULLCP);
1476: return(-1);
1477: }
1478:
1479: if (its_all_digits)
1480: {
1481: return(atoi(str));
1482: }
1483: else if (strcmp (str, "x29") == 0)
1484: {
1485: return (NRS_Context_X29);
1486: }
1487: else if (strcmp (str, "ts29") == 0)
1488: {
1489: return (NRS_Context_TS29);
1490: }
1491: else if (strcmp (str, "niftp") == 0)
1492: {
1493: return (NRS_Context_NIFTP);
1494: }
1495: else if (strcmp (str, "mail-niftp") == 0)
1496: {
1497: return (NRS_Context_MAIL_NIFTP);
1498: }
1499: else if (strcmp (str, "mail-telex") == 0)
1500: {
1501: return (NRS_Context_MAIL_TELEX);
1502: }
1503: else if (strcmp (str, "jtmp") == 0)
1504: {
1505: return (NRS_Context_JTMP);
1506: }
1507: else if (strcmp (str, "jtmp-files") == 0)
1508: {
1509: return (NRS_Context_JTMP_FILES);
1510: }
1511: else if (strcmp (str, "jtmp-reg") == 0)
1512: {
1513: return (NRS_Context_JTMP_REG);
1514: }
1515: else if (strcmp (str, "ybts-node") == 0)
1516: {
1517: return (NRS_Context_YBTS_NODE);
1518: }
1519: else if (strcmp (str, "ybts") == 0)
1520: {
1521: return (NRS_Context_YBTS);
1522: }
1523: else if (strcmp (str, "ftam") == 0)
1524: {
1525: return (NRS_Context_FTAM);
1526: }
1527: else if (strcmp (str, "jtm") == 0)
1528: {
1529: return (NRS_Context_JTM);
1530: }
1531: else if (strcmp (str, "jtm-reg") == 0)
1532: {
1533: return (NRS_Context_JTM_REG);
1534: }
1535: else if (strcmp (str, "vt") == 0)
1536: {
1537: return (NRS_Context_VT);
1538: }
1539: else if (strcmp (str, "motis") == 0)
1540: {
1541: return (NRS_Context_MOTIS);
1542: }
1543: else
1544: {
1545: parse_error ("unknown context string '%s'", str);
1546: return (-1);
1547: }
1548: }
1549:
1550: static str2addr_sp_id (orig)
1551: char * orig;
1552: {
1553: char * str;
1554: char * cc;
1555: int its_all_digits;
1556:
1557: str = SkipSpace(orig);
1558: its_all_digits = 1;
1559:
1560: if ((str == NULLCP) || ((*str) == '\0'))
1561: {
1562: parse_error ("no address space string", NULLCP);
1563: return(-1);
1564: }
1565:
1566: /* Check for numeric-ness and strip trailing spaces */
1567: for (cc=str; (*cc)!='\0'; cc++)
1568: {
1569: if (isspace(*cc))
1570: {
1571: (*cc) = '\0';
1572: cc++;
1573: break;
1574: }
1575:
1576: if (!isdigit(*cc))
1577: {
1578: its_all_digits = 0;
1579: }
1580: }
1581:
1582: while (isspace(*cc))
1583: cc++;
1584: if ((*cc) != '\0')
1585: {
1586: parse_error ("malformed address space string", NULLCP);
1587: return(-1);
1588: }
1589:
1590: if (its_all_digits)
1591: {
1592: return(atoi(str));
1593: }
1594: else if (strcmp (str, "pss") == 0)
1595: {
1596: return(NRS_Address_Space_Id_PSS);
1597: }
1598: else if (strcmp (str, "janet") == 0)
1599: {
1600: return(NRS_Address_Space_Id_JANET);
1601: }
1602: else if (strcmp (str, "telex") == 0)
1603: {
1604: return(NRS_Address_Space_Id_TELEX);
1605: }
1606: else if (strcmp (str, "osi-cons") == 0)
1607: {
1608: return(NRS_Address_Space_Id_OSI_CONS);
1609: }
1610: else
1611: {
1612: parse_error ("unknown address space string '%s'", str);
1613: return (-1);
1614: }
1615: }
1616:
1617: static struct nrs_info * str2nrs_info (orig)
1618: char * orig;
1619: {
1620: struct nrs_info * result;
1621: char * copy;
1622: char * ptr_prev;
1623: char * ptr_next;
1624:
1625: result = (struct nrs_info *) smalloc (sizeof (struct nrs_info));
1626:
1627: copy = strdup (orig);
1628: ptr_prev = copy;
1629:
1630: if ( (ptr_next=index (ptr_prev, '$')) == NULLCP)
1631: {
1632: parse_error ("first separator($) missing in nrs_info '%s'", orig);
1633: free (copy);
1634: free ((char *) result);
1635: return ((struct nrs_info *) NULL);
1636: }
1637: *ptr_next = '\0';
1638: ptr_next++;
1639:
1640: if ((result->context = str2context (ptr_prev)) == -1)
1641: {
1642: parse_error ("malformed context '%s'", orig);
1643: free (copy);
1644: free ((char *) result);
1645: return ((struct nrs_info *) NULL);
1646: }
1647:
1648: ptr_prev = ptr_next;
1649:
1650: if ( (ptr_next=index (ptr_prev, '$')) == NULLCP)
1651: {
1652: parse_error ("second separator($) missing in nrs_info '%s'", orig);
1653: free (copy);
1654: free ((char *) result);
1655: return ((struct nrs_info *) NULL);
1656: }
1657: *ptr_next = '\0';
1658: ptr_next++;
1659:
1660: if ((result->addr_sp_id = str2addr_sp_id (ptr_prev)) == -1)
1661: {
1662: parse_error ("malformed context '%s'", orig);
1663: free (copy);
1664: free ((char *) result);
1665: return ((struct nrs_info *) NULL);
1666: }
1667:
1668: if (((ptr_prev = SkipSpace (ptr_next)) == NULLCP) || ((*ptr_prev) == '\0'))
1669: {
1670: result->routes = ((struct nrs_routes *)NULL);
1671: return (result);
1672: }
1673:
1674: if ((result->routes = str2nrs_routes (ptr_prev)) == (struct nrs_routes *)NULL)
1675: {
1676: parse_error ("unparseable routes in nrs_info '%s'", orig);
1677: free (copy);
1678: free ((char *) result);
1679: return ((struct nrs_info *) NULL);
1680: }
1681:
1682: return (result);
1683: }
1684:
1685: static PE nrs_info_enc (nrs)
1686: struct nrs_info * nrs;
1687: {
1688: PE ret_pe;
1689:
1690: if (encode_QuipuNRS_NRSInformation (&ret_pe, 1, 0, NULLCP, nrs) != OK)
1691: return (NULLPE);
1692:
1693: return (ret_pe);
1694: }
1695:
1696: static struct nrs_info * nrs_info_dec (pe)
1697: PE pe;
1698: {
1699: struct nrs_info * nrs;
1700:
1701: if (decode_QuipuNRS_NRSInformation (pe, 1, NULLIP, NULLVP, &nrs) != OK)
1702: {
1703: return ((struct nrs_info *) NULL);
1704: }
1705:
1706: return (nrs);
1707: }
1708:
1709: nrs_info_syntax ()
1710: {
1711: (void) add_attribute_syntax ("NRSInformation",
1712: (IFP) nrs_info_enc, (IFP) nrs_info_dec,
1713: (IFP) str2nrs_info, nrs_info_print,
1714: (IFP) nrs_info_cpy, nrs_info_cmp,
1715: nrs_info_free, NULLCP,
1716: NULLIFP, TRUE);
1717: }
1718:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.